高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
@isTest
public class NFM705RestTest {
    static testMethod void testMothodOne(){
        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":"20221215","SponsorshipCategory":"白给","ProcessState": null ,"OfficeCategory":"1.消化科","Num":"MT-HB-202112-5773","Name":null,"MeetingType":"主办会","MeetingApprovedNo":null,"IsPaidToSponsor":"Y","HostName":"黔西南州中医院","EndDate":"20221216","CooperatorCompany":"未来城","ConveningParticipantsNum":50,"CityMaster":"贵阳","BudgetType":"新产品上市"}]';
        //[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);
    }
 
    static testMethod void testMethodTwo() {
        BatchIF_Transfer__c transfer1 = new BatchIF_Transfer__c();
        transfer1.Table__c = 'Application_for_Conference_Adjudication__c';
        transfer1.Column__c = 'ProcessState__c';
        transfer1.External_Value__c = '110';
        transfer1.Internal_Value__c = '草稿';
        transfer1.Dropped_Flag__c = false;
        insert transfer1;
 
        BatchIF_Transfer__c transfer2 = new BatchIF_Transfer__c();
        transfer2.Table__c = 'Application_for_Conference_Adjudication__c';
        transfer2.Column__c = 'IsPaidToSponsor__c';
        transfer2.External_Value__c = 'Y';
        transfer2.Internal_Value__c = '是';
        transfer2.Dropped_Flag__c = false;
        insert transfer2;
 
        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":"20251215","SponsorshipCategory":"白给","ProcessState":110,"OfficeCategory":"1.消化科","Num":null,"Name":"Test会议","MeetingType":"主办会","MeetingApprovedNo":"TEST997931","IsPaidToSponsor":"Y","HostName":"黔西南州中医院","EndDate":"20251216","CooperatorCompany":"未来城","ConveningParticipantsNum":50,"CityMaster":"安顺","BudgetType":"新产品上市","ActivityTypeName":"嗯?乖乖站好?","ExpectedOlympusAttendance":50,"ExpectedHcpAttendance":100}]}';
        req.requestURI = 'services/apexrest/NFM705/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
 
        NFM705Rest.doPost();
 
        Test.stopTest();
        
    }
}