高章伟
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
@isTest
private class UpdateHospitalOppDateBatchTest {
 
    @isTest static void test_method_one() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
 
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM007TestCompany';
        upsert company;
        RecordType[] rt = [select Id from RecordType where SobjectType = 'Opportunity' and IsActive = true and DeveloperName = 'Target'];
        list<Opportunity> Opportunities = new list<Opportunity>();
        Opportunity newopp = new Opportunity();
        newopp.Name =  'test01' ;
        newopp.StageName = '目標';
        newopp.Hospital__c =     company.id;    
        newopp.RecordTypeId = rt[0].ID;
        newopp.CloseDate = Date.today();
 
        upsert newopp;
        Statu_Achievements__c Sac = new Statu_Achievements__c(
            name = 'zhucan_one',
            Opportunity__c = newopp.id,
            DeliveryDate__c = Date.today(),
            ContractNO__c = 'ContractNO1',
            ContractAmount__c = 1
        );
        insert Sac;
 
        Id execBTId = Database.executeBatch(new UpdateHospitalOppDateBatch(company.id), 100);
        execBTId = Database.executeBatch(new UpdateHospitalOppDateBatch(), 100);
    }
 
}