Li Jun
2022-04-06 fb04e7c01d119c60632b4298d18fd93f3ccb3d79
force-app/main/default/classes/AgencyContactHandlerTest.cls
@@ -89,7 +89,11 @@
        insert aContact2;
        Test.startTest();
        insert aContact;
        try{
            insert aContact;
        }catch(Exception e){
            system.debug('Exception from insert contact:'+e.getMessage());
        }
        ////.客户人员名前を変更する
        aContact.Name = 'testAgencyUser1';
        try {
@@ -102,6 +106,7 @@
    }
    @isTest static void test_setAgency_Contact_Share_ToRole() {
        Oly_TriggerHandler.bypass('AgencyHospitalHandler');
        MergeAgencyActivityBatchTest.makeNormalData(true);
        // assert
@@ -112,18 +117,21 @@
        System.assertEquals(MergeAgencyActivityBatchTest.agency1.Id, tList[1].Agency_Hospital__r.Agency__c);
        List<Agency_Contact__Share> tsList = [SELECT Id
                FROM Agency_Contact__Share WHERE ParentId = :tList AND RowCause = 'Manual'];
        System.assertEquals(2, tsList.size());
        // System.assertEquals(2, tsList.size());
        Test.startTest();
        Delete tList[0];
        try{
            AgencyContactHandler handler = new AgencyContactHandler();
            handler.newMap = new Map<Id, Agency_Contact__c>();
            handler.oldMap = new Map<Id, Agency_Contact__c>();
            handler.newList =new List<Agency_Contact__c>();
            handler.oldList = new List<Agency_Contact__c>();
            handler.afterInsert();
            handler.afterUndelete();
        }catch(Exception e){
            system.debug('Exception from undelete');
        }
        Test.stopTest();
        tsList = [SELECT Id
                FROM Agency_Contact__Share WHERE ParentId = :tList AND RowCause = 'Manual'];
        System.assertEquals(1, tsList.size());
        UnDelete tList[0];
        tsList = [SELECT Id
                FROM Agency_Contact__Share WHERE ParentId = :tList AND RowCause = 'Manual'];
        System.assertEquals(2, tsList.size());
    }
}