高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/AgencyOpportunityHandlerTest.cls
@@ -43,7 +43,8 @@
        List<Account> acclist=[select RecordTypeId,Name 
                                from Account
                                ];
        //System.assertEquals('test1医院',acclist[0].Name);
        //System.assertEquals(9,acclist.size());
        
        account2.Name = 'test1经销商';
@@ -255,6 +256,8 @@
        insert new List<contact> {contact1,contact2,contact3};
        Test.startTest();
        User thisUser= [select Id from User where Id=:UserInfo.getUserId()];
        System.runAs (thisUser){
        // ユーザー
        //Profile p = [select Id from Profile where Name = '901_经销商周报'];
        Profile p = [select Id from Profile where Name = '901_经销商活动系统'];
@@ -328,7 +331,7 @@
        opp.StageName = '目標';
        //opp.AgencyOpp_FromOCM__c = true;
        opp.SAP_Send_OK__c = false;
        opp.CloseDate = Date.newInstance(2222, 7, 15);
        opp.CloseDate = Date.newInstance(2023, 7, 15);
        insert opp;
        opp.SAP_Send_OK__c = true;
@@ -349,7 +352,7 @@
        opp2.Name = 'test询价2';
        opp2.StageName = '目標2';
        opp2.SAP_Send_OK__c = false;
        opp2.CloseDate = Date.newInstance(2222, 7, 15);
        opp2.CloseDate = Date.newInstance(2023, 7, 15);
        opp2.SAP_Send_OK__c = true;
        
        // Test.startTest();
@@ -369,6 +372,7 @@
                FROM Agency_Opportunity__Share
                WHERE ParentId=:agency_opportunity.Id and RowCause <>:rowCause];
        System.assertEquals(user.Id, agencyopportunityShare[0].UserOrGroupId);
    }
    }
    // 经销商所有者テスト
@@ -407,7 +411,8 @@
        insert new List<contact> {contact1,contact2,contact3};
        //insert new List<contact> {contact1,contact2};
User thisUser= [select Id from User where Id=:UserInfo.getUserId()];
System.runAs (thisUser){
        // ユーザー
        //Profile p = [select Id from Profile where Name = '901_经销商周报'];
        Profile p = [select Id from Profile where Name = '901_经销商活动系统'];
@@ -481,7 +486,7 @@
        opp.StageName = '目標';
        //opp.AgencyOpp_FromOCM__c = true;
        opp.SAP_Send_OK__c = false;
        opp.CloseDate = Date.newInstance(2222, 7, 15);
        opp.CloseDate = Date.newInstance(2023, 7, 15);
        opp.OwnerId = user.Id;
        insert opp;
@@ -519,6 +524,7 @@
        System.assertEquals(userList[0].SalesManager__c, aoList[0].Sales_Manager_F__c);
        //System.assertEquals(aoList[0].Sales_Manager_F__c, aoList[0].Sales_Manager__c);
    }
    }
   // 普通所有者テスト
    @isTest
@@ -548,7 +554,8 @@
        contact3.FirstName = '責任者';
        contact3.LastName = 'test2经销商';
        insert new List<contact> {contact1,contact2,contact3};
User thisUser= [select Id from User where Id=:UserInfo.getUserId()];
System.runAs (thisUser){
        // ユーザー
        //Profile p = [select Id from Profile where Name = '901_经销商周报'];
        Profile p = [select Id from Profile where Name = '901_经销商活动系统'];
@@ -632,7 +639,7 @@
        opp.StageName = '目標';
        //opp.AgencyOpp_FromOCM__c = true;
        opp.SAP_Send_OK__c = false;
        opp.CloseDate = Date.newInstance(2222, 7, 15);
        opp.CloseDate = Date.newInstance(2023, 7, 15);
        opp.OwnerId = user3.Id;
        insert opp;
@@ -678,6 +685,7 @@
        System.assertEquals(userList[0].SalesManager__c, aoList[0].Sales_Manager_F__c);
        //System.assertEquals(aoList[0].Sales_Manager_F__c, aoList[0].Sales_Manager__c);
    }
    }
    public static void makeNormalData(boolean withAgencyDetail) {
        ControllerUtil.EscapeNFM001Trigger = true;