@isTest public with sharing class SubmitForApprovalControllerTest { static Maintenance_Contract__c setupTestData02(Account hospital, Account strategicDep, Account dep) { Maintenance_Contract__c mc = new Maintenance_Contract__c(); mc.Name = '12313132'; //合同名 mc.Status__c = '询价中'; //状态 mc.Department__c = dep.Id; //科室 mc.Service_Contract_Staff__c = UserInfo.getUserId(); //主担当者 // mc.Negotiation_Start_Date__c = Date.today(); //谈判开始日 // mc.Opportunity_Stage__c = '意向确认'; //询价进展状态 // mc.Forecast_Selling_Price__c = 100000; //预测成交价 // mc.Sales_Method__c = '公开招标'; //招标方式 insert mc; return mc; } @isTest static void setupTestData03() { Account company1 = new Account(); company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); company1.Name = '病院テスト1'; 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 and RecordType_DeveloperName__c = 'Department_Class_BF']; StaticParameter.EscapeAccountTrigger = true; Account depart1 = new Account(); depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = company1.Id; insert depart1; Account depart2 = new Account(); depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart2.Name = '*'; depart2.Department_Name__c = '消化科1'; depart2.ParentId = dc1s[0].Id; depart2.Department_Class__c = dc1s[0].Id; depart2.Hospital__c = company1.Id; insert depart2; StaticParameter.EscapeSyncProduct2Trigger = true; Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1); PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + mContract.Id); System.Test.setCurrentPage(page); SubmitForApprovalController sfac = new SubmitForApprovalController(); //初始化测试 sfac.init(); // sfac.lostData.Specific_Reasons__c = '其他(手写)'; //提交审批 sfac.submit(); //保存测试 sfac.save(); } @isTest static void setupTestData04() { Account company1 = new Account(); company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); company1.Name = '病院テスト1'; 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 and RecordType_DeveloperName__c = 'Department_Class_BF']; StaticParameter.EscapeAccountTrigger = true; Account depart1 = new Account(); depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = company1.Id; insert depart1; Account depart2 = new Account(); depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart2.Name = '*'; depart2.Department_Name__c = '消化科1'; depart2.ParentId = dc1s[0].Id; depart2.Department_Class__c = dc1s[0].Id; depart2.Hospital__c = company1.Id; insert depart2; StaticParameter.EscapeSyncProduct2Trigger = true; Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1); PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + mContract.Id); System.Test.setCurrentPage(page); SubmitForApprovalController sfac = new SubmitForApprovalController(); //初始化测试 sfac.init(); sfac.lostData.Specific_Reasons__c = '其他(手写)'; sfac.lostData.To_Where__c = '医院选择第三方'; //提交审批 sfac.submit(); //保存测试 sfac.save(); } @isTest static void setupTestData05() { Account company1 = new Account(); company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); company1.Name = '病院テスト1'; 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 and RecordType_DeveloperName__c = 'Department_Class_BF']; StaticParameter.EscapeAccountTrigger = true; Account depart1 = new Account(); depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = company1.Id; insert depart1; Account depart2 = new Account(); depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart2.Name = '*'; depart2.Department_Name__c = '消化科1'; depart2.ParentId = dc1s[0].Id; depart2.Department_Class__c = dc1s[0].Id; depart2.Hospital__c = company1.Id; insert depart2; StaticParameter.EscapeSyncProduct2Trigger = true; Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1); PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + mContract.Id); System.Test.setCurrentPage(page); SubmitForApprovalController sfac = new SubmitForApprovalController(); //初始化测试 sfac.init(); sfac.lostData.Specific_Reasons__c = '其他(手写)'; sfac.lostData.To_Where__c = '其他(手写)'; //提交审批 sfac.submit(); //保存测试 sfac.save(); } @isTest static void setupTestData06() { Account company1 = new Account(); company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); company1.Name = '病院テスト1'; 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 and RecordType_DeveloperName__c = 'Department_Class_BF']; StaticParameter.EscapeAccountTrigger = true; Account depart1 = new Account(); depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = company1.Id; insert depart1; Account depart2 = new Account(); depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId(); depart2.Name = '*'; depart2.Department_Name__c = '消化科1'; depart2.ParentId = dc1s[0].Id; depart2.Department_Class__c = dc1s[0].Id; depart2.Hospital__c = company1.Id; insert depart2; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.status__c ='契約'; contract.Maintenance_Contract_No__c = 'Kami_Contract_No'; contract.Contract_Conclusion_Date__c = Date.today(); contract.Hospital__c = depart2.Id; contract.Department_Class__c = depart2.Id; contract.Department__c = depart2.Id; contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前 contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後 contract.SalesOfficeCode_selection__c = '北京RC'; contract.RecordTypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('VM_Contract').getRecordTypeId(); insert contract; Lost_Report__c lr = new Lost_Report__c(); lr.Maintenance_Contract__c = contract.ID; lr.Specific_Reasons__c = '跟进不够'; lr.To_Where__c = ''; lr.Status__c = '审批中'; insert lr; StaticParameter.EscapeSyncProduct2Trigger = true; Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1); PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + lr.Id); System.Test.setCurrentPage(page); SubmitForApprovalController sfac = new SubmitForApprovalController(); //初始化测试 sfac.init(); sfac.lostData.Specific_Reasons__c = '其他(手写)'; sfac.lostData.To_Where__c = '其他(手写)'; //提交审批 sfac.submit(); //保存测试 sfac.save(); } }