Skip to content

Commit c78cc36

Browse files
committed
Updated testcases
1 parent 4599f29 commit c78cc36

8 files changed

+299
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.mastercard.openbanking.client.api;
2+
3+
import com.mastercard.openbanking.client.ApiException;
4+
import com.mastercard.openbanking.client.model.*;
5+
import com.mastercard.openbanking.client.model.AccountOwnerVerificationMatchResults;
6+
import com.mastercard.openbanking.client.model.AccountOwnerVerificationMatchingRequest;
7+
import com.mastercard.openbanking.client.model.ErrorMessage;
8+
import com.mastercard.openbanking.client.test.ModelFactory;
9+
import com.mastercard.openbanking.client.test.utils.AccountUtils;
10+
11+
import com.mastercard.openbanking.client.test.BaseTest;
12+
import org.junit.jupiter.api.Assertions;
13+
import org.junit.jupiter.api.BeforeAll;
14+
import org.junit.jupiter.api.Test;
15+
16+
import static org.junit.jupiter.api.Assertions.*;
17+
18+
19+
20+
21+
22+
class AccountOwnerMatchingApiTest extends BaseTest {
23+
24+
private final IdentityApi IdentityApi = new IdentityApi();
25+
private final static AccountsApi api = new AccountsApi(apiClient);
26+
private static String existingInstitutionLoginId;
27+
private static Long existingInstitutionId;
28+
private static String existingAccountId;
29+
30+
31+
/**
32+
* Verify and provide additional details about the accounts for which customer has given the consent.
33+
*
34+
* Match and provide scoring details for the claimed account associated with a specific customer in comparision with the user input with the consent given for a account matching information. _Supported regions_: ![🇺🇸](https://flagcdn.com/20x15/us.png)
35+
*
36+
* @throws ApiException if the Api call fails
37+
*/
38+
39+
@BeforeAll
40+
protected static void beforeAll() {
41+
try {
42+
// Load existing IDs to be used in the subsequent tests
43+
var existingAccount = AccountUtils.getCustomerAccounts(api, CUSTOMER_ID).get(0);
44+
existingInstitutionLoginId = existingAccount.getInstitutionLoginId().toString();
45+
existingAccountId = existingAccount.getId();
46+
} catch (ApiException e) {
47+
fail(e);
48+
}
49+
}
50+
51+
@Test
52+
public void accountMatchingScoreDetailsTest() {
53+
54+
try {
55+
var accountownerverificationmatchingrequest = ModelFactory.accountOwnerVerificationMatchingRequest();
56+
Boolean withInsights = false;
57+
58+
var response = IdentityApi.accountMatchingScoreDetails(CUSTOMER_ID, existingAccountId, accountownerverificationmatchingrequest, withInsights);
59+
assertNotNull(response);
60+
}
61+
catch (ApiException e) {
62+
fail(e);
63+
}
64+
}
65+
66+
67+
@Test
68+
public void accountMatchingScoreFirstNameFieldValidations() {
69+
70+
try {
71+
var accountownerverificationmatchingrequest = ModelFactory.accountOwnerVerificationMatchingRequest();
72+
accountownerverificationmatchingrequest.name(new AccountOwnerVerificationMatchingRequestName()
73+
.middleName("MiddleName")
74+
.lastName("LastName")
75+
.suffix("Suffix")
76+
);
77+
Boolean withInsights = false;
78+
AccountOwnerVerificationMatchResults response = IdentityApi.accountMatchingScoreDetails(CUSTOMER_ID, existingAccountId, accountownerverificationmatchingrequest, withInsights);
79+
80+
Assertions.fail();
81+
}
82+
catch (ApiException e) {
83+
logApiException(e);
84+
assertErrorCodeEquals(1002, e);
85+
assertErrorMessageEquals("Improperly Formatted Request Body", e);
86+
}
87+
}
88+
89+
}

tests/src/test/java/com/mastercard/openbanking/client/api/AppRegistrationApiTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ void modifyAppRegistrationTest() {
6161
Assertions.fail(e);
6262
}
6363
}
64-
65-
64+
65+
6666
@Test
6767
void getApplicationsTest() throws ApiException {
6868
try {
@@ -108,7 +108,7 @@ void setCustomerAppIDTest() {
108108
assertErrorMessageEquals("invalid application id", e);
109109
}
110110
}
111-
111+
112112
@Test
113113
void migrateInstitutionLoginAccountsTest() {
114114
try {
@@ -123,6 +123,6 @@ void migrateInstitutionLoginAccountsTest() {
123123
}
124124
}
125125

126-
126+
127127

128128
}

tests/src/test/java/com/mastercard/openbanking/client/api/CashFlowAnalyticsApiTest.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ class CashFlowAnalyticsApiTest extends BaseTest {
1212

1313
private final CustomCashFlowAnalyticsApi api = new CustomCashFlowAnalyticsApi(apiClient);
1414

15-
// @Test
16-
// void generateCashFlowAnalyticsTest() {
17-
// try {
18-
// // Generate the report
19-
// var reportConstraints = new BalanceAndCashFlowAnalyticsReportConstraints();
20-
// var generateResponse = api.generateCashFlowAnalytics(CUSTOMER_ID, reportConstraints, null);
21-
// var reportId = generateResponse.getReportId();
22-
23-
// // Fetch the report as JSON
24-
// var report = api.getObbAnalyticsJsonReport(reportId);
25-
// assertNotNull(report);
26-
27-
// // Fetch the report as PDF
28-
// var pdf = api.getObbAnalyticsPdfReport(reportId);
29-
// assertNotNull(pdf);
30-
// } catch (ApiException e) {
31-
// fail(e);
32-
// }
33-
// }
15+
// @Test
16+
void generateCashFlowAnalyticsTest() {
17+
try {
18+
// Generate the report
19+
var reportConstraints = new BalanceAndCashFlowAnalyticsReportConstraints();
20+
var generateResponse = api.generateCashFlowAnalytics(CUSTOMER_ID, reportConstraints, null);
21+
var reportId = generateResponse.getReportId();
22+
23+
// Fetch the report as JSON
24+
var report = api.getObbAnalyticsJsonReport(reportId);
25+
assertNotNull(report);
26+
27+
// Fetch the report as PDF
28+
var pdf = api.getObbAnalyticsPdfReport(reportId);
29+
assertNotNull(pdf);
30+
} catch (ApiException e) {
31+
fail(e);
32+
}
33+
}
3434

3535
}

tests/src/test/java/com/mastercard/openbanking/client/api/ConnectApiTest.java

+23-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import static org.junit.jupiter.api.Assertions.assertEquals;
1111
import static org.junit.jupiter.api.Assertions.assertTrue;
1212

13+
import java.util.Arrays;
14+
1315
class ConnectApiTest extends BaseTest {
1416

1517
private final ConnectApi api = new ConnectApi(apiClient);
@@ -42,10 +44,10 @@ void generateLiteConnectUrlTest_UnknownCustomerId() {
4244
api.generateLiteConnectUrl(params);
4345
fail();
4446
} catch (ApiException e) {
47+
// {"code":"10010","status":"400","message":"Customer ID does not exist or does not belong to this partner","user_message":"One or more of the fields could not be validated. Please ensure you have entered the correct data.","tags":""}
4548
logApiException(e);
4649
assertErrorCodeEquals("10010", e);
4750
assertErrorMessageEquals("Request failed with status code 404 GET /aggregation/v1/customers/1234", e);
48-
4951
}
5052
}
5153

@@ -206,7 +208,27 @@ void verifyMicroDepositEntryTest() {
206208
fail(e);
207209
}
208210
}
211+
212+
@Test
213+
void generateConnectTransferBillPaySwitchUrlTest() {
214+
try {
215+
var params = new ConnectGenerateTransferBillPaySwitchParameters()
216+
.customerId(CUSTOMER_ID)
217+
.partnerId(PARTNER_ID)
218+
.singleUseUrl(true)
219+
.identity(ModelFactory.newBillPaySwitchIdentity("master", "card", "434 Ascension way", "Salt Lake City", "UT", "84123", "2121234567"))
220+
.cards(Arrays.asList(ModelFactory.newCard("Mastercard Super Card", "4242424242424242", "12/27", "123", "mastercard")));
221+
var connectUrl = api.generateTransferBillPaySwitchUrl(params);
222+
var link = connectUrl.getLink();
223+
assertTrue(link.contains("type=transferBillPaySwitch"));
224+
assertTrue(link.contains("customerId=" + CUSTOMER_ID));
225+
assertTrue(link.contains("partnerId=" + PARTNER_ID));
226+
} catch (ApiException e) {
227+
fail(e);
228+
}
229+
}
209230

231+
210232
@Test
211233
void generateConnectTransferDepositUrlTest() {
212234
try {
@@ -231,4 +253,3 @@ private static String createTestCustomer() throws ApiException {
231253
return customerId;
232254
}
233255
}
234-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.mastercard.openbanking.client.api;
2+
3+
import com.mastercard.openbanking.client.ApiException;
4+
import com.mastercard.openbanking.client.model.CustomerAccount;
5+
import com.mastercard.openbanking.client.model.CustomerUpdate;
6+
import com.mastercard.openbanking.client.test.BaseTest;
7+
import com.mastercard.openbanking.client.test.utils.AccountUtils;
8+
import org.junit.jupiter.api.AfterAll;
9+
import org.junit.jupiter.api.BeforeAll;
10+
import org.junit.jupiter.api.Test;
11+
12+
import java.math.BigDecimal;
13+
import java.time.LocalDate;
14+
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
import static org.junit.jupiter.api.Assertions.assertNotNull;
17+
18+
class FcraPaymentSuccessIndicatorApiTest extends BaseTest {
19+
20+
private final FcraPaymentSuccessIndicatorApi api = new FcraPaymentSuccessIndicatorApi(apiClient);
21+
private static CustomerAccount existingAccount;
22+
23+
24+
@BeforeAll
25+
static void beforeAll() {
26+
try {
27+
var customerApi = new CustomersApi(apiClient);
28+
var customerUpdate = new CustomerUpdate()
29+
.putAdditionalProperty("email", "test@finicity.com");
30+
customerApi.modifyCustomer(CUSTOMER_ID, customerUpdate);
31+
32+
var accountApi = new AccountsApi(apiClient);
33+
// 0 th index account type ROTH does not return any PSS details. Untill fix from API side.
34+
existingAccount = AccountUtils.getCustomerAccounts(accountApi, CUSTOMER_ID).get(1);
35+
} catch (ApiException e) {
36+
fail(e);
37+
}
38+
}
39+
40+
@Test
41+
void getFcraPaymentSuccessIndicatorTest() {
42+
try {
43+
var settlementAmount = new BigDecimal(10);
44+
var response = api.getFCRAPaymentSuccessIndicator(CUSTOMER_ID, existingAccount.getId(),
45+
settlementAmount, LocalDate.now().plusDays(1), "1P");
46+
assertNotNull(response.getPayReqId());
47+
assertNotNull(response.getCustomerId());
48+
assertEquals(CUSTOMER_ID, response.getCustomerId());
49+
} catch (ApiException e) {
50+
fail(e);
51+
}
52+
}
53+
}

tests/src/test/java/com/mastercard/openbanking/client/api/InstitutionsApiTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void getInstitutionsTest() {
108108
var institutions = api.getInstitutions(null, null, null, null, null);
109109
assertTrue(institutions.getFound() > 0);
110110
assertEquals(25, institutions.getDisplaying());
111-
//assertEquals(25, institutions.getInstitutions().size());
111+
//assertEquals(26, institutions.getInstitutions().size());
112112
assertTrue(institutions.getMoreAvailable());
113113
assertNotNull(institutions.getCreatedDate());
114114
} catch (ApiException e) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.mastercard.openbanking.client.api;
2+
3+
import com.mastercard.openbanking.client.ApiException;
4+
import com.mastercard.openbanking.client.model.CustomerAccount;
5+
import com.mastercard.openbanking.client.test.BaseTest;
6+
import com.mastercard.openbanking.client.test.utils.AccountUtils;
7+
import org.junit.jupiter.api.BeforeAll;
8+
import org.junit.jupiter.api.Test;
9+
10+
import java.math.BigDecimal;
11+
import java.time.LocalDate;
12+
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertNotNull;
15+
16+
class PaymentSuccessIndicatorApiTest extends BaseTest {
17+
18+
private final PaymentSuccessIndicatorApi api = new PaymentSuccessIndicatorApi(apiClient);
19+
private static CustomerAccount existingAccount;
20+
21+
@BeforeAll
22+
static void beforeAll() {
23+
try {
24+
var accountApi = new AccountsApi(apiClient);
25+
// 0 th index account type ROTH does not return any PSS details. Untill fix from API side.
26+
existingAccount = AccountUtils.getCustomerAccounts(accountApi, CUSTOMER_ID).get(1);
27+
} catch (ApiException e) {
28+
fail(e);
29+
}
30+
}
31+
32+
@Test
33+
void getPaymentSuccessIndicatorTest() {
34+
try {
35+
var settlementAmount = new BigDecimal(10);
36+
var response = api.getPaymentSuccessIndicator(CUSTOMER_ID, existingAccount.getId(),
37+
settlementAmount, LocalDate.now().plusDays(1));
38+
assertNotNull(response.getPayReqId());
39+
assertNotNull(response.getCustomerId());
40+
assertEquals(CUSTOMER_ID, response.getCustomerId());
41+
} catch (ApiException e) {
42+
fail(e);
43+
}
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Open Banking
3+
* OpenAPI specification for Finicity APIs. Open Banking solutions in the US are provided by Finicity, a Mastercard company.
4+
*
5+
* The version of the OpenAPI document: 1.21.3
6+
* Contact: apisupport@mastercard.com
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package com.mastercard.openbanking.client.api;
15+
16+
import com.mastercard.openbanking.client.ApiException;
17+
import com.mastercard.openbanking.client.model.EnrichTransactionsPayload;
18+
import com.mastercard.openbanking.client.model.EnrichedTransactions;
19+
import com.mastercard.openbanking.client.model.TransactionPayload;
20+
import com.mastercard.openbanking.client.test.BaseTest;
21+
import org.junit.jupiter.api.Disabled;
22+
import org.junit.jupiter.api.Test;
23+
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
27+
import static org.junit.jupiter.api.Assertions.assertNotNull;
28+
29+
/**
30+
* API tests for TransactionDataEnrichmentApi
31+
*/
32+
public class TransactionDataEnrichmentApiTest extends BaseTest {
33+
34+
private static final TransactionDataEnrichmentApi api = new TransactionDataEnrichmentApi(apiClient);
35+
36+
/**
37+
* Performs enrichment of the provided transactions
38+
*
39+
* The operation processes the enclosed transactions for enrichment with categorization and entity recognition. Accepts a batch of 1000 transactions.
40+
*
41+
* @throws ApiException if the Api call fails
42+
*/
43+
@Test
44+
public void enrichTransactionsTest() throws ApiException {
45+
EnrichTransactionsPayload enrichTransactionsPayload = new EnrichTransactionsPayload();
46+
47+
48+
List<TransactionPayload> transactions = new ArrayList<>();
49+
TransactionPayload transactionsPayload = new TransactionPayload();
50+
transactionsPayload.setExternalCustomerId(CUSTOMER_ID);
51+
transactionsPayload.setAccountType("unknown");
52+
transactionsPayload.setExternalTransactionId("MAC18970265");
53+
transactionsPayload.setDescription("Test");
54+
transactionsPayload.setAmount(1.0);
55+
transactions.add(transactionsPayload);
56+
enrichTransactionsPayload.setTransactions(transactions);
57+
58+
EnrichedTransactions response = api.enrichTransactions(enrichTransactionsPayload);
59+
assertNotNull(response);
60+
assertNotNull(response.getTransactions());
61+
assertNotNull(response.getTransactions().get(0).getExternalCustomerId());
62+
assertNotNull(response.getTransactions().get(0).getAccountType());
63+
}
64+
65+
}

0 commit comments

Comments
 (0)