3
3
4
4
import static org .junit .Assert .assertEquals ;
5
5
import static org .junit .Assert .assertNotNull ;
6
+ import static org .junit .Assert .assertTrue ;
6
7
8
+ import org .junit .BeforeClass ;
7
9
import org .junit .Test ;
8
10
import org .powermock .core .classloader .annotations .PrepareForTest ;
9
11
12
14
import ca .paymentrails .paymentrails .RecipientAccount ;
13
15
import ca .paymentrails .paymentrails .Gateway ;
14
16
17
+ import java .util .ArrayList ;
15
18
import java .util .List ;
16
19
import java .util .UUID ;
17
20
18
21
@ PrepareForTest (Recipient .class )
19
22
public class RecipientTest {
20
23
24
+ // Testing order: alphabetical
25
+
26
+ private static Configuration config ;
27
+
28
+ @ BeforeClass
29
+ public static void setupConfig () {
30
+ final String ACCESS_KEY = "YourAccessKey" ;
31
+ final String SECRET_KEY = "YourSecretKey" ;
32
+ final String ENVIRONMENT = "production" ;
33
+
34
+ // RecipientTest recipientTest = new RecipientTest();
35
+ config = new Configuration (ACCESS_KEY , SECRET_KEY , ENVIRONMENT );
36
+ }
37
+
21
38
@ Test
22
39
public void testCreateRecipient () throws Exception {
23
- Gateway client = new Gateway (new Configuration ( "YOUR-API-KEY" , "YOUR-API-KEY" , "production" ) );
40
+ Gateway client = new Gateway (config );
24
41
25
42
UUID uuid = UUID .randomUUID ();
26
43
@@ -36,7 +53,7 @@ public void testCreateRecipient() throws Exception {
36
53
37
54
@ Test
38
55
public void testLifecycle () throws Exception {
39
- Gateway client = new Gateway (new Configuration ( "YOUR-API-KEY" , "YOUR-API-KEY" , "production" ) );
56
+ Gateway client = new Gateway (config );
40
57
41
58
UUID uuid = UUID .randomUUID ();
42
59
@@ -52,8 +69,8 @@ public void testLifecycle() throws Exception {
52
69
boolean response = client .recipient .update (recipient .getId (), body );
53
70
assertNotNull (response );
54
71
55
- Recipient anotheRecipient = client .recipient .find (recipient .getId ());
56
- assertEquals (anotheRecipient .getFirstName (), "Bob" );
72
+ Recipient anotherRecipient = client .recipient .find (recipient .getId ());
73
+ assertEquals (anotherRecipient .getFirstName (), "Bob" );
57
74
58
75
response = client .recipient .delete (recipient .getId ());
59
76
assertNotNull (response );
@@ -63,8 +80,8 @@ public void testLifecycle() throws Exception {
63
80
}
64
81
65
82
@ Test
66
- public void testAccount () throws Exception {
67
- Gateway client = new Gateway (new Configuration ( "YOUR-API-KEY" , "YOUR-API-KEY" , "production" ) );
83
+ public void testRecipientAccount () throws Exception {
84
+ Gateway client = new Gateway (config );
68
85
69
86
UUID uuid = UUID .randomUUID ();
70
87
@@ -97,4 +114,13 @@ public void testAccount() throws Exception {
97
114
assertEquals (1 , recipientAccounts1 .size ());
98
115
}
99
116
117
+ @ Test
118
+ public void testRecipientRouteMinimum () throws Exception {
119
+ Gateway client = new Gateway (config );
120
+ ArrayList <Recipient > recipients = (ArrayList )client .recipient .search (1 ,20 ,"" );
121
+ //Making sure routeMinimum is not null before asserting it's value
122
+ assertNotNull (recipients .get (0 ).getRouteMinimum ());
123
+ //Making sure routeMinium is set to a non-null value
124
+ assertTrue (Integer .parseInt (recipients .get (0 ).getRouteMinimum ()) >= 0 );
125
+ }
100
126
}
0 commit comments