use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class Accounts2ApiControllerIT method testGetAnAccount.
@Test
public void testGetAnAccount() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_AISP);
FRAccount account = JMockData.mock(FRAccount.class);
frAccountRepository.save(account);
// When
HttpResponse<OBReadAccount2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v2.0/accounts/" + account.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header("x-ob-url", "http://localhost").header("x-ob-permissions", OBExternalPermissions1Code.READACCOUNTSDETAIL.name() + "," + OBExternalPermissions1Code.READPAN.name()).asObject(OBReadAccount2.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getAccount().get(0).getAccountId()).isEqualTo(account.getAccount().getAccountId());
assertThat(response.getBody().getData().getAccount().get(0).getCurrency()).isEqualTo(account.getAccount().getCurrency());
assertThat(response.getBody().getData().getAccount().get(0).getAccountType()).isEqualTo(toOBExternalAccountType1Code(account.getAccount().getAccountType()));
assertThat(response.getBody().getData().getAccount().get(0).getAccount().get(0).getIdentification()).isEqualTo(account.getAccount().getAccounts().get(0).getIdentification());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiControllerIT method testGetAnAccount.
@Test
public void testGetAnAccount() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_AISP);
FRAccount account = JMockData.mock(FRAccount.class);
frAccountRepository.save(account);
// When
HttpResponse<OBReadAccount6> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1.7/aisp/accounts/" + account.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header("x-ob-url", "http://localhost").header("x-ob-permissions", OBExternalPermissions1Code.READACCOUNTSDETAIL.name() + "," + OBExternalPermissions1Code.READPAN.name()).asObject(OBReadAccount6.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
OBAccount6 returnedAccount = response.getBody().getData().getAccount().get(0);
assertThat(returnedAccount).isNotNull();
assertThat(returnedAccount.getAccountId()).isEqualTo(account.getAccount().getAccountId());
assertThat(returnedAccount.getCurrency()).isEqualTo(account.getAccount().getCurrency());
assertThat(returnedAccount.getAccountType()).isEqualTo(toOBExternalAccountType1Code(account.getAccount().getAccountType()));
assertThat(returnedAccount.getAccountSubType()).isEqualTo(toOBExternalAccountSubType1Code(account.getAccount().getAccountSubType()));
assertThat(returnedAccount.getDescription()).isEqualTo(account.getAccount().getDescription());
assertThat(returnedAccount.getNickname()).isEqualTo(account.getAccount().getNickname());
assertThat(returnedAccount.getServicer().getSchemeName()).isEqualTo(account.getAccount().getServicer().getSchemeName());
assertThat(returnedAccount.getServicer().getIdentification()).isEqualTo(account.getAccount().getServicer().getIdentification());
assertThat(returnedAccount.getAccount().get(0).getIdentification()).isEqualTo(account.getAccount().getAccounts().get(0).getIdentification());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class DataApiControllerIT method shouldReturnPayloadTooLargeWhenCreatingNewDataWithDataAlreadySaved.
@Test
public void shouldReturnPayloadTooLargeWhenCreatingNewDataWithDataAlreadySaved() throws Exception {
// Given
OBAccount6 account = new OBAccount6().accountId(UUID.randomUUID().toString());
List<FRAccountData> accountDatas = Collections.singletonList(FRAccountData.builder().account(account).balances(Collections.singletonList(new OBCashBalance1().accountId(account.getAccountId()).type(OBBalanceType1Code.INTERIMAVAILABLE))).build());
FRAccount savedAccount = frAccountRepository.save(FRAccount.builder().id(account.getAccountId()).userID(UUID.randomUUID().toString()).build());
frBalanceRepository.save(FRBalance.builder().accountId(account.getAccountId()).build());
FRUserData userData = new FRUserData();
userData.setAccountDatas(accountDatas);
userData.setUserName(savedAccount.getUserID());
// When
mockMvc.perform(post("/api/data/user").content(mapper.writeValueAsString(userData)).contentType("application/json")).andExpect(status().isPayloadTooLarge());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class FRAccountRepositoryImpl method byAccountId.
@Override
public FRAccount byAccountId(String accountId, List<FRExternalPermissionsCode> permissions) {
Optional<FRAccount> isAccount = accountsRepository.findById(accountId);
if (!isAccount.isPresent()) {
return null;
}
FRAccount account = isAccount.get();
try {
filterAccount(account, permissions);
return account;
} catch (IllegalArgumentException e) {
return null;
}
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticPaymentTaskTest method shouldDebitAccount.
@Test
public void shouldDebitAccount() throws CurrencyConverterException {
// Given
FRDomesticConsent payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
// When
acceptDomesticPaymentTask.autoAcceptPayment();
// Then
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED)));
}
Aggregations