@Test public void testExecuteActionOK() throws RetryLaterException, Exception { final OrderProcessModel businessProcessModel = new OrderProcessModel(); final OrderModel order = new OrderModel(); final PaymentTransactionModel paymentTransaction = new PaymentTransactionModel(); final PaymentTransactionEntryModel entry = new PaymentTransactionEntryModel(); entry.setType(PaymentTransactionType.AUTHORIZATION); entry.setTransactionStatus(TransactionStatus.ACCEPTED.name()); paymentTransaction.setEntries(Arrays.asList(entry)); businessProcessModel.setOrder(order); order.setPaymentTransactions(Arrays.asList(paymentTransaction)); Assertions.assertThat(checkAuthorizeOrderPayment.executeAction(businessProcessModel)) .isEqualTo(Transition.OK); }
@Override public Transition executeAction(final OrderProcessModel process) { final OrderModel order = process.getOrder(); if (order != null) { if (order.getPaymentInfo() instanceof InvoicePaymentInfoModel) { return Transition.OK; } else { for (final PaymentTransactionModel transaction : order.getPaymentTransactions()) { for (final PaymentTransactionEntryModel entry : transaction.getEntries()) { if (entry.getType().equals(PaymentTransactionType.AUTHORIZATION) && TransactionStatus.ACCEPTED.name().equals(entry.getTransactionStatus())) { order.setStatus(OrderStatus.PAYMENT_AUTHORIZED); modelService.save(order); return Transition.OK; } } } } } return Transition.NOK; }