/* Class Name:InvocaCallLogMatchWithLeadBatch_Test Developer Name: Krishna Nagendra Rao.Yerru Created Date: 06-Feb-2019 Apex Class Name(for Code coverage): InvocaCallLogMatchWithLeadBatch,InvocaCallLogMatchWithLeadBatchSchdlr Project Name: SP-3530:Create Batch Process to match Invoca Call Logs with Leads ------------------------------------------------------------------------------------------------------------------ CH# Description Developer Modified Date ------------------------------------------------------------------------------------------------------------------ */ @isTest public class InvocaCallLogMatchWithLeadBatch_Test{ @testSetup static void setup() { //Fetching Record Type Id RsagLeadRt = Schema.SObjectType.Lead.getRecordTypeInfosByName().get('RSAG New Account Lead').getRecordTypeId(); //Partner or Bank record creation List<Bank__c> bnk=new List<Bank__c>(); Bank__c bank1 = new Bank__c(); bank1.Name = 'BAMS'; bnk.add(bank1); Bank__c bank = new Bank__c(); bank.Name = 'Please Choose Valid Bank'; bnk.add(bank); insert bnk; //Lead record creation List<Lead> lstLeads = new List<Lead>(); Lead testlead = new Lead( RecordTypeId =RsagLeadRt, Company = 'Testing #ABC1234', LeadSource = 'Self Sourced', Status = 'Open', LastName = 'testing1', MC_V_Ann_Vol__c = 50, Phone = '3017662386', Bank_Lookup__c = bank.Id); lstLeads.add(testlead); Lead testlead1 = new Lead( RecordTypeId = RsagLeadRt, Company = 'Test', LeadSource = 'Self Sourced', Status = 'Open', LastName = 'testing2', MC_V_Ann_Vol__c = 70, Phone = '4017662386', Bank_Lookup__c = bank.Id); lstLeads.add(testlead1); Lead testlead2 = new Lead( RecordTypeId =RsagLeadRt, Company = '#XYZ1234', LeadSource = 'Self Sourced', Status = 'Open', LastName = 'testing3', MC_V_Ann_Vol__c = 50, Phone = '5017662386', Bank_Lookup__c = bank.Id); lstLeads.add(testlead2); Lead testlead3 = new Lead( RecordTypeId =RsagLeadRt, Company = '#XYZ12346', LeadSource = 'Self Sourced', Status = 'Open', LastName = 'testing3', MC_V_Ann_Vol__c = 50, Phone = '5017662386', Bank_Lookup__c = bank.Id); lstLeads.add(testlead3); Insert lstLeads; Campaign c = new Campaign(Name='55120-CloComLiv'); insert c; List<CampaignMember> cmlist = new List<CampaignMember>(); List<lead> invocaCampleads=[select id,Company from lead where RecordTypeId=:RsagLeadRt]; for(lead les:invocaCampleads){ CampaignMember cml = new CampaignMember(); cml.campaignid = c.id; cml.leadid = les.id; cmlist.add(cml); } insert cmlist; System.assert(lstLeads!= null); //Invoca Call Log Record Creation List<INVOCA_FOR_SF__Invoca_Call_Log__c> inv=new List<INVOCA_FOR_SF__Invoca_Call_Log__c>(); INVOCA_FOR_SF__Invoca_Call_Log__c calllog1 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead.id,INVOCA_FOR_SF__transaction_id__c='42A38A2A-01DA2713',INVOCA_FOR_SF__keypresses__c='[1]', INVOCA_FOR_SF__Connect_Duration__c =25.0,INVOCA_FOR_SF__calling_phone_number__c='301-7662386',INVOCA_FOR_SF__advertiser_campaign_name__c='55120-CloComLiv'); inv.add(calllog1); INVOCA_FOR_SF__Invoca_Call_Log__c calllog2 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead1.id,INVOCA_FOR_SF__transaction_id__c='52A38A2A-01DA2713',INVOCA_FOR_SF__keypresses__c='[-]', INVOCA_FOR_SF__Connect_Duration__c =25.0,INVOCA_FOR_SF__calling_phone_number__c=testlead1.Phone,INVOCA_FOR_SF__advertiser_campaign_name__c='55120-CloComLiv'); inv.add(calllog2); INVOCA_FOR_SF__Invoca_Call_Log__c calllog3 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead2.id,INVOCA_FOR_SF__transaction_id__c='62A38A2A-01DA2713',INVOCA_FOR_SF__keypresses__c='[2]', INVOCA_FOR_SF__Connect_Duration__c =35.0,INVOCA_FOR_SF__calling_phone_number__c=testlead2.Phone,INVOCA_FOR_SF__advertiser_campaign_name__c='55120-CloComLiv'); inv.add(calllog3); INVOCA_FOR_SF__Invoca_Call_Log__c calllog4 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead3.id,INVOCA_FOR_SF__transaction_id__c='72A38A2A-01DA2713',INVOCA_FOR_SF__keypresses__c='[3]', INVOCA_FOR_SF__Connect_Duration__c =35.0,INVOCA_FOR_SF__calling_phone_number__c=testlead3.Phone,INVOCA_FOR_SF__advertiser_campaign_name__c='55120-CloComLiv'); inv.add(calllog4); INVOCA_FOR_SF__Invoca_Call_Log__c calllog5 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead2.id,INVOCA_FOR_SF__transaction_id__c='52A38A2A-01DA2883',INVOCA_FOR_SF__keypresses__c='[-]', INVOCA_FOR_SF__Connect_Duration__c =40.0,INVOCA_FOR_SF__calling_phone_number__c=testlead2.Phone,INVOCA_FOR_SF__advertiser_campaign_name__c='55120-CloComLiv'); inv.add(calllog5); INVOCA_FOR_SF__Invoca_Call_Log__c calllog6 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead2.id,INVOCA_FOR_SF__transaction_id__c='52A38A2A-01DA28L3',INVOCA_FOR_SF__keypresses__c='[-]', INVOCA_FOR_SF__Connect_Duration__c =40.0,INVOCA_FOR_SF__calling_phone_number__c=testlead2.Phone); inv.add(calllog6); INVOCA_FOR_SF__Invoca_Call_Log__c calllog7 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__transaction_id__c='52A38A2A-01DY28L3',INVOCA_FOR_SF__keypresses__c='[-]', INVOCA_FOR_SF__Connect_Duration__c =40.0,INVOCA_FOR_SF__calling_phone_number__c=testlead2.Phone); inv.add(calllog7); INVOCA_FOR_SF__Invoca_Call_Log__c calllog8 = new INVOCA_FOR_SF__Invoca_Call_Log__c (INVOCA_FOR_SF__Lead__c=testlead.id,INVOCA_FOR_SF__transaction_id__c='42A38A2A-01YY2713',INVOCA_FOR_SF__keypresses__c='[1]', INVOCA_FOR_SF__Connect_Duration__c =25.0,INVOCA_FOR_SF__calling_phone_number__c='(301)-766 2386',INVOCA_FOR_SF__advertiser_campaign_name__c='55120-CloComLiv'); inv.add(calllog8); insert inv; } static testmethod void InvocaCallLogMatchWithLeadBatchMethod(){ Test.StartTest(); List<lead> invocaleads=[select id,Company from lead where Phone='5017662386']; List<INVOCA_FOR_SF__Invoca_Call_Log__c> invocacallls=[select id,Status__c from INVOCA_FOR_SF__Invoca_Call_Log__c where INVOCA_FOR_SF__Lead__c=:invocaleads[0].id]; InvocaCallLogMatchWithLeadBatch newLeaddelbatch = new InvocaCallLogMatchWithLeadBatch(); Database.executeBatch(newLeaddelbatch); Test.StopTest(); System.AssertNotEquals('Matched',invocacallls[0].Status__c); } static testmethod void InvocaCallLogMatchWithLeadBatchShdlrmethod() { String CRON_EXP = '0 0 4 ? * SUN *'; Test.startTest(); String jobId = System.schedule('INVBatchScheduleTest',CRON_EXP,new InvocaCallLogMatchWithLeadBatchSchdlr()); CronTrigger ct = [SELECT id, CronExpression, TimesTriggered,NextFireTime FROM CronTrigger WHERE id = :jobId]; System.assertEquals(CRON_EXP, ct.CronExpression); System.assertEquals(0, ct.TimesTriggered); Test.stopTest(); } }
Wednesday, 6 November 2019
Sample batch test claaa
Subscribe to:
Posts (Atom)