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
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
@isTest
private class SyncLostOppLineItemBatchTest {
 
    public static String CurrencyIso = 'CNY';
    private static Pricebook2 pricebook = null;
    private static Product2 product = null;
 
    @isTest
    static void TestMethod01() {
 
        product = new Product2( Name = 'テスト商品');
        pricebook = ControllerUtil.getStandardPricebook();
 
        //询价
        Opportunity opp = new Opportunity();
        opp.Name='opp1';
        opp.StageName='oppName';
        opp.CloseDate=Date.today();
        insert opp;
 
        //招标项目
        Tender_information__c ten = new Tender_information__c();
        ten.Name = 'QLMTEST08111057-02';
        insert ten;
 
        //招标-询价关系
        Tender_Opportunity_Link__c tol = new Tender_Opportunity_Link__c();
        tol.Opportunity__c = opp.Id;
        tol.CurrencyIsoCode = 'CNY';
        tol.Tender_information__c = ten.Id;
        StaticParameter.EscapeTOLinkTrigger = true;
        insert tol;
        StaticParameter.EscapeTOLinkTrigger = false;
 
        //产品
        Product2 pro = new Product2();
        pro.Name = 'test20240228';
        pro.ProductClass__c = '主机';
        pro.ProductCategory__c = 'CV主机';
        pro.IsActive=true;
        pro.ProductCode = 'TST1000001'; 
        pro.Asset_Model_No__c = 'TST1000001';
        insert pro;
 
        //价格手册
        PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = pro.Id);
        pE.UnitPrice = 0;
        pE.IsActive = true;
        pE.UseStandardPrice = false;
        pE.CurrencyIsoCode = CurrencyIso;
        insert pE;
 
        //询价行项目
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.Quantity = 1;
        oli.UnitPrice = 0;
        oli.PricebookEntryId = pE.Id;
        oli.OpportunityId = opp.id;
        insert oli;
 
        List<Product2> proList = new List<Product2>();
        proList.add(pro);
 
        Test.startTest();
        Database.executeBatch (new SyncLostOppLineItemBatch(proList),200);
        Test.stopTest();
    }
}