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
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
142
@isTest
private class ConsumTrialUpdateControllerTest {
    // 已出库
    @testSetup static void setupTestData(){
        TestDataUtility.CreatePIPolicyConfiguration('Consum_Apply_Equipment_Set_Detail__c');
        ConsumTestDataFactory factory = new ConsumTestDataFactory();
        factory.eachStepUpdate = false;
        factory.setupTestData();
        factory.selectDetails();
        factory.approve();
        factory.defaultAssign();
        factory.shippmentRequest();
        factory.shipment();
        factory.updateData();
    }
    // 收货OK
    static testMethod void testOK() {
        Consum_Apply__c ca = null ;
        List<Consum_Apply_Equipment_Set_Detail__c> caesdList = null;
        ca = [SELECT Id FROM Consum_Apply__c LIMIT 1];
        caesdList = [SELECT Received_Confirm__c FROM Consum_Apply_Equipment_Set_Detail__c];
        System.assertEquals(null, caesdList[0].Received_Confirm__c);
 
        PageReference ref = new PageReference('/apex/ConsumTrialUpdate');
        ref.getParameters().put('parId', ca.Id);
        ref.getParameters().put('canedit', 'true');
 
        Test.setCurrentPage(ref);
        ConsumTrialUpdateController controller = new ConsumTrialUpdateController();
        controller.init();
        Test.startTest();
        controller.changeFixModel();
        controller.pageB.rowBList[0].rnd.Received_Confirm__c = 'OK';
        controller.pageB.rowBList[0].checked = true;
        controller.saveRecord();
        Test.stopTest();
 
        caesdList = [SELECT Received_Confirm__c FROM Consum_Apply_Equipment_Set_Detail__c];
        System.assertEquals('OK', caesdList[0].Received_Confirm__c);
    }
    // 收货NG
    static testMethod void testNG() {
        Consum_Apply__c ca = null ;
        List<Consum_Apply_Equipment_Set_Detail__c> caesdList = null;
        ca = [SELECT Id FROM Consum_Apply__c LIMIT 1];
        caesdList = [SELECT Received_Confirm__c, Picture1__c FROM Consum_Apply_Equipment_Set_Detail__c];
        System.assertEquals(null, caesdList[0].Received_Confirm__c);
        caesdList[0].Picture1__c = 'p1';
        update caesdList;
 
        PageReference ref = new PageReference('/apex/ConsumTrialUpdate');
        ref.getParameters().put('parId', ca.Id);
        ref.getParameters().put('canedit', 'true');
 
        Test.setCurrentPage(ref);
        ConsumTrialUpdateController controller = new ConsumTrialUpdateController();
        controller.init();
        Test.startTest();
        controller.changeFixModel();
        controller.pageB.rowBList[0].rnd.Received_Confirm__c = 'NG';
        controller.pageB.rowBList[0].rnd.Received_NG_Content__c = 'ng1';
        controller.pageB.rowBList[0].checked = true;
        controller.saveRecord();
        Test.stopTest();
 
        caesdList = [SELECT Received_Confirm__c, Received_NG_Content__c FROM Consum_Apply_Equipment_Set_Detail__c];
        System.assertEquals('NG', caesdList[0].Received_Confirm__c);
        System.assertEquals('ng1', caesdList[0].Received_NG_Content__c );
    }
    // 收货NG+备品中心确认OK
    static testMethod void testNGAndOK() {
        Consum_Apply__c ca = null ;
        List<Consum_Apply_Equipment_Set_Detail__c> caesdList = null;
        ca = [SELECT Id FROM Consum_Apply__c LIMIT 1];
        caesdList = [SELECT Received_Confirm__c, Picture1__c FROM Consum_Apply_Equipment_Set_Detail__c];
        caesdList[0].Picture1__c = 'p1';
        caesdList[0].Received_Confirm__c = 'NG';
        caesdList[0].Received_NG_Content__c = 'ng1';
        update caesdList;
 
        PageReference ref = new PageReference('/apex/ConsumTrialUpdate');
        ref.getParameters().put('parId', ca.Id);
        ref.getParameters().put('canedit', 'true');
 
        Test.setCurrentPage(ref);
        ConsumTrialUpdateController controller = new ConsumTrialUpdateController();
        controller.init();
        Test.startTest();
        controller.changeFixModel();
        controller.pageB.rowBList[0].checked = true;
        controller.pageB.rowBList[0].rnd.Asset_Center_Confirm__c = 'OK';
        controller.saveRecord();
        Test.stopTest();
 
        caesdList = [SELECT Received_Confirm__c
                          , Received_NG_Content__c
                          , Asset_Center_Confirm__c
                          //, Check_lost_Item_Final__c
                       FROM Consum_Apply_Equipment_Set_Detail__c];
        System.assertEquals('NG', caesdList[0].Received_Confirm__c);
        System.assertEquals('ng1', caesdList[0].Received_NG_Content__c);
        System.assertEquals('OK', caesdList[0].Asset_Center_Confirm__c);
        //System.assertEquals('消耗', caesdList[0].Check_lost_Item_Final__c);
    }
 
    // 收货NG+备品中心确认NG
    static testMethod void testNGAndNG() {
        Consum_Apply__c ca = null ;
        List<Consum_Apply_Equipment_Set_Detail__c> caesdList = null;
        ca = [SELECT Id FROM Consum_Apply__c LIMIT 1];
        caesdList = [SELECT Received_Confirm__c, Picture1__c FROM Consum_Apply_Equipment_Set_Detail__c];
        caesdList[0].Picture1__c = 'p1';
        caesdList[0].Received_Confirm__c = 'NG';
        caesdList[0].Received_NG_Content__c = 'ng1';
        update caesdList;
 
        PageReference ref = new PageReference('/apex/ConsumTrialUpdate');
        ref.getParameters().put('parId', ca.Id);
        ref.getParameters().put('canedit', 'true');
 
        Test.setCurrentPage(ref);
        ConsumTrialUpdateController controller = new ConsumTrialUpdateController();
        controller.init();
        Test.startTest();
        controller.changeFixModel();
        controller.pageB.rowBList[0].checked = true;
        controller.pageB.rowBList[0].rnd.Asset_Center_Confirm__c = 'NG';
        controller.saveRecord();
        Test.stopTest();
 
        caesdList = [SELECT Received_Confirm__c
                          , Received_NG_Content__c
                          , Asset_Center_Confirm__c
                          //, Check_lost_Item_Final__c
                       FROM Consum_Apply_Equipment_Set_Detail__c];
        System.assertEquals('NG', caesdList[0].Received_Confirm__c);
        System.assertEquals('ng1', caesdList[0].Received_NG_Content__c);
        System.assertEquals('NG', caesdList[0].Asset_Center_Confirm__c);
        //System.assertEquals(null, caesdList[0].Check_lost_Item_Final__c);
    }
 
}