buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
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
@isTest
private class ProRegisterBatchTest {
    static testMethod void testMethod1() {
 
        Product_Register__c prorec = new Product_Register__c();
        prorec.Name = 'SFDCTEST2018001';
        prorec.MedPrdClass__c = '3';
        prorec.RegisterNoClass_New__c = '';
        prorec.RegisterNoClass_Old__c = '6822';
        prorec.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        prorec.ValidTo__c = Date.today().addDays(-1);
        prorec.ValidFrom__c = Date.today().addDays(-22);
        insert prorec;
        Product_Register__c prorec1 = new Product_Register__c();
        prorec1.Name = 'SFDCTEST2018002';
        prorec1.MedPrdClass__c = '3';
        prorec1.RegisterNoClass_New__c = '';
        prorec1.RegisterNoClass_Old__c = '6822';
        prorec1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        prorec1.ValidTo__c = Date.today().addDays(1);
        prorec1.ValidFrom__c = Date.today().addDays(-22);
        insert prorec1;
        List<Product_Register__c> prorecList = [select Id, Name, ValidProductRegister__c from Product_Register__c ];
        System.assertEquals(false, prorecList[0].ValidProductRegister__c);
 
        Product2 pro = new Product2();
        pro.Name = 'A00507A:密封圈,  透明, 黑色';
        pro.registrationCode__c  = 'SFDCTEST2018001 SFDCTEST2018002';
        insert pro;
 
        Product_Register_Link__c prl = new Product_Register_Link__c(Product_Register__c = prorec.ID);
        prl.Product2__c = pro.ID;
        insert prl;
 
        Product_Register_Link__c prl2 = new Product_Register_Link__c(Product_Register__c = prorec1.ID);
        prl2.Product2__c = pro.ID;
        insert prl2;
 
        Id execBTId = null;
        System.Test.StartTest();
        execBTId = Database.executeBatch(new ProRegisterBatch());
        List<Product2> productList = [select Id, registrationCode__c from Product2];
        System.assertEquals('SFDCTEST2018002', productList[0].registrationCode__c);
        execBTId = Database.executeBatch(new ProRegisterBatch('updateAllInvalidData'));
        productList = [select Id, registrationCode__c from Product2];
        System.assertEquals('SFDCTEST2018002', productList[0].registrationCode__c);
        String prorecId = prorec.ID;
        execBTId = Database.executeBatch(new ProRegisterBatch(prorecId));
        productList = [select Id, registrationCode__c from Product2];
        System.assertEquals('SFDCTEST2018002', productList[0].registrationCode__c);
        System.Test.StopTest();
 
    }
}