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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@isTest
public with sharing class OpportunityMessageControllerTest {
 
    static testMethod void myTest1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        Account accIE = new Account(
            Name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c='Customer IE',
            FacilityName__c='abc',
            PostCodeD__c='000000',
            PostCode__c='000000'
        );
        insert accIE; 
        PriceBook2 pricebook =new PriceBook2(
            Name = 'IE'
        );
        insert pricebook;
         
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        // 有预定下单日
        Opportunity opp = new Opportunity(
            Name = 'test opp',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Prospect Created',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            SalesChannel__c = 'direct'
        );
        insert opp;
         //画面迁移--留言画面
        PageReference page = new PageReference('/apex/OpportunityMessagePopUp?raid=' + opp.Id );
        System.Test.setCurrentPage(page);
        
        OpportunityMessageController controller = new OpportunityMessageController();
        
 
        //取得询价
        Opportunity opp1 = [select Id, Name, OCN_Internal_Notes__c from Opportunity where Id = :opp.Id];
 
        //初始化
        controller.init1();
        System.assertEquals('', controller.ra1.OCN_Internal_Notes__c);
        
        //发送按钮
        controller.ra1.OCN_Internal_Notes__c = 'test1';
 
        //保存后
        controller.saveBtn();
    }
 
    static testMethod void myTest2() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        Account accIE = new Account(
            Name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c='Customer IE',
            FacilityName__c='abc',
            PostCodeD__c='000000',
            PostCode__c='000000'
        );
        insert accIE; 
        PriceBook2 pricebook =new PriceBook2(
            Name = 'IE'
        );
        insert pricebook;
         
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        // 有预定下单日
        Opportunity opp = new Opportunity(
            Name = 'test opp',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Prospect Created',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            OCN_Internal_Notes__c = 'test1',
            SalesChannel__c = 'direct'
        );
        insert opp;
         //画面迁移--留言画面
        PageReference page = new PageReference('/apex/OpportunityMessagePopUp?raid=' + opp.Id );
        System.Test.setCurrentPage(page);
        
        OpportunityMessageController controller = new OpportunityMessageController();
        
 
        //取得询价
        Opportunity opp1 = [select Id, Name, OCN_Internal_Notes__c from Opportunity where Id = :opp.Id];
 
        //初始化
        controller.init();
        //System.assertEquals('', controller.ra1.OCN_Internal_Notes__c);
        
        //发送按钮
        controller.ra1 = opp1;
        controller.ra1.OCN_Internal_Notes__c = '';
 
        //保存后
        controller.saveBtn();
    }
}