@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();
|
// }
|
|
}
|