liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@isTest
private class OpportunityLightingButtonControllerTest {
    
    @TestSetup
    static void makeData(){
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        // if (rectCo.size() == 0) {
        //     return;
        // }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        // if (rectSct.size() == 0) {
        //     return;
        // }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        // if (rectDpt.size() == 0) {
        //     return;
        // }
        List<RecordType> rectAgency = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        // if (rectAgency.size() == 0) {
        //     return;
        // }
        // テストデータ
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM206TestCompany';
        insert company;
        Account section = new Account();
        section.RecordTypeId = rectSct[0].Id;
        section.Name         = '*';
        section.Department_Class_Label__c = '消化科';
        section.ParentId                  = company.Id;
        section.Hospital_Department_Class__c = company.Id;
        insert section;
        Account depart = new Account();
        depart.RecordTypeId = rectDpt[0].Id;
        depart.Name         = '*';
        depart.Department_Name__c  = 'NFM206TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        insert depart;
        Date today = Date.today();
        Date lastDate1 = Date.today().addMonths(1);
        Date lastDate2 = Date.today().addMonths(2);
        Date lastDate3 = Date.today().addMonths(3);
 
        Account account2  = new Account();
        account2.Name = 'test1经销商';
        account2.RecordTypeId = rectAgency[0].id;
        insert account2;
 
        Opportunity opp = new Opportunity();
        opp.AccountId           = depart.Id;
        opp.Department_Class__c = section.Id;
        opp.Hospital__c         = company.Id;
        opp.SAP_Send_OK__c      = false;
        opp.Name                = 'GZ-SP-NFM009_0';
        opp.agency1__c             =  account2.Id;
        opp.Trade__c            = '内貿';
        opp.StageName           = '出荷';
        opp.CloseDate           = lastDate1;
        opp.Close_Forecasted_Date__c = lastDate1;
        opp.Stock_apply_status__c = '申请中';
        insert opp;
    }
 
    static testMethod void test1(){
        List<Opportunity> oppList = new List<Opportunity>();
        oppList = [select Id from Opportunity limit 1];
        Test.startTest();
        OpportunityLightingButtonController.queryForEditLostButton(oppList[0].Id);
        OpportunityLightingButtonController.initForPredictedDateChangeButton(oppList[0].Id);
        OpportunityLightingButtonController.initForAgencyAuthorizeButton(oppList[0].Id);
        OpportunityLightingButtonController.initForLoseBidButton(oppList[0].Id);
        OpportunityLightingButtonController.initForOLYwinBidButton(oppList[0].Id);
        OpportunityLightingButtonController.initForCreateEventButton(oppList[0].Id);
        OpportunityLightingButtonController.initForBeforeOPDPDFBtnButton(oppList[0].Id);
        OpportunityLightingButtonController.initFoBeforeOPDPDFBtnSISButton(oppList[0].Id);
        OpportunityLightingButtonController.initForRequestDBButton(oppList[0].Id);
        OpportunityLightingButtonController.initForCancelReportButton(oppList[0].Id);
        OpportunityLightingButtonController.initForLostReportButton(oppList[0].Id);
        OpportunityLightingButtonController.initForLexQuoteEntryNewbotton(oppList[0].Id);
        OpportunityLightingButtonController.initForQuotationRequestButton(oppList[0].Id);
        OpportunityLightingButtonController.initForStockApplyButton(oppList[0].Id);
        OpportunityLightingButtonController.initForQuotationProductNewButton(oppList[0].Id);
        OpportunityLightingButtonController.initForCopyWithAssetButton(oppList[0].Id);
        OpportunityLightingButtonController.initForNewOpportunityAgencyButton(oppList[0].Id);
        OpportunityLightingButtonController.initForOpporSpliteButton(oppList[0].Id);
        OpportunityLightingButtonController.initForCreateActivityButton(oppList[0].Id);
        OpportunityLightingButtonController.initForAssignTaskButtonButton(oppList[0].Id);
        OpportunityLightingButtonController.initForChangeContractTypeButton(oppList[0].Id);
        OpportunityLightingButtonController.initForSpecilaApplyCreateButton(oppList[0].Id);
        OpportunityLightingButtonController.initForSpecilaApplyCreateAchButton(oppList[0].Id);
        OpportunityLightingButtonController.initForNewOpportunityFileButton(oppList[0].Id);
        OpportunityLightingButtonController.updateForAgencyAuthorizeButton(oppList[0].Id);
        OpportunityLightingButtonController.updateForLoseBidButton(oppList[0].Id);
        OpportunityLightingButtonController.updateForOLYwinBidButton(oppList[0].Id);
        OpportunityLightingButtonController.updateForStockApplyButton(oppList[0].Id,true);
        OpportunityLightingButtonController.queryForPredictedDateChangeButton(oppList[0].Id);
        OpportunityLightingButtonController.queryForLoseBidButton(oppList[0].Id);
        OpportunityLightingButtonController.queryForOLYwinBidButton(oppList[0].Id);
        OpportunityLightingButtonController.queryForCancelReportButton(oppList[0].Id);
        OpportunityLightingButtonController.queryForQuotationRequestButton(oppList[0].Id);
        OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecords(oppList[0].Id,'');
        OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecords2(oppList[0].Id);
        OpportunityLightingButtonController.submitProcess(oppList[0].Id);
        OpportunityLightingButtonController.getUserIdByName(oppList[0].Id);
        OpportunityLightingButtonController.getProfileIdByName(oppList[0].Id);
        OpportunityLightingButtonController.queryForProfileId();
        OpportunityLightingButtonController.initCopy(oppList[0].Id);
        OpportunityLightingButtonController.forma(oppList[0].Id);
        OpportunityLightingButtonController.changeTrade(oppList[0].Id);
        OpportunityLightingButtonController.queryQuote('');
        OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecTypeList('Product','',true);
        
        Test.stopTest();
    }
 
    static testMethod void test2(){
        OCMManagementProvinceWebService.updateOpportunity();
    }
}