@isTest
|
private class PaymentPlanLoadControllerTest {
|
private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
|
private static Account hospital = null;
|
private static List<Account> strategicDep = null;
|
private static Product2 productA = null;
|
private static Account dep = null;
|
private static PricebookEntry entry = null;
|
private static Asset asset01 = null;
|
private static Asset asset02 = null;
|
private static Asset asset03 = null;
|
private static Maintenance_Contract__c contract = null;
|
static {
|
|
}
|
@isTest static void test_method_one() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// 病院を作る
|
hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
|
// 戦略科室を得る
|
strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
|
// 診療科を作る
|
dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
|
dep.Name = 'test dep';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
// 製品を作る
|
productA = new Product2( Name='テスト商品');
|
insert productA;
|
|
// 価格表エントリを作成する
|
entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
|
entry.UnitPrice = 0;
|
entry.IsActive = true;
|
entry.UseStandardPrice = false;
|
entry.CurrencyIsoCode = 'CNY';
|
entry.Product2Id = productA.Id;
|
insert entry;
|
|
|
|
|
List<User> UserList = new List<User>();
|
|
User MacOwner = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
UserList.add(MacOwner);
|
User MacOwner1 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner2', Alias = 'hp', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com2', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
UserList.add(MacOwner1);
|
User MacOwner2 = new User(Test_staff__c = true, LastName = 'hp3', FirstName = 'owner3', Alias = 'hp', CommunityNickname = 'hpOwner3', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com3', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
UserList.add(MacOwner2);
|
User MacOwner3 = new User(Test_staff__c = true, LastName = 'hp4', FirstName = 'owner4', Alias = 'hp', CommunityNickname = 'hpOwner4', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com4', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
UserList.add(MacOwner3);
|
User MacOwner4 = new User(Test_staff__c = true, LastName = 'hp5', FirstName = 'owner5', Alias = 'hp', CommunityNickname = 'hpOwner5', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com5', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
UserList.add(MacOwner4);
|
User MacOwner5 = new User(Test_staff__c = true, LastName = 'hp5', FirstName = 'owner6', Alias = 'hp', CommunityNickname = 'hpOwner6', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com6', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
UserList.add(MacOwner5);
|
insert UserList;
|
// Implement test code
|
Maintenance_Contract__c target01 = new Maintenance_Contract__c();
|
target01.Department__c = dep.Id;
|
target01.Name = 'TestMAC';
|
target01.Service_Contract_Staff__c = MacOwner.id;
|
target01.Contract_Start_Date__c = Date.today();
|
target01.Contract_End_Date__c = Date.today().addMonths(+12);
|
target01.Is_Standard_Contract__c = '是';
|
target01.Inspection_Time__c = '1';
|
target01.Total_Payment_Time__c = '1';
|
target01.Term_Of_Payment__c = '多次付款';
|
target01.Contract_Range__c = Decimal.valueOf('12');
|
|
insert target01;
|
|
PageReference page = new PageReference('apex/PaymentPlanLoad?id=' + target01.Id );
|
System.Test.setCurrentPage(page);
|
PaymentPlanLoadController ppc = new PaymentPlanLoadController();
|
ppc.init();
|
ppc.save();
|
|
target01.Service_Contract_Staff__c = MacOwner1.id;
|
update target01;
|
ppc.init();
|
ppc.save();
|
target01.Service_Contract_Staff__c = MacOwner2.id;
|
update target01;
|
ppc.init();
|
ppc.PageMCEElement.Is_Standard_Contract__c = '是';
|
ppc.PageMCEElement.Term_Of_Payment__c = '多次付款';
|
ppc.PageMCEElement.Payment_Plan_Sum_First__c = 2000;
|
ppc.PageMCEElement.Payment_Plan_Date_First__c = Date.today();
|
target01.one_off_payment_agreed_period__c = '15';
|
ppc.print();
|
ppc.save();
|
target01.Service_Contract_Staff__c = MacOwner3.id;
|
update target01;
|
ppc.init();
|
ppc.PageMCEElement.Is_Standard_Contract__c = '是';
|
ppc.PageMCEElement.Term_Of_Payment__c = '一次性付款';
|
ppc.PageMCEElement.Payment_Plan_Sum_First__c = 2000;
|
ppc.PageMCEElement.Payment_Plan_Date_First__c = Date.today();
|
target01.one_off_payment_agreed_period__c = '15';
|
ppc.print();
|
ppc.save();
|
target01.Service_Contract_Staff__c = MacOwner4.id;
|
update target01;
|
ppc.init();
|
ppc.PageMCEElement.Is_Standard_Contract__c = '否';
|
ppc.PageMCEElement.Term_Of_Payment__c = '一次性付款';
|
ppc.print();
|
ppc.save();
|
|
target01.Service_Contract_Staff__c = MacOwner5.id;
|
update target01;
|
ppc.init();
|
ppc.save();
|
ppc.getSmall_Repair_Time();
|
ppc.getTour_Check();
|
ppc.getTotal_Payment_Time();
|
ppc.getTerm_Of_Payment();
|
ppc.getFirst_Party_Contract_Number();
|
ppc.getCheck_Of_Payment();
|
ppc.getDedust();
|
ppc.getNegotiate_Mean();
|
ppc.getBig_Repair_Time();
|
ppc.getone_off_payment_agreed_period();
|
ppc.dummy();
|
}
|
|
@isTest static void test_method_two() {
|
|
}
|
|
}
|