@isTest
|
private class NextMonthVisitBatchTest {
|
static testMethod void testMethod1() {
|
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;
|
}
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM007TestCompany';
|
upsert 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;
|
upsert section;
|
System.Test.startTest();
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM007TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
|
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-NFM007_1';
|
opp.Trade__c = '内貿';
|
opp.StageName = '引合';
|
opp.CloseDate = date.newinstance(2022, 11, 30);
|
opp.Stock_apply_status__c = '申请中';
|
opp.IsNextMonthOfVisit__c = true;
|
insert opp;
|
|
// RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='販売店' limit 1];
|
// Account sellerA = new Account(Name = '販売店A');
|
// sellerA.RecordTypeId = recHanbaiten.id;
|
// sellerA.Delete_Flag__c = false;
|
// insert sellerA;
|
|
Database.executeBatch(new NextMonthVisitBatch(), 1);
|
System.Test.stopTest();
|
|
}
|
static testMethod void testMethod2() {
|
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;
|
}
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM007TestCompany';
|
upsert 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;
|
upsert section;
|
System.Test.startTest();
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM007TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
|
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-NFM007_1';
|
opp.Trade__c = '内貿';
|
opp.StageName = '引合';
|
opp.CloseDate = date.newinstance(2022, 11, 30);
|
opp.Stock_apply_status__c = '申请中';
|
opp.IsNextMonthOfVisit__c = true;
|
insert opp;
|
|
// RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='販売店' limit 1];
|
// Account sellerA = new Account(Name = '販売店A');
|
// sellerA.RecordTypeId = recHanbaiten.id;
|
// sellerA.Delete_Flag__c = false;
|
// insert sellerA;
|
|
Database.executeBatch(new NextMonthVisitBatch(opp.Id), 1);
|
System.Test.stopTest();
|
|
}
|
static testMethod void testMethod3() {
|
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;
|
}
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM007TestCompany';
|
upsert 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;
|
upsert section;
|
System.Test.startTest();
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM007TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
|
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-NFM007_1';
|
opp.Trade__c = '内貿';
|
opp.StageName = '引合';
|
opp.CloseDate = date.newinstance(2022, 11, 30);
|
opp.Stock_apply_status__c = '申请中';
|
opp.IsNextMonthOfVisit__c = true;
|
insert opp;
|
|
Opportunity opp1 = new Opportunity();
|
opp1.AccountId = depart.Id;
|
opp1.Department_Class__c = section.Id;
|
opp1.Hospital__c = company.Id;
|
opp1.SAP_Send_OK__c = false;
|
opp1.Name = 'GZ-SP-NFM007_1';
|
opp1.Trade__c = '外貿';
|
opp1.StageName = '引合';
|
opp1.CloseDate = date.newinstance(2022, 11, 30);
|
opp1.Stock_apply_status__c = '申请中';
|
opp1.IsNextMonthOfVisit__c = true;
|
insert opp1;
|
|
List<String> idList =new List<String> {opp.Id,opp1.Id};
|
// RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='販売店' limit 1];
|
// Account sellerA = new Account(Name = '販売店A');
|
// sellerA.RecordTypeId = recHanbaiten.id;
|
// sellerA.Delete_Flag__c = false;
|
// insert sellerA;
|
|
Database.executeBatch(new NextMonthVisitBatch(idList), 2);
|
System.Test.stopTest();
|
|
}
|
}
|