Untitled
unknown
plain_text
3 years ago
4.8 kB
5
Indexable
Never
@isTest public with sharing class CEP_LC_ModifyContactDataTst { @TestSetup static void setup(){ wrts_prcgvr.InstallIntegration.install(); insert TestDataCustomer.createPhaseManagerSettingFileMetadata(); insert TestDataCustomer.createPhaseManagerSettingIntegration(); insert TestDataCustomer.createPhaseManagerSettingCase(); insert TestDataCustomer.createPhaseManagerSettingIntegrationCase(); insert TestDataCustomer.createPhase('BOZZA'); insert TestDataCustomer.createPhase('INLAVORAZIONE'); wrts_prcgvr__PhaseTransition__c pt = new wrts_prcgvr__PhaseTransition__c( wrts_prcgvr__Code__c = 'code', wrts_prcgvr__Type__c = 'A', wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('CEP_RT_ChangeContactData').getRecordTypeId(), wrts_prcgvr__RecordTypeName__c = 'CEP_RT_ChangeContactData', wrts_prcgvr__OriginPhase__c = 'BOZZA', wrts_prcgvr__DestinationPhase__c = 'INLAVORAZIONE', wrts_prcgvr__Tags__c = '' ); insert pt; insert TestDataCustomer.createPhase('START'); insert TestDataCustomer.createPhase('ANC'); wrts_prcgvr__PhaseTransition__c ptic = new wrts_prcgvr__PhaseTransition__c( wrts_prcgvr__Code__c = 'code', wrts_prcgvr__Type__c = 'A', wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.IntegrationCase__c.getRecordTypeInfosByDeveloperName().get('CEP_RT_ChangeContactData').getRecordTypeId(), wrts_prcgvr__RecordTypeName__c = 'CEP_RT_ChangeContactData', wrts_prcgvr__OriginPhase__c = 'START', wrts_prcgvr__DestinationPhase__c = 'ANC', wrts_prcgvr__Tags__c = '' ); insert ptic; user u = TestDataCustomer.user().admindUser().build(); insert u; Account acc = TestDataCustomer.account().physicalPersonAccount().build(); acc.Segment__c = 'Mass Market'; System.runAs(u){ insert acc; } Interaction__c interaction = TestDataCustomer.interaction().createInteraction().build(); insert interaction; Individual individual = TestDataCustomer.individual().createIndividual().build(); insert individual; Account bsnAcc = TestDataCustomer.account().businessAccount().build(); insert bsnAcc; Contact cont = TestDataCustomer.Contact().createContact().build(); cont.AccountId = bsnAcc.Id; cont.IndividualId = individual.Id; cont.Email = 'Test2@email.com'; insert cont; AccountContactRelation acr = TestDataCustomer.AccountContactRelation().createAccountContactRelation(cont.Id,acc.Id).build(); acr.Roles = 'Customer'; acr.isActive = true; insert acr; case c = TestDataCustomer.case().createCase(acc.Id).build(); c.Status = 'Bozza'; c.Email__c = 'Test@Email.it'; c.OldEmail__c = 'Test2@email.com'; c.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('CEP_RT_ChangeContactData').getRecordTypeId(); insert c; } @isTest public static void verifyProcessStartTest(){ Account acc = [SELECT Id FROM Account WHERE LastName__c = 'Bianchi']; Test.startTest(); String accId = CEP_LC_ModifyContactData.verifyProcessStart(acc.Id); System.assertEquals(true, accId != ''); Test.stopTest(); } @isTest public static void createCaseTest(){ Account acc = [SELECT Id FROM Account WHERE LastName__c = 'Bianchi']; Test.startTest(); String caseId = CEP_LC_ModifyContactData.createCase(acc.Id,'Modifica Dati di Contatto'); System.assertEquals(true, caseId != ''); Test.stopTest(); } @isTest public static void getIsMassMarketTest(){ Account acc = [SELECT Id FROM Account WHERE LastName__c = 'Bianchi']; Test.startTest(); Boolean ver = CEP_LC_ModifyContactData.getIsMassMarket(acc.Id); System.assertEquals(true, ver); Test.stopTest(); } @isTest public static void updateCase(){ Account acc = [SELECT Id, (SELECT Id FROM cases) FROM Account WHERE LastName__c = 'Bianchi']; case c = acc.Cases[0]; Contact cont = [SELECT Id FROM Contact limit 1]; Test.startTest(); CEP_LC_ModifyContactData.updateCase(c.Id); IntegrationCase__c ic = [SELECT id FROM IntegrationCase__c limit 1]; System.assertEquals(true, ic != null); Test.stopTest(); } }