### Question:
WirecardTakePaymentAction extends AbstractSimpleDecisionAction<OrderProcessModel> { @Override public Transition executeAction(final OrderProcessModel process) { final OrderModel order = process.getOrder(); LOG.info(START_MESSAGE, order.getCode()); ImpersonationContext context = new ImpersonationContext(); context.setOrder(order); context.setUser(order.getUser()); context.setLanguage(order.getUser().getSessionLanguage()); context.setCurrency(order.getCurrency()); context.setSite(order.getSite()); OrderStatus orderStatus = impersonationService.executeInContext( context, (ImpersonationService.Executor<OrderStatus, ImpersonationService.Nothing>) () -> { i18NService.setLocalizationFallbackEnabled(true); return wirecardPOExecutionService.executePaymentCaptureOperation(order, null); }); Transition result = Transition.NOK; if (orderStatus != null && orderStatus.getCode() != null) { if (OrderStatus.PAYMENT_CAPTURED.getCode().equals(orderStatus.getCode())) { result = Transition.OK; LOG.info(STATUS_MESSAGE, order.getCode(), orderStatus.getCode()); } } else { LOG.error(NULL_ERROR_MESSAGE); } setOrderStatus(order, orderStatus); return result; }  @Override Transition executeAction(final OrderProcessModel process); @Required void setWirecardPOExecutionService(WirecardPOExecutionService wirecardPaymentOperationExecution); @Required void setImpersonationService(ImpersonationService impersonationService); @Required void setI18NService(I18NService i18NService);  }### Answer:
@Test public void executeActionTestSuccess() { try{ when(impersonationService.executeInContext(Mockito.anyObject(), Mockito.anyObject())).thenReturn(OrderStatus.PAYMENT_CAPTURED); }catch(Throwable t){ fail("IDK probably should not throw that throwable"); } AbstractSimpleDecisionAction.Transition transition; transition = wirecardTakePaymentAction.executeAction(orderProcessModel); assertEquals("The transition is not correct", transition, AbstractSimpleDecisionAction.Transition.OK); }
@Test public void executeActionTestFailed() { AbstractSimpleDecisionAction.Transition transition; try{ when(impersonationService.executeInContext(Mockito.anyObject(), Mockito.anyObject())).thenReturn(OrderStatus.CANCELLED); }catch(Throwable t){ fail("IDK probably should not throw that throwable"); } transition = wirecardTakePaymentAction.executeAction(orderProcessModel); assertEquals("The transition should return NOK", transition, AbstractSimpleDecisionAction.Transition.NOK); }