use of com.forgerock.openbanking.aspsp.rs.simulator.service.MoneyService in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticScheduledPaymentTaskTest method shouldRejectPaymentWhenCurrencyConversionException.
@Test
public void shouldRejectPaymentWhenCurrencyConversionException() throws CurrencyConverterException {
// Given
FRScheduledPayment payment = defaultPayment(DateTime.now().minusDays(1), ScheduledPaymentStatus.PENDING);
given(paymentsService.getPendingAndDueScheduledPayments()).willReturn(Collections.singletonList(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
doThrow(new CurrencyConverterException("Simulated failure")).when(moneyService).moveMoney(any(), any(), any(), any(), any());
// When
acceptDueScheduledPaymentTask.payDueScheduledPayments();
// Then
verify(moneyService).moveMoney(eq(account), eq(payment.getScheduledPayment().getInstructedAmount()), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updateSchedulePayment(argThat(p -> p.getStatus().equals(ScheduledPaymentStatus.REJECTED)));
assertThat(payment.getRejectionReason()).isEqualTo("Can't convert amount in the right currency: Simulated failure");
}
use of com.forgerock.openbanking.aspsp.rs.simulator.service.MoneyService in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticStandingOrderTaskTest method pendingStandingOrder_finalPaymentDue_shouldDebitAccount.
@Test
public void pendingStandingOrder_finalPaymentDue_shouldDebitAccount() throws CurrencyConverterException {
// Given
FRStandingOrder payment = defaultPayment(StandingOrderStatus.ACTIVE);
payment.getStandingOrder().setNextPaymentDateTime(payment.getStandingOrder().getFinalPaymentDateTime());
given(paymentsService.getActiveStandingOrders()).willReturn(Collections.singletonList(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
// When
acceptDueStandingOrderTask.payDueStandingOrders();
// Then
verify(moneyService).moveMoney(eq(account), any(), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updateStandingOrder(argThat(p -> p.getStatus().equals(StandingOrderStatus.COMPLETED)));
}
use of com.forgerock.openbanking.aspsp.rs.simulator.service.MoneyService in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptInternationalPaymentTaskTest method shouldRejectPaymentWhenCurrencyConversionException.
@Test
public void shouldRejectPaymentWhenCurrencyConversionException() throws CurrencyConverterException {
// Given
FRInternationalConsent 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());
// When
acceptDomesticPaymentTask.autoAcceptPayment();
// Then
FRAmount amount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(amount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.REJECTED)));
}
use of com.forgerock.openbanking.aspsp.rs.simulator.service.MoneyService in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptInternationalPaymentTaskTest method shouldRejectPaymentWhenAnyException.
@Test
public void shouldRejectPaymentWhenAnyException() throws CurrencyConverterException {
// Given
FRInternationalConsent payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
doThrow(new RuntimeException()).when(moneyService).moveMoney(any(), any(), any(), any(), any());
// When
acceptDomesticPaymentTask.autoAcceptPayment();
// Then
FRAmount amount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(amount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.REJECTED)));
}
use of com.forgerock.openbanking.aspsp.rs.simulator.service.MoneyService in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptInternationalPaymentTaskTest method shouldDebitAccount.
@Test
public void shouldDebitAccount() throws CurrencyConverterException {
// Given
FRInternationalConsent payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
// When
acceptDomesticPaymentTask.autoAcceptPayment();
// Then
FRAmount amount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(amount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED)));
}
Aggregations