GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
@isTest
private class OpportunityAAdvancedControllerTest {
    
    static testMethod void testMethod1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        List<RecordType> rectOpp = [select Id from RecordType where IsActive = true and SobjectType = 'Opportunity' and Name = 'SSBD'];
 
        Pricebook2 pricebook = new Pricebook2(
            Name = 'IE',
            ProductSegment__c = 'IE',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            MachineParts__c = 'Machine',
            CurrencyIsoCode = 'CNY'
        );
        insert pricebook;
        Account acc1 = new Account(
            name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer IE',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        insert acc1;
        
        Opportunity opp1 = new Opportunity(
            name = 'test opp1',
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            AccountId = acc1.Id,
            StageName = 'Phase3',
            ProductSegment__c = 'IE',
            CurrencyIsoCode = 'CNY',
            Pricebook2Id = pricebook.Id,
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            Machine_Parts__c = 'Machine',
            //CloseDate = Date.valueof('1900-01-01')
            CloseDate = Date.today().addDays(22),
            ExpectedOrderDate__c = Date.today().addDays(2),
            IE_Custom_Price__c = 1000
        );
        insert opp1;
        PageReference page = new PageReference('/apex/OpportunityAAdvanced?oppid=' + opp1.Id);
        System.Test.setCurrentPage(page);
        OpportunityAAdvancedController controller = new OpportunityAAdvancedController();
        controller.init(); 
        controller.saveLine();  
        
        controller = new OpportunityAAdvancedController(new ApexPages.StandardController(opp1));
        controller.init(); 
    }
}