liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@isTest
public class NFM705RestTest {
    
    static testMethod void testMothodOne(){
        BatchIF_Transfer__c temp1 = new BatchIF_Transfer__c();
        BatchIF_Transfer__c temp2 = new BatchIF_Transfer__c();
        temp1.Table__c = 'Application_for_Conference_Adjudication__c';
        temp1.Column__c = 'ProcessState__c';
        temp1.External_Value__c = '110';
        temp1.Internal_Value__c = '草稿';
        insert temp1;
        temp2.Table__c = 'Application_for_Conference_Adjudication__c';
        temp2.Column__c = 'ProcessState__c';
        temp2.External_Value__c = '120';
        temp2.Internal_Value__c = '审批中';
        insert temp2;
        BatchIF_Log__c testLog = new BatchIF_Log__c();
        testLog.CurrencyIsoCode = 'CNY';
        testLog.Type__c = 'NFM705';
        testLog.MessageGroupNumber__c = '123456789987';
        // testLog.Name = '20211207';
        testLog.ErrorLog__c = '';
        testLog.MessageGroupNumber__c = '20211207';
        testLog.RowDataFlg__c = true;
        testLog.Log__c = '[{"WorkshopPlace":"河北","StateMaster":"河北省","StartDate":"2022-03-25T00:00:00","SponsorshipCategory":"","SharedEditing":"","ProcessState":110,"OfficeCategory":"","Num":"MT-GI-202203-5850","Name":"TEST说明会 (2022/01/13 - 2022/03/24) v1","MeetingType":"线上+线下","MeetingApprovedNo":"ME154P03-0007","IsPaidToSponsor":"否","IsCoOrganizingActivities":"Y","HostName":"1","ExpectedOlympusAttendance":10,"ExpectedHcpAttendance":111,"EndDate":"2022-03-30T00:00:00","CooperatorCompany":"2","ConveningParticipantsNum":121,"CityMaster":"石家庄市","BudgetType":"其他","Applicant":"om001646","ActivityTypeName":"自主主办活动"}]';
        //[Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]
        insert testLog;
        NFM705Rest.main(testLog.Id);
        testLog.Log__c = '[{"WorkshopPlace":"河北","StateMaster":"河北省","StartDate":"2022-03-25T00:00:00","SponsorshipCategory":"","SharedEditing":"","ProcessState":120,"OfficeCategory":"","Num":"MT-GI-202203-5850","Name":"TEST说明会 (2022/01/13 - 2022/03/24) v1","MeetingType":"线上+线下","MeetingApprovedNo":"ME154P03-0007","IsPaidToSponsor":"否","IsCoOrganizingActivities":"Y","HostName":"1","ExpectedOlympusAttendance":10,"ExpectedHcpAttendance":111,"EndDate":"2022-03-30T00:00:00","CooperatorCompany":"2","ConveningParticipantsNum":121,"CityMaster":"石家庄市","BudgetType":"其他","Applicant":"om001646","ActivityTypeName":"自主主办活动"}]';
        update testLog;
        NFM705Rest.main(testLog.Id);
        //controller.ReservedProductVerification();
        // string[] azzz = new String[]{'1','2'};
        // system.debug(azzz[3]);
    }
 
    static testMethod void testMethodTwo() {
        BatchIF_Transfer__c temp1 = new BatchIF_Transfer__c();
        BatchIF_Transfer__c temp2 = new BatchIF_Transfer__c();
        temp1.Table__c = 'Application_for_Conference_Adjudication__c';
        temp1.Column__c = 'ProcessState__c';
        temp1.External_Value__c = '110';
        temp1.Internal_Value__c = '草稿';
        insert temp1;
        temp2.Table__c = 'Application_for_Conference_Adjudication__c';
        temp2.Column__c = 'ProcessState__c';
        temp2.External_Value__c = '120';
        temp2.Internal_Value__c = '审批中';
        insert temp2;
 
        List<RecordType> rectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'Society'];
        System.runAs(new User(Id = Userinfo.getUserId())) {
            User user = new User(Test_staff__c = true);
            user.LastName = '_サンブリッジ';
            user.FirstName = 'う';
            user.Alias = 'う';
            user.Email = 'olympusTest03@sunbridge.com';
            user.Username = 'olympusTest03@sunbridge.com';
            user.IsActive = true;
            user.EmailEncodingKey = 'ISO-2022-JP';
            user.TimeZoneSidKey = 'Asia/Tokyo';
            user.LocaleSidKey = 'ja_JP';
            user.LanguageLocaleKey = 'ja';
            user.ProfileId = System.Label.ProfileId_SystemAdmin;
            user.Province__c = '北京';
            user.Dept__c = '医疗华北营业本部';
            user.Use_Start_Date__c = Date.today().addMonths(-6);
            insert user;
 
            Campaign cam = new Campaign();
            cam.Name = 'test campaign';
            cam.StartDate = Date.today().addDays(15);
            cam.EndDate = Date.today().addDays(18);
            cam.Name2__c = '1234';
            cam.Status = '申请中';
            cam.Mailflg_after45__c = true;
            cam.Mailflg_cancel__c = true;
            cam.Mailflg_before15__c = true;
            cam.Mailflg_before7__c = true;
            cam.Mailflg_after3__c = true;
            cam.HostName__c = '1';
            cam.cooperatorCompany__c = '1';
            cam.RecordTypeId = rectCo[0].Id;
            cam.OwnerId = user.Id;
            cam.Num__c = 'MT-XN-202203-5854';
            insert cam;
            system.debug('cam.Num__c'+cam.Num__c);
 
            //20221208 lt DB202212060256 start 
            Campaign cam1 = new Campaign();
            cam1.Name = 'test campaign';
            cam1.StartDate = Date.today().addDays(18);
            cam1.EndDate = Date.today().addDays(20);
            cam1.Name2__c = '1234';
            cam1.Status = '申请中';
            cam1.Meeting_Type__c = '共同主办会';
            cam1.Mailflg_after45__c = true;
            cam1.Mailflg_cancel__c = true;
            cam1.Mailflg_before15__c = true;
            cam1.Mailflg_before7__c = true;
            cam1.Mailflg_after3__c = true;
            cam1.HostName__c = '1';
            cam1.cooperatorCompany__c = '1';
            cam1.RecordTypeId = rectCo[0].Id;
            cam1.OwnerId = user.Id;
            cam1.Num__c = 'MT-GI-202203-5850';
            insert cam1;
            system.debug('lt123cam.Num__c---'+cam.Num__c);
 
            cam1.StartDate = Date.today().addDays(28);
            cam1.EndDate = Date.today().addDays(30);
            update cam1;
            //20221208 lt DB202212060256 end 
        }
        
        Test.startTest();
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
 
        String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"202107131529","Text":null,"Tag":null,"Sender":"OBPM","Receiver":"SFDC","NumberOfRecord":"2","MessageType":"NFM705","MessageGroupNumber":null},"GeData":[{"WorkshopPlace":"云南","StateMaster":"云南省","StartDate":"2022-12-28T00:00:00","SponsorshipCategory":"","SharedEditing":"on000695,on000630,om002080","ProcessState":120,"OfficeCategory":"GI(MEBG),ET(MEBG),","Num":"MT-GI-202203-5850","Name":"测试会议-001 (2022/03/28 - 2022/03/31)关联OBPM ","MeetingType":"线下","MeetingApprovedNo":"ME154P03-0009","IsPaidToSponsor":"否","IsCoOrganizingActivities":"N","HostName":"奥林巴斯","ExpectedOlympusAttendance":2,"ExpectedHcpAttendance":100,"EndDate":"2023-01-09T00:00:00","CooperatorCompany":"无","ConveningParticipantsNum":102,"CityMaster":"昆明市","BudgetType":"产品推广","Applicant":"om001646","ActivityTypeName":"自主主办活动"}]}';
        req.requestURI = 'services/apexrest/NFM705/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
 
        NFM705Rest.doPost();
 
        Test.stopTest();
    }
}