-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathAccountsSimpleApiTest.java
80 lines (69 loc) · 2.85 KB
/
AccountsSimpleApiTest.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
package com.mastercard.openbanking.client.api;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.mastercard.openbanking.client.ApiException;
import com.mastercard.openbanking.client.test.BaseTest;
import com.mastercard.openbanking.client.test.utils.AccountSimpleUtils;
class AccountsSimpleApiTest extends BaseTest {
private final static AccountsSimpleApi api = new AccountsSimpleApi(apiClient);
private static String existingInstitutionLoginId;
private static Long existingInstitutionId;
private static String existingAccountId;
@BeforeAll
protected static void beforeAll() {
try {
// Load existing IDs to be used in the subsequent tests
var existingAccount = AccountSimpleUtils.getCustomerAccountsSimple(api, CUSTOMER_ID).get(0);
existingInstitutionLoginId = existingAccount.getInstitutionLoginId().toString();
existingAccountId = existingAccount.getId();
existingInstitutionId = Long.parseLong(existingAccount.getInstitutionId());
} catch (ApiException e) {
fail(e);
}
}
@Test
void getCustomerAccountsByInstitutionLoginSimpleTest() {
try {
var accounts = api.getCustomerAccountsByInstitutionLoginSimple(CUSTOMER_ID, existingInstitutionLoginId);
assertTrue(accounts.getAccounts().size() > 0);
} catch (ApiException e) {
fail(e);
}
}
@Test
void getCustomerAccountsByInstitutionSimpleTest() {
try {
var accounts = api.getCustomerAccountsByInstitutionSimple(CUSTOMER_ID, existingInstitutionId);
var firstAccount = accounts.getAccounts().get(0);
assertEquals(existingInstitutionId.toString(), firstAccount.getInstitutionId());
} catch (ApiException e) {
fail(e);
}
}
@Test
void getCustomerAccountsSimpleTest() {
try {
var customerAccounts = api.getCustomerAccountsSimple(CUSTOMER_ID);
var accounts = customerAccounts.getAccounts();
assertTrue(accounts.size() > 0);
var firstAccount = accounts.get(0);
assertEquals(CUSTOMER_ID, firstAccount.getCustomerId());
} catch (ApiException e) {
fail(e);
}
}
@Test
void getCustomerAccountSimpleTest() {
try {
var account = api.getCustomerAccountSimple(CUSTOMER_ID, existingAccountId);
assertEquals(existingAccountId, account.getId());
assertEquals(CUSTOMER_ID, account.getCustomerId());
assertNotNull(account);
} catch (ApiException e) {
fail(e);
}
}
}