@isTest 
public class AgencyReportHandlerTest{
    public static Account account1 = new Account();
    public static Account account2 = new Account();
    public static Contact contact1 = new Contact();
    public static Contact contact2 = new Contact();
    public static User user = new User();
    //public static Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
    //public static Agency_Contact__c agency_contact = new Agency_Contact__c();
    //public static ProductTypes__c product_types = new ProductTypes__c();
    //public static Agency_Opportunity__c agency_opportunity = new Agency_Opportunity__c();
    //public static OlympusCalendar__c olympus_calendar = new OlympusCalendar__c();
    
    public static String report_id;
    public static String report_header_id;
    
    /* 病院。コンタクト、ユーザー、カレンダーなどの初期データ作る
    */
    public static testMethod void test_method(){
        
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs(thisUser) {
            // 週報ヘッダー作成
            // 取引先
            account1.Name = 'test1医院';
            account1.RecordTypeId = '01210000000QemG';
            insert account1;
            
            account2.Name = 'test1经销商';
            account2.RecordTypeId = '01210000000Qem1';
            insert account2;
            
            // 取引先責任者
            contact1.AccountId = account1.Id;
            contact1.FirstName = '責任者';
            contact1.LastName = 'test1医院';
            insert contact1;
            
            contact2.AccountId = account2.Id;
            contact2.FirstName = '責任者';
            contact2.LastName = 'test1经销商';
            insert contact2;
            
            // ユーザー
            Profile p = [select Id from Profile where Name = '901_经销商活动系统'];
            user.ProfileId = p.Id;
            user.ContactId = contact2.Id;
            user.FirstName = 'ユーザー';
            user.LastName = 'テスト';
            user.Email = 'test_user@example.com';
            user.emailencodingkey='UTF-8';
            user.languagelocalekey='zh_CN';
            user.localesidkey='ja_JP';
            user.timezonesidkey='Asia/Shanghai';
            user.Username = 'test_user@example.com';
            user.Alias = 'テユ';
            user.CommunityNickname = 'テストユーザー';
            insert user;

            Date sDate = Date.newInstance(2017, 4, 10);
            //String cc = [select Id,Country__c from User where Id = :Userinfo.getUserId()].Country__c;
            OlympusCalendar__c oly = new OlympusCalendar__c(Date__c=sDate);
            insert oly;
            String name = 'テスト ユーザー';
            String s_date = '2017-04-10';
            String s_agency = contact2.Id;
            String head_key = contact2.Id + ':20170410';
            report_header_id = WeeklyReportCmp.createReportHeader(name, s_date, s_agency, head_key);
            
            Agency_Report_Header__c data = [select Id, Name, Agency__c,Owner_Agency_ID__c,Agency_ID__c,Week__c, Agency_Person2__c, HeaderInputKey__c, OlympusDate__r.Date__c from Agency_Report_Header__c where HeaderInputKey__c = :head_key];
   
            // System.assertEquals(data.Agency__c , data.Owner_Agency_ID__c);
            // System.assertEquals(data.Agency_ID__c , String.valueOf(data.Owner_Agency_ID__c).substring(0,15));
        }
    }

}