高章伟
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
@isTest
public class LicenseInfoHandlerTest {
    static testMethod void testMonitoring() {
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
 
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
 
        List<RecordType> rectContract = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCo.size() == 0) {
            return;
        }
        Account myAccount1 = new Account(name='Testaccount001',
                                        Dealer_discount__c =20,
                                        Ban_On_Use_Date__c = Date.today().addDays(1),
                                        Business_Paper_Expiration_Date__c = Date.today().addDays(1),
                                        Tax_Practice_Expiration_Date__c = Date.today().addDays(1),
                                        Medical_Equipment_Expiration_Date__c = Date.today().addDays(1),
                                        RecordTypeId = rectCo[0].Id);
        insert myAccount1;
 
        License_Information__c lic = new License_Information__c();
        lic.name='Test20181204';
        lic.LicenseType__c = '医疗器械经营许可证';
        lic.BusinessLicense__c = '20180522';
        lic.ValidFrom__c = date.newinstance(2018, 05, 22);
        lic.ValidTo__c = date.newinstance(2088, 05, 22);
        lic.Scope3__c = '6815;6822;6823;6825';
        lic.LicenseAndAccount__c = myAccount1.Id;
        insert lic;
        License_Information__c lic1 = new License_Information__c();
        lic1.name='Test20190111';
        lic1.LicenseType__c = '第二类医疗器械经营备案凭证';
        lic1.BusinessLicense__c = '20190522';
        lic1.ValidFrom__c = date.newinstance(2018, 05, 22);
        lic1.ValidTo__c = date.newinstance(2088, 05, 22);
        lic1.Scope__c = '6815;6822;6823;6825';
        lic1.LicenseAndAccount__c = myAccount1.Id;
        insert lic1;
        Test.startTest();
        lic.name='20181204';
        lic.Scope3__c = '';
        lic.BusinessLicense__c = '20180522';
        update lic;
        lic1.Scope__c = '6816;6826;6827;6828';
        update lic1;
        Test.stopTest();
    }
}