@isTest private class ReceivingNoteSummaryHandlerTest { static ReceivingNoteTestDataFactory factory; /** @description 安装master数据 */ @testSetup static void setupMasterData(){ factory = new ReceivingNoteTestDataFactory(); factory.setupMasterData(); } /** @param typeStringListString 格式:'备品类型,管理种类;备品类型,管理种类...' @description 造出指定类型的清单数据,并插入数据库 */ static void setupTestData(String typeStringListString){ factory = new ReceivingNoteTestDataFactory(); if(String.isBlank(typeStringListString)){ typeStringListString = '固定资产,个体管理;附属品,个体管理;附属品,数量管理;耗材,数量管理;低值易耗品,数量管理'; } List typeStringList = typeStringListString.split(';'); factory.setupReceivingNoteData(typeStringList); } // 以收货清单为单位发清点NG邮件,此处不需要 //static testMethod void unitTestSendEmail() { // setupTestData('固定资产,个体管理'); // ReceivingNoteSummary__c rns = factory.rnsMap.get('固定资产,个体管理'); // ReceivingNoteDetail__c mainRnd = factory.rndMap.get('固定资产,个体管理'); // ReceivingNoteSummary__c oldRns = [SELECT Wei_Acceptance_Cnt__c, Acceptance_NG_Email__c FROM ReceivingNoteSummary__c WHERE Id =: rns.Id]; // System.assertEquals(null, oldRns.Acceptance_NG_Email__c); // System.assertEquals(1, oldRns.Wei_Acceptance_Cnt__c ); // mainRnd.AcceptanceResult__c = 'NG'; // mainRnd.AcceptanceTime__c = System.Now(); // update mainRnd; // ReceivingNoteSummary__c newRns = [SELECT Wei_Acceptance_Cnt__c,Acceptance_NG_Email__c FROM ReceivingNoteSummary__c WHERE Id =: rns.Id]; // ReceivingNoteDetail__c rnd = [Select Name, AcceptanceResult__c, Change_Point__c from ReceivingNoteDetail__c]; // String message = rnd.Name + ': ' + rnd.AcceptanceResult__c + ' ' + rnd.Change_Point__c; // System.assertEquals(0, newRns.Wei_Acceptance_Cnt__c); // System.assertEquals(message, newRns.Acceptance_NG_Email__c); //} //add by rentx 20210726 start 154P课题_SAP传输至SFDC后推送 static testMethod void testMethod1() { //创建收货清单 Date td = Date.today(); ReceivingNote__c rn = new ReceivingNote__c(); rn.Internal_asset_location__c = '上海 张江'; rn.Asset_loaner_category__c = '固定资产'; rn.Name = 'ZZ-153PA-0000813'; rn.Status__c = '待数据确认'; rn.DateOfDelivery__c = td+7; rn.OrderCode__c = 'SHRC-SP-20044-02'; rn.Sales_order_number__c = '1000109900'; rn.ApprovalNumber__c = 'ME153P07-0301'; rn.ContactPerson__c = 'username'; insert rn; // 备品配套(只有附属品) Fixture_Set__c fsObjC1 = new Fixture_Set__c(); fsObjC1.Name = 'setC1'; fsObjC1.Fixture_Set_Body_Model_No__c = 'modelNoC1'; fsObjC1.Loaner_name__c = 'nameC1'; insert fsObjC1; //收货清单一览 ReceivingNoteSummary__c rns = new ReceivingNoteSummary__c(); rns.ReceivingNote__c = rn.Id; rns.Fixture_Set__c = fsObjC1.Id; insert rns; // 收货一览明细 ReceivingNoteDetail__c rnd1 = new ReceivingNoteDetail__c(); rnd1.ReceivingNoteSummary__c = rns.Id; rnd1.Is_Body__c = true; rnd1.SerialNumber__c = '12'; insert new ReceivingNoteDetail__c[] {rnd1}; Fixture_Set__c fsObjC2 = new Fixture_Set__c(); fsObjC2.Name = 'setC2'; fsObjC2.Fixture_Set_Body_Model_No__c = 'modelNoC2'; fsObjC2.Loaner_name__c = 'nameC2'; insert fsObjC2; rns.Fixture_Set__c = fsObjC2.Id; rns.First_RND__c = rnd1.Id; update rns; } //add by rentx 20210726 end 154P课题_SAP传输至SFDC后推送 }