GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
133
134
135
136
137
138
139
140
141
@isTest
private class LogAutoSendBatchProductTest {
     static Product2 testSBG004Init() {
        // テストデータ
        Product2 prd = new Product2();
        prd.Product_ECCode__c     = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        insert prd;  
        //Pricebook2 prdbook     = new Pricebook2();
 
        Pricebook2 prdbook1 = new Pricebook2( 
            Name = 'testSBG004',
            ProductSegment__c  = 'BS',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'dealer',
            MachineParts__c = 'Machine',
            isActive = true);
 
        insert prdbook1;
        Pricebook2 prdbook2 = new Pricebook2( 
            Name = 'testSBG004',
            ProductSegment__c  = 'BS',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            MachineParts__c = 'Machine',
            isActive = true);
 
        insert prdbook2;
 
        PricebookEntry pbe = new PricebookEntry();
        pbe.Pricebook2Id = ControllerUtil.getStandardPricebook().Id;
        pbe.Product2Id      = prd.Id;
        pbe.UnitPrice       = 0;
        pbe.CurrencyIsoCode = 'CNY';
        pbe.IsActive        = true;
        insert pbe;
        PricebookEntry pbe1 = new PricebookEntry();
        pbe1.Pricebook2Id = ControllerUtil.getStandardPricebook().Id;
        pbe1.Product2Id      = prd.Id;
        pbe1.UnitPrice       = 0;
        pbe1.CurrencyIsoCode = 'USD';
        pbe1.IsActive        = true;
        insert pbe1;
 
        return prd;
        
    }
    @isTest 
    static void test_LogAutoSendBatchProduct_SBG004() {
        testSBG004Init();
 
        SBG004Rest.GeData GeData = new SBG004Rest.GeData();
        SBG004Rest.GeDatas GeDatas = new SBG004Rest.GeDatas();
        GeDatas.GeData = new SBG004Rest.GeData[] { GeData };
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        GeDatas.Monitoring = new NFMUtil.Monitoring();
        GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
        GeDatas.Monitoring.MessageGroupNumber = nowStr + '02';
        GeData.ProductCode  = 'testSBG004X';
        BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG004', GeDatas.GeData);
        //System.Test.startTest();
        SBG004Rest.main(rowData.Id);
        
        //SBGITMRest.main(rowData.Id);
        BatchIF_Log__c[] logs =[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
                                from BatchIF_Log__c
                                where RowDataFlg__c = true
                                and Type__c = 'SBG004'
                                order by CreatedDate desc ];
 
        logs[0].retry_cnt__c=1;
        update logs;
        Id execBTId = Database.executeBatch(new LogAutoSendBatchProduct(), 1);
        //System.Test.stopTest();
    }
    @isTest 
    static void test_LogAutoSendBatchProduct_SBG005() {
        testSBG004Init();
 
        SBG005Rest.GeData GeData = new SBG005Rest.GeData();
        SBG005Rest.GeDatas GeDatas = new SBG005Rest.GeDatas();
        GeDatas.GeData = new SBG005Rest.GeData[] { GeData };
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        GeDatas.Monitoring = new NFMUtil.Monitoring();
        GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
        GeDatas.Monitoring.MessageGroupNumber = nowStr + '02';
        GeData.ProductCode  = 'testSBG005X';
         BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG005', GeDatas.GeData);
        //System.Test.startTest();
        SBG005Rest.main(rowData.Id);
        
        BatchIF_Log__c[] logs =[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
                        from BatchIF_Log__c
                        where RowDataFlg__c = true
                        and Type__c = 'SBG005'
                        order by CreatedDate desc ];
 
        logs[0].retry_cnt__c=1;
        update logs;
        Id execBTId = Database.executeBatch(new LogAutoSendBatchProduct(), 1);
        //System.Test.stopTest();
    }
}