@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 testAcceptedAuthorization() { paymentTransactionEntriesList.add(authorizationAccepted); try { final String result = action.execute(process); Assert.assertEquals(OK, result); } catch (final RetryLaterException e) { e.printStackTrace(); fail(); } catch (final Exception e) { e.printStackTrace(); fail(); } }
@Test public void testMultipleReviewAuthorization() { paymentTransactionEntriesList.add(authorizationReview); paymentTransactionEntriesList.add(reviewRejected); paymentTransactionEntriesList.add(authorizationReview); try { final String result = action.execute(process); Assert.assertEquals(WAIT, result); } catch (final RetryLaterException e) { e.printStackTrace(); fail(); } catch (final Exception e) { e.printStackTrace(); fail(); } }