1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@isTest
private class LexNewOnLineSurvey2ControllerTest {
    static Account company;   //医院
    static Account section1;  //科室ET
    static Account agent;  //经销商
    static Account contact;  //契约
    static Account olympus;  //Olympus社内 其他 经销商资产
    static testMethod void testMethod1() {
        RecordType rectagent = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        RecordType rectContract = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        RecordType rect9900 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 その他'];
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        RecordType rectDpt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類ET'];
        //RecordType rectDpt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        company = new Account(RecordTypeId = rectCo.Id, Name = 'NFM110TestCompany');
        olympus = new Account(RecordTypeId = rectCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert new Account[] {company, olympus};
        // company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:company.Id];
        // section1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:company.Id and RecordType.name = '戦略科室分類ET'];
        company = [select Management_Code__c, Name, Id from Account where Id =:company.Id];
        section1 = [select Management_Code__c, Name, Id, Department_Class_Label__c from Account where ParentId =:company.Id and RecordType.name = '戦略科室分類ET'];
        //
        agent = new Account(name='Testaccount001',
                                        Dealer_discount__c =20,
                                        Ban_On_Use_Date__c = Date.today().addDays(1),
                                        Business_Paper_Expiration_Date__c = Date.today().addDays(1),
                                        Tax_Practice_Expiration_Date__c = Date.today().addDays(1),
                                        Medical_Equipment_Expiration_Date__c = Date.today().addDays(1),
                                        RecordTypeId = rectagent.Id);
        insert agent;
        //经销商有效合同
        contact = new Account(name='Testaccount002',
                                            RecordTypeId = rectContract.Id,
                                            Contract_Decide_Start_Date__c = Date.today().addDays(-1),
                                            Contract_Decide_End_Date__c =Date.today().addDays(1),
                                            Contract_Start_Date__c = Date.today().addDays(-1),
                                            Contract_End_Date__c =Date.today().addDays(1),
                                            Agent_Ref__c =agent.Id,
                                            ET_SP_Dealer__c = true,
                                            ParentId =agent.Id);
        insert contact;
 
        lexNewOnLineSurvey2Controller c = new lexNewOnLineSurvey2Controller();
        lexNewOnLineSurvey2Controller.init(contact.Id);
    }
}