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
@isTest
private class EmailComeBackListenTest {
    static testMethod void testMethod1() {
 
        User_FaultInfo__c ca = new User_FaultInfo__c();
        ca.ORIGIN__c = 'Web';
        ca.SUBJECT__c = 'test';
        ca.OFFICE_OWNER__c = 'Beijing';
        ca.Product_Type__c = 'NDT';
        ca.TYPE__c = 'Service';
        ca.LOGISTICS_SHIPMENT_TYPE__c = 'Domestic';
        ca.STATUS__c = 'Not Started';
        ca.PRIORITY__c = 'High';
        insert ca;
        User_FaultInfo__c cas = [select Name from User_FaultInfo__c where Id =: ca.Id];
 
        List<String> toAddressesList = new List<String>();
        toAddressesList.add('dai_prectech@olympus.com.cn');
        List<String> ccAddressesList = new List<String>();
        ccAddressesList.add('dai_prectech@olympus.com.cn');
        Messaging.InboundEmail email = new Messaging.InboundEmail();
        email.fromAddress = 'dai_prectech@olympus.com.cn';
        email.toAddresses = toAddressesList; 
        email.ccAddresses = ccAddressesList;
        email.plainTextBody = 'test';
        email.subject = 'test~Ctest:'+cas.Name;
        EmailComeBackListen listen = new EmailComeBackListen();
        listen.handleInboundEmail(email, new Messaging.InboundEnvelope());
        ca.notSaveEmail__c = true;
        update ca;
        listen.handleInboundEmail(email, new Messaging.InboundEnvelope());
    }
    static testMethod void testMethod2() {
 
        SWO__c swo = new SWO__c();
        swo.Name = 'test2';
        swo.QUANTITY__c = 22;
        swo.ESTIMATED_LABOUR_HOURS__c = 22;
        swo.LABOUR_RATE__c = 22;
        insert swo;
 
        List<String> toAddressesList = new List<String>();
        toAddressesList.add('dai_prectech@olympus.com.cn');
        List<String> ccAddressesList = new List<String>();
        ccAddressesList.add('dai_prectech@olympus.com.cn');
        Messaging.InboundEmail email = new Messaging.InboundEmail();
        email.fromAddress = 'dai_prectech@olympus.com.cn';
        email.toAddresses = toAddressesList; 
        email.ccAddresses = ccAddressesList;
        email.plainTextBody = 'test';
        email.subject = 'test~Stest:'+swo.Name;
        EmailComeBackListen listen = new EmailComeBackListen();
        listen.handleInboundEmail(email, new Messaging.InboundEnvelope());
        swo.notSaveEmail__c = true;
        update swo;
        listen.handleInboundEmail(email, new Messaging.InboundEnvelope());
    }
    static testMethod void testMethod3() {
        SWO__c swo = new SWO__c();
        swo.Name = 'test3';
        swo.QUANTITY__c = 22;
        swo.ESTIMATED_LABOUR_HOURS__c = 22;
        swo.LABOUR_RATE__c = 22;
        insert swo;
 
        Quotes__c quotes = new Quotes__c();
        quotes.Name = 'test4';
        quotes.SWO__c = swo.Id;
        quotes.QuotesType__c = '零件报价单';
        insert quotes;
 
        Quotes__c quo = [select Name from Quotes__c where Id =: quotes.Id];
 
        List<String> toAddressesList = new List<String>();
        toAddressesList.add('dai_prectech@olympus.com.cn');
        List<String> ccAddressesList = new List<String>();
        ccAddressesList.add('dai_prectech@olympus.com.cn');
        Messaging.InboundEmail email = new Messaging.InboundEmail();
        email.fromAddress = 'dai_prectech@olympus.com.cn';
        email.toAddresses = toAddressesList; 
        email.ccAddresses = ccAddressesList;
        email.plainTextBody = 'test';
        email.subject = 'test~Qtest:'+quo.Name;
        EmailComeBackListen listen = new EmailComeBackListen();
        listen.handleInboundEmail(email, new Messaging.InboundEnvelope());
        quotes.notSaveEmail__c = true;
        update quotes;
        listen.handleInboundEmail(email, new Messaging.InboundEnvelope());
    }
}