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
@isTest
private class DeleteSObjectBatchTest {
    static testMethod void testMethod1() {
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'HistoryPrd1';
        prd1.ProductCode            = 'HistoryPrd1';
        prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
        prd1.Name                   = 'HistoryPrd1';
        prd1.Manual_Entry__c        = false;
        prd1.Extend_new_product_gurantee__c = true;
        prd1.Extend_Gurantee_Start__c = Date.today().addDays(-60);
        prd1.Extend_Gurantee_End__c = Date.today().addDays(60);
        insert prd1;
 
        Id execBTId1 = Database.executeBatch(new DeleteSObjectBatch('Product2'), 100);
        // Id execBTId2 = Database.executeBatch(new DeleteSObjectBatch('Contact','LastName = \'lastName\''), 100);
        // DeleteSObjectBatch b = new DeleteSObjectBatch();
    }
    static testMethod void testMethod2() {
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'HistoryPrd1';
        prd1.ProductCode            = 'HistoryPrd1';
        prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
        prd1.Name                   = 'HistoryPrd1';
        prd1.Manual_Entry__c        = false;
        prd1.Extend_new_product_gurantee__c = true;
        prd1.Extend_Gurantee_Start__c = Date.today().addDays(-60);
        prd1.Extend_Gurantee_End__c = Date.today().addDays(60);
        insert prd1;
 
        Id execBTId1 = Database.executeBatch(new DeleteSObjectBatch('Product2','ProductCode = \'lastName\''), 100);
        // Id execBTId2 = Database.executeBatch(new DeleteSObjectBatch('Contact','LastName = \'lastName\''), 100);
        // DeleteSObjectBatch b = new DeleteSObjectBatch();
    }
}