forked from Mastercard/open-banking-us-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCashFlowApiTest.java
60 lines (52 loc) · 2.23 KB
/
CashFlowApiTest.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
package com.mastercard.finicity.client.api;
import com.mastercard.finicity.client.ApiException;
import com.mastercard.finicity.client.model.CashFlowReportConstraints;
import com.mastercard.finicity.client.test.BaseTest;
import com.mastercard.finicity.client.test.utils.AccountUtils;
import com.mastercard.finicity.client.test.utils.ConsumerUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class CashFlowApiTest extends BaseTest {
private static String customerAccountList;
private final CashFlowApi api = new CashFlowApi(apiClient);
@BeforeAll
protected static void beforeAll() {
try {
// A consumer is required to generate reports
ConsumerUtils.getOrCreateDefaultConsumer(new ConsumersApi(apiClient), CUSTOMER_ID);
// Fetch some accounts IDs to be included in reports
customerAccountList = AccountUtils.getCustomerAccountListString(new AccountsApi(apiClient), CUSTOMER_ID);
} catch (ApiException e) {
fail(e);
}
}
@Test
void generateCashFlowReportBusinessTest() {
try {
var constraints = new CashFlowReportConstraints()
.showNsf(true)
.accountIds(customerAccountList);
var reportAck = api.generateCashFlowBusinessReport(CUSTOMER_ID, constraints, null);
assertEquals("inProgress", reportAck.getStatus());
assertEquals("cfrb", reportAck.getType());
} catch (ApiException e) {
// Status code: 429, Reason: Too Many Requests
logApiException(e);
}
}
@Test
void generateCashFlowReportPersonalTest() {
try {
var constraints = new CashFlowReportConstraints()
.showNsf(true)
.accountIds(customerAccountList);
var reportAck = api.generateCashFlowPersonalReport(CUSTOMER_ID, constraints, null);
assertEquals("inProgress", reportAck.getStatus());
assertEquals("cfrp", reportAck.getType());
} catch (ApiException e) {
// Status code: 429, Reason: Too Many Requests
logApiException(e);
}
}
}