@isTest
|
private class CPL003RestTest {
|
|
@isTest
|
static void testlog00(){
|
|
// 产品
|
Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP',
|
Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
|
Fixture_Model_No_T__c = 'n05',
|
ProductCode_Ext__c='pc05',Manual_Entry__c=false,
|
ProductCode = 'pc0522');
|
insert pro5;
|
CPL003Rest.GeDatas GeDatas = new CPL003Rest.GeDatas();
|
CPL003Rest.GeData GeData = new CPL003Rest.GeData();
|
GeDatas.Inventory = new CPL003Rest.GeData[]{GeData};
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
|
|
GeData.MaterialNumber = 'pc0522';
|
GeData.ItemQuantity = '33';
|
GeData.Area = null;
|
|
System.Test.startTest();
|
NFMUtil.Monitoring Monitoring = GeDatas.Monitoring;
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'CPL003', GeDatas.Inventory);
|
CPL003Rest.executefuture(rowData.Id);
|
GeData.MaterialNumber = '';
|
rowData = NFMUtil.saveRowData(Monitoring, 'CPL003', GeDatas.Inventory);
|
CPL003Rest.executefuture(rowData.Id);
|
|
GeData.MaterialNumber = 'pc1222';
|
rowData = NFMUtil.saveRowData(Monitoring, 'CPL003', GeDatas.Inventory);
|
CPL003Rest.executefuture(rowData.Id);
|
|
GeData.MaterialNumber = 'pc0522';
|
GeData.ItemQuantity = 'pc1222';
|
rowData = NFMUtil.saveRowData(Monitoring, 'CPL003', GeDatas.Inventory);
|
CPL003Rest.executefuture(rowData.Id);
|
System.Test.stopTest();
|
}
|
|
@isTest
|
static void test_method_two() {
|
|
Test.startTest();
|
|
RestRequest req = new RestRequest();
|
RestResponse res = new RestResponse();
|
|
String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"201812201320","Text":"","Tag":"MSGH","Sender":"SFDC","Receiver":"SPO","NumberOfRecord":"1","MessageType":"CPL003","MessageGroupNumber":"20180001722190"},"Inventory":[{"MaterialNumber":"4802930","ItemQuantity":"5 ","Area":null}]}';
|
req.requestURI = 'services/apexrest/CPL003/execute';
|
req.httpMethod = 'POST';
|
req.requestBody = Blob.valueof(JsonMsg);
|
RestContext.request = req;
|
RestContext.response= res;
|
|
CPL003Rest.execute();
|
|
Test.stopTest();
|
//Test.setMock(HttpCalloutMock.class, new NFM205RestCalloutMock());
|
//NFM205Rest.execute1('{"Monitoring":{"TransmissionDateTime":"201812201320","Text":"","Tag":"MSGH","Sender":"SFDC","Receiver":"SPO","NumberOfRecord":"1","MessageType":"NFM205","MessageGroupNumber":"20180001722190"},"GeData":[{"Opportunity_Code":"HKBJ-GI-BJ0588881","Bidding_No":"as123121","Bidding_Content":"招标内容","Bid_Project_Name":"招标项目名","Bid_Date":"20181203","Authorized_Status":"1","Authorized_Finish_Sales":"30033","Authorized_DB_No":"MGZWESQHN201812001","Authorized_Date":"20190316","Autholization_Activated_Date":"20190415"}]}');
|
}
|
}
|