@isTest
private class CampaignCreateControllerTest {
    static User user;
    static Application_for_Conference_Adjudication__c afca;
    static Campaign cam;

    static testMethod void testSample_01() {
        List<RecordType> rectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'Society'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found Society recordtype');
        }
        
        System.runAs(new User(Id = Userinfo.getUserId())) {
            user = new User(Test_staff__c = true);
            user.LastName = '_サンブリッジ';
            user.FirstName = 'う';
            user.Alias = 'う';
            user.Email = 'olympusTest03@sunbridge.com';
            user.Username = 'olympusTest03@sunbridge.com';
            user.IsActive = true;
            user.EmailEncodingKey = 'ISO-2022-JP';
            user.TimeZoneSidKey = 'Asia/Tokyo';
            user.LocaleSidKey = 'ja_JP';
            user.LanguageLocaleKey = 'ja';
            user.ProfileId = System.Label.ProfileId_SystemAdmin;
            user.Province__c = '北京';
            user.Dept__c = '医疗华北营业本部';
            user.Use_Start_Date__c = Date.today().addMonths(-6);
            insert user;
            
            afca = new Application_for_Conference_Adjudication__c();
            afca.Name = 'test01';
            afca.StartDate__c = Date.today();
            afca.EndDate__c =  Date.today().addDays(20);
            afca.BudgetType__c =  '新产品上市';
            afca.OfficeCategory__c =  '1.消化科';
            afca.MeetingType__c = '共同主办会';
            afca.WorkshopPlace__c = 'Beijing';
            afca.HostName__c = 'Olympus';
            afca.CooperatorCompany__c = 'Olympus';
            afca.ConveningParticipantsNum__c = 200;
            afca.ExpectedOlympusAttendance__c = 200;
            afca.ExpectedHcpAttendance__c = 200;
            afca.SponsorshipCategory__c = '无';
            afca.IsPaidToSponsor__c = '是';
            afca.ActivityTypeName__c = '线上';
            insert afca;

            cam = new Campaign();
            cam.Name = 'test campaign';
            cam.StartDate = Date.today().addDays(15);
            cam.EndDate = Date.today().addDays(18);
            cam.Name2__c = '1234';
            cam.Status = '申请中';
            cam.Mailflg_after45__c = true;
            cam.Mailflg_cancel__c = true;
            cam.Mailflg_before15__c = true;
            cam.Mailflg_before7__c = true;
            cam.Mailflg_after3__c = true;
            cam.HostName__c = '1';
            cam.cooperatorCompany__c = '1';
            cam.RecordTypeId = rectCo[0].Id;
            cam.OwnerId = user.Id;
            cam.Meeting_Approved_No__c = afca.Id;
            insert cam;
        }
        PageReference page = new PageReference('/apex/CampaignCreate?RecordType=' + rectCo[0].Id + '&CMRT=\'123123\'' + '&retURL=\'123123\''
                                                +'&p8=\'123123\''+'&CF00N10000002DIsr=\'123123\''+'&ent=\'123123\''+'&CF00N10000002DIsr_lkid=\'123123\'');
        System.Test.setCurrentPage(page);
        System.Test.startTest();
        CampaignCreateController cam = new CampaignCreateController(new ApexPages.StandardController(cam));
        cam.init();
        cam.AdjudicationDataobj.isAdjudication = true;
        cam.AdjudicationDataobj.cam.Meeting_Approved_No__c = afca.Id;
        cam.skipPage();
        cam.returnPage();
        cam.displayDecisionTheme();
        System.Test.stopTest();
    }

    static testMethod void testSample_02() {
        List<RecordType> rectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'Training_event'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found Training_event recordtype');
        }
        System.runAs(new User(Id = Userinfo.getUserId())) {
            user = new User(Test_staff__c = true);
            user.LastName = '_サンブリッジ';
            user.FirstName = 'う';
            user.Alias = 'う';
            user.Email = 'olympusTest03@sunbridge.com';
            user.Username = 'olympusTest03@sunbridge.com';
            user.IsActive = true;
            user.EmailEncodingKey = 'ISO-2022-JP';
            user.TimeZoneSidKey = 'Asia/Tokyo';
            user.LocaleSidKey = 'ja_JP';
            user.LanguageLocaleKey = 'ja';
            user.ProfileId = System.Label.ProfileId_SystemAdmin;
            user.Province__c = '北京';
            user.Dept__c = '医疗华北营业本部';
            user.Use_Start_Date__c = Date.today().addMonths(-6);
            insert user;
            
            // afca = new Application_for_Conference_Adjudication__c();
            // afca.Name = 'test01';
            // afca.StartDate__c = Date.today();
            // afca.EndDate__c =  Date.today().addDays(20);
            // afca.BudgetType__c =  '新产品上市';
            // afca.OfficeCategory__c =  '1.消化科';
            // afca.MeetingType__c = '共同主办会';
            // afca.WorkshopPlace__c = 'Beijing';
            // afca.HostName__c = 'Olympus';
            // afca.CooperatorCompany__c = 'Olympus';
            // afca.ConveningParticipantsNum__c = 200;
            // afca.ExpectedOlympusAttendance__c = 200;
            // afca.ExpectedHcpAttendance__c = 200;
            // afca.SponsorshipCategory__c = '无';
            // afca.IsPaidToSponsor__c = '是';
            // afca.ActivityTypeName__c = '线上';
            // insert afca;

            cam = new Campaign();
            cam.Name = 'test campaign';
            cam.StartDate = Date.today().addDays(15);
            cam.EndDate = Date.today().addDays(18);
            cam.Name2__c = '1234';
            cam.Status = '申请中';
            cam.Mailflg_after45__c = true;
            cam.Mailflg_cancel__c = true;
            cam.Mailflg_before15__c = true;
            cam.Mailflg_before7__c = true;
            cam.Mailflg_after3__c = true;
            cam.HostName__c = '1';
            cam.cooperatorCompany__c = '1';
            cam.RecordTypeId = rectCo[0].Id;
            cam.OwnerId = user.Id;
            insert cam;
        }
        PageReference page = new PageReference('/apex/CampaignCreate?RecordType=' + rectCo[0].Id);
        System.Test.setCurrentPage(page);
        System.Test.startTest();
        CampaignCreateController cam = new CampaignCreateController(new ApexPages.StandardController(cam));
        cam.init();
        System.Test.stopTest();
    }
}