@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);
  }
  @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;
  }
 /**
  * Gets the {@link PaymentTransactionModel} resource which is addressed by current resource
  * request.
  *
  * @see de.hybris.platform.webservices.AbstractYResource#readResource(String)
  */
 @Override
 protected PaymentTransactionModel readResource(final String resourceId) throws Exception {
   PaymentTransactionModel model = new PaymentTransactionModel();
   model.setCode(resourceId);
   return (PaymentTransactionModel) readResourceInternal(model);
 }