use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class FRAmountConverterTest method toOBFundsConfirmation1DataInstructedAmount.
@Test
public void toOBFundsConfirmation1DataInstructedAmount() {
// Given
FRAmount frAmount = new FRAmount();
frAmount.setAmount(amount);
frAmount.setCurrency(currency);
// When
OBFundsConfirmation1DataInstructedAmount obFundsConfirmation1DataInstructedAmount = FRAmountConverter.toOBFundsConfirmation1DataInstructedAmount(frAmount);
// Then
assertThat(obFundsConfirmation1DataInstructedAmount.getAmount()).isEqualTo(amount);
assertThat(obFundsConfirmation1DataInstructedAmount.getCurrency()).isEqualTo(currency);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class FRAmountConverterTest method OBFundsConfirmation1DataInstructedAmount_toFRAmount.
@Test
public void OBFundsConfirmation1DataInstructedAmount_toFRAmount() {
// Given
OBFundsConfirmation1DataInstructedAmount obFundsConfirmation1DataInstructedAmount = new OBFundsConfirmation1DataInstructedAmount();
obFundsConfirmation1DataInstructedAmount.amount(amount).currency(currency);
// When
FRAmount frAmount = toFRAmount(obFundsConfirmation1DataInstructedAmount);
assertThat(frAmount.getAmount()).isEqualTo(amount);
assertThat(frAmount.getCurrency()).isEqualTo(currency);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticPaymentTaskTest method shouldRejectPaymentWhenCurrencyConversionException.
@Test
public void shouldRejectPaymentWhenCurrencyConversionException() 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);
doThrow(CurrencyConverterException.class).when(moneyService).moveMoney(any(), any(), any(), any(), any());
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.REJECTED)));
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticPaymentTaskTest method shouldCreditAccount.
@Test
public void shouldCreditAccount() throws CurrencyConverterException {
// Given
FRDomesticConsent payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(defaultAccount(DEBIT_ACCOUNT));
FRAccount account = defaultAccount(CREDIT_ACCOUNT);
given(account2StoreService.findAccountByIdentification(CREDIT_ACCOUNT)).willReturn(Optional.of(account));
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
// When
acceptDomesticPaymentTask.autoAcceptPayment();
// Then
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.CREDIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED)));
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptInternationalPaymentTaskTest method shouldCreditAccount.
@Test
public void shouldCreditAccount() throws CurrencyConverterException {
// Given
FRInternationalConsent payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(defaultAccount(DEBIT_ACCOUNT));
FRAccount account = defaultAccount(CREDIT_ACCOUNT);
given(account2StoreService.findAccountByIdentification(CREDIT_ACCOUNT)).willReturn(Optional.of(account));
// When
acceptDomesticPaymentTask.autoAcceptPayment();
// Then
FRAmount amount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(amount), eq(FRCreditDebitIndicator.CREDIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED)));
}
Aggregations