DefaultPaymentTransactionRejectionStrategy implements PaymentTransactionRejectionStrategy { @Override public void executeRejection(final PaymentTransactionModel paymentTransactionModel) { rejectTransactionEntries(paymentTransactionModel); wakeUpBusinessProcess(paymentTransactionModel.getOrder()); }  @Override void executeRejection(final PaymentTransactionModel paymentTransactionModel); @Required void setModelService(ModelService modelService); @Required void setWorldpayPaymentTransactionService(WorldpayPaymentTransactionService worldpayPaymentTransactionService); @Required void setProcessDefinitionDao(ProcessDefinitionDao processDefinitionDao); @Required void setBusinessProcessService(BusinessProcessService businessProcessService);  }
@Test public void testExecuteRejection() throws Exception { when(paymentTransactionModelMock.getOrder()).thenReturn(orderModelMock); when(processDefinitionDaoMock.findWaitingOrderProcesses(orderModelMock.getCode(), AUTHORIZATION)).thenReturn(Collections.singletonList(businessProcessModelMock)); when(businessProcessModelMock.getCode()).thenReturn(BUSINESS_PROCESS_CODE); testObj.executeRejection(paymentTransactionModelMock); verify(worldpayPaymentTransactionServiceMock).updateEntriesStatus(paymentTransactionModelMock.getEntries(), REJECTED.name()); verify(modelServiceMock).save(paymentTransactionModelMock); verify(businessProcessServiceMock).triggerEvent(BUSINESS_PROCESS_CODE + "_" + AUTHORIZATION); }
@Test public void testExecuteRejectionShouldNotTriggerABusinessProcessWhenNoneFound() throws Exception { when(paymentTransactionModelMock.getOrder()).thenReturn(orderModelMock); when(processDefinitionDaoMock.findWaitingOrderProcesses(orderModelMock.getCode(), AUTHORIZATION)).thenReturn(Collections.<BusinessProcessModel>emptyList()); testObj.executeRejection(paymentTransactionModelMock); verify(worldpayPaymentTransactionServiceMock).updateEntriesStatus(paymentTransactionModelMock.getEntries(), REJECTED.name()); verify(modelServiceMock).save(paymentTransactionModelMock); verify(businessProcessServiceMock, never()).triggerEvent(anyString()); }