-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathNotificationVerificationTest.java
More file actions
85 lines (74 loc) · 2.53 KB
/
NotificationVerificationTest.java
File metadata and controls
85 lines (74 loc) · 2.53 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
package com.amazon.pay.impl.ipn;
import com.amazon.pay.exceptions.AmazonClientException;
import com.amazon.pay.response.ipn.model.Notification;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { NotificationVerification.class})
public class NotificationVerificationTest {
private Map<String,String> ipnHeader = new HashMap<String,String>();
private String sampleNotification;
@Before
public void setUp() throws Exception {
ipnHeader.put("x-amz-sns-message-type" , "Notification");
sampleNotification = new NotificationFactoryTest().loadTestFile("AuthorizeNotification.json");
}
/**
* Empty payload and empty header
*/
@Test(expected=AmazonClientException.class)
public void testNullHeaderPayloadIPN() {
NotificationFactory.parseNotification(null, null);
Assert.fail();
}
/**
* Empty header
*/
@Test(expected=AmazonClientException.class)
public void testEmptyHeaderIPN() {
Map<String,String> emptyheader = new HashMap<String,String>();
NotificationFactory.parseNotification(emptyheader, sampleNotification);
Assert.fail();
}
/**
* Null header
*/
@Test(expected=AmazonClientException.class)
public void testNullHeaderIPN() {
NotificationFactory.parseNotification(null, sampleNotification);
Assert.fail();
}
/**
* Incorrect header
*/
@Test(expected=AmazonClientException.class)
public void testBadHeaderIPN() {
Map<String,String> badHeader = new HashMap<String,String>();
badHeader.put("x-amz-sns-message-type" , "Otherr");
NotificationFactory.parseNotification(badHeader, sampleNotification);
Assert.fail();
}
/**
* Null Payload
*/
@Test(expected=AmazonClientException.class)
public void testNullPayloadIPN() {
Notification notification = NotificationFactory.parseNotification(ipnHeader, null);
Assert.fail();
}
/**
* Empty Payload
*/
@Test(expected=AmazonClientException.class)
public void testEmptyPayloadIPN() {
String payload = "";
Notification notification = NotificationFactory.parseNotification(ipnHeader, payload);
Assert.fail();
}
}