-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaseTriggerHandlerTest.cls
More file actions
99 lines (78 loc) · 3.27 KB
/
caseTriggerHandlerTest.cls
File metadata and controls
99 lines (78 loc) · 3.27 KB
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
@isTest
private class caseTriggerHandlerTest {
//tests case with number of positives greater than the threshold
//expected result: case moves to No Man's Queue
@isTest static void caseWithUrlMalicious() {
//create case record with a malicious url in the body
Case caseTest = new Case(
Subject='Test record',
Status='New',
Origin='Phone',
Priority='Medium',
Description='This is the body with bad URL www.google.com',
OwnerId = '00G1H000003tjKe');
insert caseTest;
Set<String> urlSet = new Set<String>{'www.google.com', 'www.example.com'};
Test.setMock(HttpCalloutMock.class, new VTMockClassTestPositiveResponse());
Test.startTest();
scanURLS.checkURLMalicious(urlSet, caseTest.Id);
Test.stopTest();
Case caseOwner = [Select id, OwnerId from Case where Id=: caseTest.Id];
system.assertEquals('00G1H000003tjKjUAI', caseOwner.OwnerId);
}
//tests case with number of positives less than the threshold
//expected result: case moves to general queue
@isTest (seeAllData=true) static void caseWithUrlGood() {
//create case record with a malicious url in the body
Case caseTest = new Case(
Subject='Test record',
Status='New',
Origin='Phone',
Priority='Medium',
Description='This is the body with good URL www.test.com',
OwnerId = '00G1H000003tjKe'
);
insert caseTest;
Set<String> urlSet = new Set<String>{'www.test.com', 'www.example.com'};
Test.setMock(HttpCalloutMock.class, new VTMockClassTestNegativeResponse());
Test.startTest();
scanURLS.checkURLMalicious(urlSet, caseTest.Id);
Test.stopTest();
Case caseOwner = [Select id, OwnerId from Case where Id=: caseTest.Id];
system.assertEquals('00G1H000003tjKy', caseOwner.OwnerId);
}
//tests case with url not found in the system
//expected result: case moves to general queue
@isTest static void CaseWithNoResponse() {
//create case record with a malicious url in the body
Case caseTest = new Case(
Subject='Test record',
Status='New',
Origin='Phone',
Priority='Medium',
Description='This is the body with unknown URL www.test.com',
OwnerId = '00G1H000003tjKe'
);
insert caseTest;
Set<String> urlSet = new Set<String>{'www.test.com', 'www.test.com'};
Test.setMock(HttpCalloutMock.class, new VTMockClassTestZeroResponse());
Test.startTest();
scanURLS.checkURLMalicious(urlSet, caseTest.Id);
Test.stopTest();
Case caseOwner = [Select id, OwnerId from Case where Id=: caseTest.Id];
system.assertEquals('00G1H000003tjKy', caseOwner.OwnerId);
}
//create case record with no urls in the body
//expected result: case moves to general queue
@isTest static void caseWithNoUrls() {
Case caseTest = new Case(
Subject='Test record',
Status='New',
Origin='Phone',
Priority='Medium',
Description='This is the body with no URL');
insert caseTest;
Case caseOwner = [Select id, OwnerId from Case where Id=: caseTest.Id];
system.assertEquals('00G1H000003tjKy', caseOwner.OwnerId);
}
}