高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
@isTest
private class NFM605ControllerTest {
    static testMethod void testMethod1() {
        
    }
 
    @testSetup
    static void makeTestRepair() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        // テストデータ
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM105TestCompany';
        upsert company;
        Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId = :company.Id and RecordTypeId = :rectSct[0].Id];
 
        Account depart = new Account();
        depart.RecordTypeId        = rectDpt[0].Id;
        depart.Name                = '*';
        depart.Department_Name__c  = 'NFM105TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        Maintenance_Contract__c contract = new Maintenance_Contract__c();
        contract.Department__c = depart.Id;
        insert contract;
 
        //Maintenance_Contract__c[] contracts = [select id from Maintenance_Contract__c];
 
        NewMaintenanceReport_Task__c  report  = new NewMaintenanceReport_Task__c();
        report.Name = 'test';
        report.NewMaintenance_Contract__c = contract.Id;
        insert report;
 
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Log__c = '[{"strategicDepartmenCd":"8089822","reportSendTime":"20210830080000","reportSeasonStartDate":null,"reportSeasonEndDate":null,"reportSeason":"1","hospitalCd":"8089819","departmentCd":"8089823","CurDistributionTimes":0,"contractStartDate":"20181221000000","contractEquipQty":"0","contractEndDate":"20211220000000","contractCd":"GZ-RS-GD0051448","ActDistributionTimes":0}]';
        iflog.Type__c = '605test';
        insert iflog;
 
 
    }
 
    @isTest
    static void testcallout1(){
        List<NewMaintenanceReport_Task__c> reportList = [select id from NewMaintenanceReport_Task__c];
 
        Test.startTest();
 
        List<Id> idList = new List<Id>();
        for(NewMaintenanceReport_Task__c report : reportList){
            idList.add(report.Id);
        }
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Log__c = 'test start \n';
        insert iflog;
        NFM605Controller.callout(iflog.Id,idList);
            
        Test.stopTest();
    }
 
    @isTest
    static void testcallout2(){
        List<NewMaintenanceReport_Task__c> reportList = [select id from NewMaintenanceReport_Task__c];
 
        Test.startTest();
 
        List<Id> idList = new List<Id>();
        for(NewMaintenanceReport_Task__c report : reportList){
            idList.add(report.Id);
        }
        NFM605Controller.executeNotFuture(null,idList);
        
        Test.stopTest();
    }
 
    @isTest
    static void testcallout3(){
        BatchIF_Log__c iflog = [select id from BatchIF_Log__c where Type__c = '605test'];
        NFM605Controller.ManualExecute(iflog.Id);
    }
 
    // @isTest
    // static void testcallout4(){
    //     List<NewMaintenanceReport_Task__c> reportList = [select id from NewMaintenanceReport_Task__c];
 
    //     Test.startTest();
 
    //     List<Id> idList = new List<Id>();
    //     for(NewMaintenanceReport_Task__c report : reportList){
    //         idList.add(report.Id);
    //     }
    //     NFM605Controller.executeNotFuture(null,null);
        
    //     Test.stopTest();
    // }
    
}