Skip to content

Commit 81ccb23

Browse files
committed
Updated tests to include routeMinimum testing
1 parent 6921b68 commit 81ccb23

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

src/test/java/ca/paymentrails/paymentrails/integration/BatchTest.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.util.UUID;
88

9+
import org.junit.BeforeClass;
910
import org.junit.Test;
1011
import org.powermock.core.classloader.annotations.PrepareForTest;
1112

@@ -19,8 +20,21 @@
1920
@PrepareForTest(Recipient.class)
2021
public class BatchTest {
2122

23+
private static Configuration config;
24+
25+
@BeforeClass
26+
public static void setupConfig() {
27+
final String ACCESS_KEY = "YourAccessKey";
28+
final String SECRET_KEY = "YourSecretKey";
29+
final String ENVIRONMENT = "production";
30+
31+
// RecipientTest recipientTest = new RecipientTest();
32+
config = new Configuration(ACCESS_KEY, SECRET_KEY, ENVIRONMENT);
33+
}
34+
35+
2236
private Recipient createRecipient() throws Exception {
23-
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
37+
Gateway client = new Gateway(config);
2438

2539
UUID uuid = UUID.randomUUID();
2640

@@ -39,8 +53,7 @@ private Recipient createRecipient() throws Exception {
3953

4054
@Test
4155
public void testCreate() throws Exception {
42-
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
43-
56+
Gateway client = new Gateway(config);
4457

4558
String body = "{\"sourceCurrency\": \"GBP\", \"description\":\"Integration Test Create\"}";
4659
Batch batch = client.batch.create(body);
@@ -49,7 +62,7 @@ public void testCreate() throws Exception {
4962

5063
@Test
5164
public void testUpdate() throws Exception {
52-
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
65+
Gateway client = new Gateway(config);
5366

5467
String body = "{\"sourceCurrency\": \"GBP\", \"description\":\"Integration Test Create\"}";
5568
Batch batch = client.batch.create(body);
@@ -68,8 +81,7 @@ public void testUpdate() throws Exception {
6881

6982
@Test
7083
public void testCreateWithPayments() throws Exception {
71-
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
72-
84+
Gateway client = new Gateway(config);
7385

7486
Recipient recipientAlpha = createRecipient();
7587

@@ -88,8 +100,7 @@ public void testCreateWithPayments() throws Exception {
88100

89101
@Test
90102
public void testPayments() throws Exception {
91-
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
92-
103+
Gateway client = new Gateway(config);
93104

94105
String body = "{\"sourceCurrency\": \"GBP\", \"description\":\"Integration Test Create\"}";
95106
Batch batch = client.batch.create(body);
@@ -110,8 +121,7 @@ public void testPayments() throws Exception {
110121

111122
@Test
112123
public void testProcessing() throws Exception {
113-
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
114-
124+
Gateway client = new Gateway(config);
115125

116126
Recipient recipientAlpha = createRecipient();
117127

src/test/java/ca/paymentrails/paymentrails/integration/RecipientTest.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
import static org.junit.Assert.assertEquals;
55
import static org.junit.Assert.assertNotNull;
6+
import static org.junit.Assert.assertTrue;
67

8+
import org.junit.BeforeClass;
79
import org.junit.Test;
810
import org.powermock.core.classloader.annotations.PrepareForTest;
911

@@ -12,15 +14,30 @@
1214
import ca.paymentrails.paymentrails.RecipientAccount;
1315
import ca.paymentrails.paymentrails.Gateway;
1416

17+
import java.util.ArrayList;
1518
import java.util.List;
1619
import java.util.UUID;
1720

1821
@PrepareForTest(Recipient.class)
1922
public class RecipientTest {
2023

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+
2138
@Test
2239
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);
2441

2542
UUID uuid = UUID.randomUUID();
2643

@@ -36,7 +53,7 @@ public void testCreateRecipient() throws Exception {
3653

3754
@Test
3855
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);
4057

4158
UUID uuid = UUID.randomUUID();
4259

@@ -52,8 +69,8 @@ public void testLifecycle() throws Exception {
5269
boolean response = client.recipient.update(recipient.getId(), body);
5370
assertNotNull(response);
5471

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");
5774

5875
response = client.recipient.delete(recipient.getId());
5976
assertNotNull(response);
@@ -63,8 +80,8 @@ public void testLifecycle() throws Exception {
6380
}
6481

6582
@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);
6885

6986
UUID uuid = UUID.randomUUID();
7087

@@ -97,4 +114,13 @@ public void testAccount() throws Exception {
97114
assertEquals(1, recipientAccounts1.size());
98115
}
99116

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+
}
100126
}

0 commit comments

Comments
 (0)