|
| 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_:  |
| 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 | + } |
0 commit comments