@isTest
|
private class ConsumTrialUpdateControllerTest {
|
// 已出库
|
@testSetup static void setupTestData(){
|
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);
|
}
|
|
}
|