use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticPaymentTaskTest method shouldRejectPaymentWhenAnyException.
@Test
public void shouldRejectPaymentWhenAnyException() 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(new RuntimeException()).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 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.common.model.openbanking.domain.common.FRAmount 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.common.model.openbanking.domain.common.FRAmount 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)));
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldCreditAccount.
@Test
public void shouldCreditAccount() throws CurrencyConverterException {
// Given
FRPaymentSetup 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
autoAcceptPaymentTask.autoAcceptPayment();
// Then
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.CREDIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED)));
}
Aggregations