Li Jun
2022-03-31 3ba0123db48f8bab81ddf0913e1b95280ef545e8
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
@IsTest
public with sharing class NFM502ControllerTest {
    public NFM502ControllerTest() {
 
    }
    @testSetup
    static void makeTestQLM502() {
        TestDataUtility.CreatePIPolicyConfiguration('NFM502');
        BatchIF_Transfer__c transfer1 = new BatchIF_Transfer__c();
        transfer1.Table__c          = 'QLMoldMark';
        transfer1.Internal_Value__c = '*';
        insert transfer1;
 
        List<BatchIF_Transfer__c> NFM501GainEndTimeTransfers = new List<BatchIF_Transfer__c>();
        BatchIF_Transfer__c transfer2 = new BatchIF_Transfer__c();
        transfer2.Table__c          = 'NFM501GainEndTime';
        transfer2.NFM501_Gain_End_Time__c = Datetime.now();
        NFM501GainEndTimeTransfers.add(transfer2);
        insert NFM501GainEndTimeTransfers;
 
        List<BatchIF_Transfer__c> NFM501TokenTransfers = new List<BatchIF_Transfer__c>();
        BatchIF_Transfer__c transfer3 = new BatchIF_Transfer__c();
        transfer3.Table__c          = 'NFM501Token';
        transfer3.NFM501_Token__c = null;//'eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiIwNzBmMDBiZi02NGYxLTQ3MjAtYThkOC1iYmUxYWE5NzZkMjIiLCJhcHBTZWNyZXQiOiI2N0JCMkJBRkM4QUEwQkEwQ0FCQjM3Q0JGNTBFQzI5MiIsImV4cCI6MTYyNDI2MTc1OX0.s55zh9SSpwqRdp1wXH43_wEGpwlZtMfRgl1x8t69A-N0H7QrzRNmK5MNqNGGLhQ2LL_AbMSJmDfwO5chgwndoA';
        NFM501TokenTransfers.add(transfer3);
        insert NFM501TokenTransfers;
 
        Tender_information__c Ten = new Tender_information__c();
        Ten.Name = '123456';
        Ten.InfoTitle__c = '123456';
        Ten.ProjectId__c = '38_99df2844cf784982acdc61d00d7a7dbb';
        insert Ten;
 
        BatchIF_Log__c rowData = new BatchIF_Log__c();
        rowData.Type__c = 'NFM501';
        rowData.RowDataFlg__c = true;
        rowData.Log__c = '{"code":"0","data":{"cursorMark":"60d01dde42ec7ed48d3730d6","list1":[{"agentRelationName":[],"agentRelationWay":[],"agentUnit":[],"areaCity":"惠州市","areaCountry":"","areaProvince":"广东省","biddingType":"0","bidingAcquireTime":"","bidingEndTime":"","budget":[{"amount":"250000.00","unit":"元"}],"infoFile":["http://cusdata.qianlima.com/vip/info/download/V2/eyJhbGciOiJIUzI1NiJ9.eyJpbmZvSWQiOiIyMjczMjgxOTAiLCJhcHBLZXkiOiIwNzBmMDBiZi02NGYxLTQ3MjAtYThkOC1iYmUxYWE5NzZkMjIiLCJhcHBTZWNyZXQiOiI2N0JCMkJBRkM4QUEwQkEwQ0FCQjM3Q0JGNTBFQzI5MiIsImZpbGVVcmwiOiI0QjY2Mzg2MzY4MzI0MTQyNzY2MjU5NEI0QTc0NEM1NzcxNkI2RjcyNkI1MTNEM0QifQ.3UTAGOde4plSKFKf_DV1sBWXJbdsz7zN8a1KZZys6bo"],"infoId":"227328190","infoPublishTime":"2021-06-21 09:41:26","infoQianlimaUrl":"http://www.qianlima.com/zb/detail/20210621_227328190.html","infoTitle":"皮肤镜图像处理工作站调研公告","infoType":"0","infoTypeSegment":"3","isElectronic":"0","keywords":"图像处理","openBidingTime":"","projectId":"38_99df2844cf784982acdc61d00d7a7dbb","target":null,"tenderBeginTime":"","tenderEndTime":"","winnerAmount":[],"xmNumber":"CD-1624266167710","zhaoBiaoUnit":["惠州市第一人民医院"],"zhaoRelationName":["范梅红"],"zhaoRelationWay":["0752-2883625"],"zhongBiaoUnit":[],"zhongRelationName":[],"zhongRelationWay":[]}]},"msg":"正确返回数据"}';
        rowData.MessageGroupNumber__c = transfer1.Internal_Value__c;
        insert rowData;
 
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = 'NFM501';
        iflog.RowDataFlg__c = false;
        iflog.Log__c = ' ';
        iflog.ErrorLog__c = ' ';
        iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c;
        insert iflog;
 
        List<Attachment> WebAttList = new List<Attachment>();
        Attachment WebAtt = new Attachment();
        WebAtt.ParentId = Ten.Id;
        WebAtt.Body = Blob.valueOf('123456789');
        WebAtt.Name = '1234567.html';
        WebAttList.add(WebAtt);
        insert WebAttList;
    }
 
    @IsTest
    static void Test502() {
        BatchIF_Log__c rowData = [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,
                                  NFM501Future_Count__c,
                                  NFM501_Web_Annex_Count__c from BatchIF_Log__c
                                  where RowDataFlg__c = true];
        BatchIF_Log__c iflog = [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,
                                NFM501Future_Count__c,
                                NFM501_Web_Annex_Count__c from BatchIF_Log__c Limit 1];
 
 
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new NFM501HttpCallMock());
        NFM502Controller.WebAnnexGain(rowData.Id, iflog.Id, false);
        Test.stopTest();
    }
    // 报错
    @IsTest
    static void myTest1() {
        BatchIF_Log__c rowData = [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,
                                  NFM501Future_Count__c,
                                  NFM501_Web_Annex_Count__c from BatchIF_Log__c
                                  where RowDataFlg__c = true];
        BatchIF_Log__c iflog = [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,
                                NFM501Future_Count__c,
                                NFM501_Web_Annex_Count__c from BatchIF_Log__c Limit 1];
        // List<Tender_information__c> TIList =
        //     [Select Id, ProjectId__c, InfoType__c
        //      FROM Tender_information__c];
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new NFM501HttpCallMockEx());
        NFM502Controller.WebAnnexGain(rowData.Id, iflog.Id, false);
        NFM502Controller.test();
        Test.stopTest();
    }
 
}