@isTest private class eSignAgencyPageControllerTest { static testMethod void testMethod1() { List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectCo.size() == 0) { return; } List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科']; if (rectSct.size() == 0) { return; } List rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc]; if (rectDpt.size() == 0) { return; } List rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品']; if (rectAs.size() == 0) { return; } // insert hospital Account company1 = new Account(); company1.RecordTypeId = rectCo[0].Id; company1.Name = '病院テスト1'; company1.OCM_man_province_txt__c = '江西'; List hps = new Account[]{company1}; insert hps; List dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = company1.Id; depart1.OCM_man_province_txt__c = '江西'; insert new Account[] {depart1}; List prdList = new List(); Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'HistoryPrd1'; prd1.ProductCode = 'HistoryPrd1'; prd1.Repair_Product_Code__c = 'HistoryPrd1_RP'; prd1.Name = 'HistoryPrd1'; prd1.Manual_Entry__c = false; prd1.Extend_new_product_gurantee__c = true; prd1.Extend_Gurantee_Start__c = Date.today().addDays(-60); prd1.Extend_Gurantee_End__c = Date.today().addDays(60); prdList.add(prd1); insert prdList; Asset ast = new Asset(); ast.RecordTypeId = rectAs[0].Id; ast.SerialNumber = 'abcdefg'; ast.Name = '测试资产1'; ast.AccountId = depart1.Id; ast.Department_Class__c = dc1s[0].Id; ast.Hospital__c = company1.Id; ast.Product2Id = prd1.Id; ast.Guarantee_period_for_products__c = Date.today(); ast.InstallDate = Date.today(); ast.Manage_type__c = '个体管理'; ast.FirstApproveDate_old__c = Date.today().addDays(-30); Oly_TriggerHandler.bypass('AssetHandler'); insert ast; Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id]; String RecordTypeID = ast1.RecordTypeID__c; System.assertEquals(RecordTypeID , ast.RecordTypeId); RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ]; Opportunity opp = new Opportunity( Name='testOpp1', StageName='引合', CloseDate=Date.today(), AccountId=depart1.Id, Sales_Root__c = '販売店', Competitor__c ='A', Click_Close_Date__c = null, RecordType = rectOpp ); insert opp; //注残 Statu_Achievements__c Sac = new Statu_Achievements__c( name = 'zhucan_one', Opportunity__c = opp.id, DeliveryDate__c = Date.today(), ContractNO__c = 'ContractNO1', ContractAmount__c = 1000 ); insert Sac; //新建电子签收单 eSignForm__c eSignForm = new eSignForm__c(); eSignForm.Statu_Achievements__c = Sac.Id; eSignForm.Name = '::测试电子签收单'; eSignForm.DNName__c = '112233'; insert eSignForm; eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c(); eSignFormEntry1.Name = '::电子签收单录入表1'; eSignFormEntry1.eSignForm__c = eSignForm.Id; eSignFormEntry1.entryType__c = '经销商收货'; insert eSignFormEntry1; eSignFormEntry__c eSignFormEntry2 = new eSignFormEntry__c(); eSignFormEntry2.Name = '::电子签收单录入表2'; eSignFormEntry2.eSignForm__c = eSignForm.Id; eSignFormEntry2.entryType__c = '经销商收货'; eSignFormEntry2.IsSubmit__c = true; // eSignFormEntry2.createdDate = Date.today().addDays(-2); insert eSignFormEntry2; //新建电子签收单明细 eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c(); eSignFormLineItem.Name = '::电子签收单明细'; eSignFormLineItem.eSignForm__c = eSignForm.Id; insert eSignFormLineItem; //新建电子签收单明细录入表 eSignFormLineItemEntry__c eSignFormLineItemEntry1 = new eSignFormLineItemEntry__c(); eSignFormLineItemEntry1.Name = '::电子签收单明细录入1'; eSignFormLineItemEntry1.eSignFormEntry__c =eSignFormEntry1.Id; eSignFormLineItemEntry1.eSignFormLineItem__c = eSignFormLineItem.Id; insert eSignFormLineItemEntry1; eSignFormLineItemEntry__c eSignFormLineItemEntry2 = new eSignFormLineItemEntry__c(); eSignFormLineItemEntry2.Name = '::电子签收单明细录入2'; eSignFormLineItemEntry2.eSignFormEntry__c =eSignFormEntry2.Id; eSignFormLineItemEntry2.eSignFormLineItem__c = eSignFormLineItem.Id; insert eSignFormLineItemEntry2; eSignAgencyPageController.geteSigns('112233'); eSignAgencyPageController.saveeSignFormEntry(eSignAgencyPageController.geteSigns('112233').eSignFormLineItems,eSignForm,'经销商收货',true,true,null); list attachmentList = new list(); Attachment attach=new Attachment(); attach.Name='Unit Test Attachment'; Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); attach.body=bodyBlob; attach.parentId=eSignForm.id; attachmentList.add(attach); // insert attach; Attachment attach1=new Attachment(); attach1.Name='Unit Test Attachment'; Blob bodyBlob1=Blob.valueOf('Unit Test Attachment Body'); attach1.body=bodyBlob1; attach1.parentId=eSignForm.id; insert attach1; String fileId = String.valueOf(attach1.Id); String body1 = '%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%2F2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj%2F2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj%2FwAARCALuAegDASIAAhEBAxEB%2F8QAHAAAAgIDAQEAAAAAAAAAAAAAAwQCBQABBgcI%2F8QARRAAAgEDAwIFAgMGBAUCBQQDAQIDAAQRBRIhMUEGEyJRYTJxFIGRByNCUqHBFTOx0SRDYuHwcvEWNFNjggglc5ImotL%2FxAAbAQACAwEBAQAAA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qVQRLKSDkS4STdGj%2FkaqtRbM%2FHSnLJ90bIarrps3BqlS4aPa27fSv7m4etWFuPUKQgHqqxgHqFRaZ2hHUtbccUTHqqMA9NEQZkFZ5PM9YBisTvvCmnh9MV5B6CCaeu7dEZccY7UTSJAukWUY4AUE%2FOTQb2bN3IwGQDWESzWEmZ6ZYnMDIC0hcnOec%2FbpW87YVC9P71KAFh8GoT5iyhHpard8S4PqKXJdZ4nUHKnP8AWmL9PxkzMnTcNvwO1WD2gmtlmjGR147HuKTKnzMqBuC5wP4h8fIqFfPU4W'; eSignAgencyPageController.saveChunk(eSignForm.Id,'test01',body1,'image/jpeg',''); eSignAgencyPageController.saveChunk(eSignForm.Id,'test01',body1,'image/jpeg',fileId); eSignAgencyPageController.deleteChunk(fileId); } static testMethod void testMethod2() { List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectCo.size() == 0) { return; } List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科']; if (rectSct.size() == 0) { return; } List rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc]; if (rectDpt.size() == 0) { return; } List rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品']; if (rectAs.size() == 0) { return; } // insert hospital Account company1 = new Account(); company1.RecordTypeId = rectCo[0].Id; company1.Name = '病院テスト1'; company1.OCM_man_province_txt__c = '江西'; List hps = new Account[]{company1}; insert hps; List dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = company1.Id; depart1.OCM_man_province_txt__c = '江西'; insert new Account[] {depart1}; List prdList = new List(); Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'HistoryPrd1'; prd1.ProductCode = 'HistoryPrd1'; prd1.Repair_Product_Code__c = 'HistoryPrd1_RP'; prd1.Name = 'HistoryPrd1'; prd1.Manual_Entry__c = false; prd1.Extend_new_product_gurantee__c = true; prd1.Extend_Gurantee_Start__c = Date.today().addDays(-60); prd1.Extend_Gurantee_End__c = Date.today().addDays(60); prdList.add(prd1); insert prdList; Asset ast = new Asset(); ast.RecordTypeId = rectAs[0].Id; ast.SerialNumber = 'abcdefg'; ast.Name = '测试资产1'; ast.AccountId = depart1.Id; ast.Department_Class__c = dc1s[0].Id; ast.Hospital__c = company1.Id; ast.Product2Id = prd1.Id; ast.Guarantee_period_for_products__c = Date.today(); ast.InstallDate = Date.today(); ast.Manage_type__c = '个体管理'; ast.FirstApproveDate_old__c = Date.today().addDays(-30); Oly_TriggerHandler.bypass('AssetHandler'); insert ast; Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id]; String RecordTypeID = ast1.RecordTypeID__c; System.assertEquals(RecordTypeID , ast.RecordTypeId); RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ]; Opportunity opp = new Opportunity( Name='testOpp1', StageName='引合', CloseDate=Date.today(), AccountId=depart1.Id, Sales_Root__c = '販売店', Competitor__c ='A', Click_Close_Date__c = null, RecordType = rectOpp ); insert opp; //注残 Statu_Achievements__c Sac = new Statu_Achievements__c( name = 'zhucan_one', Opportunity__c = opp.id, DeliveryDate__c = Date.today(), ContractNO__c = 'ContractNO1', ContractAmount__c = 1000 ); insert Sac; //新建电子签收单 eSignForm__c eSignForm = new eSignForm__c(); eSignForm.Statu_Achievements__c = Sac.Id; eSignForm.Name = '::测试电子签收单'; eSignForm.DNName__c = '112233'; insert eSignForm; // eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c(); // eSignFormEntry1.Name = '::电子签收单录入表1'; // eSignFormEntry1.eSignForm__c = eSignForm.Id; // eSignFormEntry1.entryType__c = '经销商收货'; // insert eSignFormEntry1; // eSignFormEntry__c eSignFormEntry2 = new eSignFormEntry__c(); // eSignFormEntry2.Name = '::电子签收单录入表2'; // eSignFormEntry2.eSignForm__c = eSignForm.Id; // eSignFormEntry2.entryType__c = '经销商收货'; // eSignFormEntry2.IsSubmit__c = true; // // eSignFormEntry2.createdDate = Date.today().addDays(-2); // insert eSignFormEntry2; //新建电子签收单明细 eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c(); eSignFormLineItem.Name = '::电子签收单明细'; eSignFormLineItem.eSignForm__c = eSignForm.Id; insert eSignFormLineItem; //新建电子签收单明细录入表 // eSignFormLineItemEntry__c eSignFormLineItemEntry1 = new eSignFormLineItemEntry__c(); // eSignFormLineItemEntry1.Name = '::电子签收单明细录入1'; // eSignFormLineItemEntry1.eSignFormEntry__c =eSignFormEntry1.Id; // eSignFormLineItemEntry1.eSignFormLineItem__c = eSignFormLineItem.Id; // insert eSignFormLineItemEntry1; // eSignFormLineItemEntry__c eSignFormLineItemEntry2 = new eSignFormLineItemEntry__c(); // eSignFormLineItemEntry2.Name = '::电子签收单明细录入2'; // eSignFormLineItemEntry2.eSignFormEntry__c =eSignFormEntry2.Id; // eSignFormLineItemEntry2.eSignFormLineItem__c = eSignFormLineItem.Id; // insert eSignFormLineItemEntry2; eSignAgencyPageController.geteSigns('112233'); eSignAgencyPageController.saveeSignFormEntry(eSignAgencyPageController.geteSigns('112233').eSignFormLineItems,eSignForm,'经销商收货',true,true,null); } }