-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectCalloutServiceTest.cls
54 lines (44 loc) · 1.71 KB
/
ProjectCalloutServiceTest.cls
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
public class ProjectCalloutServiceTest {
//Implement mock callout tests here
@isTest public static void successCallout() {
Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMock());
Account a = new Account(Name = 'Test Account');
insert a;
ServiceTokens__c st = new ServiceTokens__c();
st.Name = 'ProjectServiceToken';
st.Token__c = 'testString';
insert st;
Opportunity op = new Opportunity();
op.Name = 'Test Opp';
op.AccountID = a.ID;
op.CloseDate = System.today()+10;
op.Amount = 15000;
op.StageName = 'Prospecting';
Test.startTest();
insert op;
Test.stopTest();
Opportunity opSuccess = [SELECT StageName FROM Opportunity WHERE ID =: op.ID];
System.assertEquals('Submitted Project', opSuccess.StageName);
}
@isTest public static void failureCallout() {
Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMockFailure());
Account a = new Account(Name = 'Test Account');
insert a;
ServiceTokens__c st = new ServiceTokens__c();
st.Name = 'ProjectServiceToken';
st.Token__c = 'testString';
insert st;
Opportunity op = new Opportunity();
op.Name = 'Test Opp';
op.AccountID = a.ID;
op.CloseDate = System.today()+10;
op.Amount = 15000;
op.StageName = 'Prospecting';
Test.startTest();
insert op;
Test.stopTest();
Opportunity opSuccess = [SELECT StageName FROM Opportunity WHERE ID =: op.ID];
System.assertEquals('Resubmit Project', opSuccess.StageName);
}
}