@isTest public with sharing class StartTradingController2Test { public static String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); public static String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); public static String leadNR = Schema.SObjectType.Lead.getRecordTypeInfosByDeveloperName().get('NewDaily_Report').getRecordTypeId(); public static String rectAg = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); public static User thisUser = [ SELECT Id from User WHERE Id = :UserInfo.getUserId()]; @testSetup static void testSetup() { System.runAs(thisUser){ Account testRectcoAccounts = new Account(Name = 'testRectcoAccount', RecordTypeId = rectHp); insert testRectcoAccounts; Account testRectHpAccounts = new Account(Name = 'testRectHpAccount', RecordTypeId = rectCo, Hospital__c = testRectcoAccounts.id); insert testRectHpAccounts; Contact testContacts = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber',RecordTypeId = rectAg, AWS_Data_Id__c = 'TestContact', accountId = testRectHpAccounts.id); insert testContacts; Lead testLeads = new Lead(LastName='testLead', Company='testLead',RecordTypeId = leadNR, Hospital_Name__c = testRectHpAccounts.id, Contact_Name__c = testContacts.Id); insert testLeads; } } static testMethod void test1() { Lead lea = [SELECT Id FROM Lead WHERE RecordTypeId =:leadNR LIMIT 1]; StartTradingController2.init(lea.Id); StartTradingController2.start(lea.Id); // StartTradingController2.start('00Q1000000GC9TqEAL'); } }