use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldDebitAccount.
@Test
public void shouldDebitAccount() throws CurrencyConverterException {
// Given
FRPaymentSetup payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
// When
autoAcceptPaymentTask.autoAcceptPayment();
// Then
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), 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 MoneyServiceTest method shouldCreateTransaction.
@Test
public void shouldCreateTransaction() throws CurrencyConverterException {
// Given
FRBalance balance = defaultBalance(DEBIT_ACCOUNT, "20");
given(balanceStoreService.getBalance(DEBIT_ACCOUNT, OBBalanceType1Code.INTERIMAVAILABLE)).willReturn(Optional.of(balance));
CreateTransaction<FRPaymentSetup> createTransaction = mock(CreateTransaction.class);
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
FRPaymentSetup payment = new FRPaymentSetup();
FRTransaction transaction = JMockData.mock(FRTransaction.class);
FRAmount amount = defaultAmount();
given(createTransaction.createTransaction(account, payment, FRCreditDebitIndicator.DEBIT, balance, amount)).willReturn(transaction);
// When
moneyService.moveMoney(account, amount, FRCreditDebitIndicator.DEBIT, payment, createTransaction);
// Then
verify(transactionStoreService).create(transaction);
}
Aggregations