buli
2023-07-14 e6068da47c1bef5517c9e5fdc8c726766867ad4e
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@isTest
private class LexSaleAndDeliveryControllerTest {
    @isTest
    static void testInit() {
        User myUser_test;
        Account myAccount2;
        Product2__c pro2;
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs(thisUser) {
            List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'];
            if (rectCo.size() == 0) {
                return;
            }
            Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET Email)'];
            Product2 prod02 = new Product2(
                Name = 'Test02181',
                ProductCode = 'Test0218',
                Asset_Model_No__c = 'Test0218',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                SFDA_Approbation_No__c = 'Test002',
                Packing_list_manual__c = 12,
                SFDA_Expiration_Date__c = Date.today(),
                Category5__c = 'tset8',
                Manual_Entry__c = false
            );
            pro2 = new Product2__c(Name = 'Pro002181', OT_CODE_Text__c = 'Test002181', Product2__c = prod02.Id);
            insert pro2;
            myAccount2 = new Account(name = 'Testaccount003', Dealer_discount__c = 20, RecordTypeId = rectCo[0].Id, AgentCode_Ext__c = '2');
            insert myAccount2;
 
            Contact core = new Contact(email = 'wan@salesforce.com', firstname = 'wan', lastname = 'Plumbers', accountid = myAccount2.id);
            insert core;
            myUser_test = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert myUser_test;
            myUser_test.UserPro_Type__c = '';
            update myUser_test;
        }
        System.runAs(MyUser_Test) {
            String accountId = myUser_test.accountid;
            String agencyProType = myUser_test.UserPro_Type__c;
            String userWorkLocation = myUser_test.Work_Location__c;
            System.Test.startTest();
            LexSaleAndDeliveryController.init();
            LexSaleAndDeliveryController.searchOrderInstatus(
                '2023/01/01',
                '2023/12/31',
                accountId,
                agencyProType,
                userWorkLocation,
                'DB',
                '大连'
            );
            LexSaleAndDeliveryController.searchConsumableorderdetails(
                '2023/01/01',
                '2023/12/31',
                accountId,
                agencyProType,
                userWorkLocation,
                'DB',
                '大连'
            );
            LexSaleAndDeliveryController.searchConsumableorFinish(
                '2023/01/01',
                '2023/12/31',
                accountId,
                agencyProType,
                userWorkLocation,
                'DB',
                '大连'
            );
            LexSaleAndDeliveryController.cleanUp(accountId, agencyProType, userWorkLocation);
            System.Test.stopTest();
        }
    }
}