forked from Mastercard/open-banking-us-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaymentsApiTest.java
93 lines (81 loc) · 2.86 KB
/
PaymentsApiTest.java
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
package com.mastercard.finicity.client.api;
import com.mastercard.finicity.client.ApiException;
import com.mastercard.finicity.client.model.CustomerAccount;
import com.mastercard.finicity.client.test.BaseTest;
import com.mastercard.finicity.client.test.utils.AccountUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class PaymentsApiTest extends BaseTest {
private final PaymentsApi api = new PaymentsApi(apiClient);
private static CustomerAccount existingAccount;
@BeforeAll
static void beforeAll() {
try {
var accountApi = new AccountsApi(apiClient);
existingAccount = AccountUtils.getCustomerAccounts(accountApi, CUSTOMER_ID, "savings").get(0);
} catch (ApiException e) {
fail(e);
}
}
@Test
void getAccountACHDetailsTest() {
try {
var achDetails = api.getAccountACHDetails(CUSTOMER_ID, existingAccount.getId());
assertNotNull(achDetails.getRealAccountNumber());
assertNotNull(achDetails.getRoutingNumber());
} catch (ApiException e) {
// {"code":20000,"message":"Routing number not found"}
assertErrorCodeEquals(20000, e);
logApiException(e);
}
}
@Test
void getAvailableBalanceTest() {
try {
var balance = api.getAvailableBalance(CUSTOMER_ID, existingAccount.getId());
assertNotNull(balance.getAvailableBalance());
} catch (ApiException e) {
fail(e);
}
}
@Test
void getAvailableBalanceLiveTest() {
try {
var balance = api.getAvailableBalanceLive(CUSTOMER_ID, existingAccount.getId());
assertNotNull(balance.getAvailableBalance());
} catch (ApiException e) {
fail(e);
}
}
@Test
void getLoanPaymentDetailsTest() {
try {
var existingAccount = AccountUtils.getCustomerAccounts(new AccountsApi(apiClient), CUSTOMER_ID).get(0);
api.getLoanPaymentDetails(CUSTOMER_ID, existingAccount.getId());
fail();
} catch (ApiException e) {
// {"code":14020,"message":"Bad request. (Account type not supported)"}
assertErrorCodeEquals(14020, e);
logApiException(e);
}
}
@Test
void getAccountOwnerTest() {
try {
var owner = api.getAccountOwner(CUSTOMER_ID, existingAccount.getId());
assertNotNull(owner);
} catch (ApiException e) {
fail(e);
}
}
@Test
public void getAccountOwnerDetailsTest() {
try {
var ownerDetails = api.getAccountOwnerDetails(CUSTOMER_ID, existingAccount.getId());
assertNotNull(ownerDetails);
} catch (ApiException e) {
fail(e);
}
}
}