@Before public void setUp() throws Exception { // Used for MockitoAnnotations annotations MockitoAnnotations.initMocks(this); action.setModelService(modelService); action.setTicketBusinessService(ticketBusinessService); BDDMockito.given(modelService.create(CsTicketModel.class)).willReturn(new CsTicketModel()); authorizationAccepted = createPaymentTransactionEntry( PaymentTransactionType.AUTHORIZATION, TransactionStatus.ACCEPTED); authorizationReview = createPaymentTransactionEntry( PaymentTransactionType.AUTHORIZATION, TransactionStatus.REVIEW); reviewAccepted = createPaymentTransactionEntry( PaymentTransactionType.REVIEW_DECISION, TransactionStatus.ACCEPTED); reviewRejected = createPaymentTransactionEntry( PaymentTransactionType.REVIEW_DECISION, TransactionStatus.REJECTED); process = new OrderProcessModel(); final OrderModel order = new OrderModel(); process.setOrder(order); final List<PaymentTransactionModel> paymentTransactionList = new ArrayList<PaymentTransactionModel>(); order.setPaymentTransactions(paymentTransactionList); final PaymentTransactionModel paymentTransactionModel = new PaymentTransactionModel(); paymentTransactionList.add(paymentTransactionModel); paymentTransactionEntriesList = new ArrayList<PaymentTransactionEntryModel>(); paymentTransactionModel.setEntries(paymentTransactionEntriesList); }
@Test public void testExecuteActionNOK() 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.REJECTED.name()); paymentTransaction.setEntries(Arrays.asList(entry)); businessProcessModel.setOrder(order); order.setPaymentTransactions(Arrays.asList(paymentTransaction)); Assertions.assertThat(checkAuthorizeOrderPayment.executeAction(businessProcessModel)) .isEqualTo(Transition.NOK); }