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
55
@isTest
private class NewRepairPartsControllerTest {
    
    static testMethod void testMethod1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        List<RecordType> rectOpp = [select Id from RecordType where IsActive = true and SobjectType = 'Opportunity' and Name = 'SSBD'];
        Id pricebookId = Test.getStandardPricebookId();
        
        Pricebook2 pricebook = new Pricebook2(
            Name = 'IE',
            ProductSegment__c = 'IE',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            MachineParts__c = 'Machine',
            CurrencyIsoCode = 'CNY'
        );
        insert pricebook;
        
        Product2 product1 = new Product2();
        product1.Name = 'product1';
        product1.IsActive = true;
        product1.ProductCode = 'product1';
        product1.ProductStatus__c = '1';
        product1.NMPAStatus_one__c = 'Z1';
        product1.MaterialStatus_one_Start__c = Date.today().addDays(-22);
        product1.MaterialStatus_one_End__c = Date.today().addDays(22);
 
        insert product1;
 
        SWO__c swo = new SWO__c();
        swo.Name = 'Test';
        insert swo;
 
        PageReference page = new PageReference('/apex/NewRepairParts?swoId=' + swo.Id + '&id=');
        System.Test.setCurrentPage(page);
        NewRepairPartsController controller = new NewRepairPartsController();
        controller.init();
        controller.repairPart.Product__c = product1.Id;
        controller.repairPart.QUANTITY__c = 1;
        controller.repairPart.LOCATION__c = 'Beijing';
        controller.deleteAction();
        controller.save();
 
        RepairPart__c repairPart = new RepairPart__c();
        repairPart.SWO_ID__c = swo.Id;
        insert repairPart;
 
        PageReference page1 = new PageReference('apex/NewRepairParts?swoId='+swo.Id+'&id='+repairPart.Id);
        System.Test.setCurrentPage(page1);
        NewRepairPartsController controller1 = new NewRepairPartsController();
        controller1.init();
        controller1.deleteAction();
        controller1.mastData();
    }
}