高章伟
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
@isTest
private class UpOpportunityTradeBatchTest
{
    static testMethod void testUpOpportunity() {
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
        
        Account acc = new Account();
        acc.RecordTypeId = rectCo.Id;
        acc.Name = 'HP test1';
        insert acc;
        
        List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
        depart1.Name         = '*';
        depart1.Department_Name__c  = 'Gastoro Intestin Test';
        depart1.ParentId            = dept[0].Id;
        depart1.Department_Class__c = dept[0].Id;
        depart1.Hospital__c         = acc.Id;
        
        Account depart2 = new Account();
        depart2.RecordTypeId = rectDpt[1].Id;
        depart2.Name         = '*';
        depart2.Department_Name__c  = '診療科2';
        depart2.ParentId            = dept[1].Id;
        depart2.Department_Class__c = dept[1].Id;
        depart2.Hospital__c         = acc.Id;
        insert new Account[] {depart1, depart2};
        
        RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
        
        Opportunity opp1 = new Opportunity(Name='aiueo1', StageName='出荷', CurrencyIsoCode='USD', CloseDate=Date.today());
        Opportunity opp2 = new Opportunity(Name='aiueo2', StageName='出荷', CurrencyIsoCode='CNY', CloseDate=Date.today());
        insert new Opportunity[] {opp1, opp2};
        List<Opportunity> test = [Select Id,Tax_Foreign_F__c,Tax_Foreign_F_Copy__c,Tax_Intra_F__c,Tax_Intra_F_Copy__c from Opportunity where Id =:opp1.Id ];
        System.assertEquals(1, test.size());
        System.assertEquals(test[0].Tax_Foreign_F__c, test[0].Tax_Foreign_F_Copy__c);
        System.assertEquals(test[0].Tax_Intra_F__c, test[0].Tax_Intra_F_Copy__c);
        //insert opp1;
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new UpOpportunityTradeBatch(), 50);
        System.Test.StopTest();
 
        // assert
        List<Opportunity> bList = [select Id from Opportunity];
        System.assertEquals(2, bList.size());
    }
}