@Test public void testRunFailWithRetry() { final TaskModel taskModelMock = mock(TaskModel.class); final OrderCancelRecordEntryModel orderCancelRecordEntryMock = mock(OrderCancelRecordEntryModel.class); final OrderModificationRecordModel modificationRecordMock = mock(OrderModificationRecordModel.class); final DefaultSendOrderCancelRequestToDataHubHelper cSVHelperMock = mock(DefaultSendOrderCancelRequestToDataHubHelper.class); final TaskService paramTaskService = null; final OrderModel order = new OrderModel(); final ModelService modelService = mock(ModelService.class); when(taskModelMock.getContext()).thenReturn(orderCancelRecordEntryMock); when(orderCancelRecordEntryMock.getModificationRecord()).thenReturn(modificationRecordMock); when(cSVHelperMock.createAndSendRawItem(orderCancelRecordEntryMock)) .thenReturn(new DefaultSendToDataHubResult(HttpStatus.FORBIDDEN, "")); when(modificationRecordMock.getOrder()).thenReturn(order); cut.setModelService(modelService); cut.setOrderCancelRequestCSVHelper(cSVHelperMock); try { cut.run(paramTaskService, taskModelMock); } catch (final RetryLaterException e) { verify(cSVHelperMock).createAndSendRawItem(orderCancelRecordEntryMock); verify(modelService).save(order); assertEquals(OrderStatus.CANCELLING, order.getStatus()); assertEquals(SendOrderCancelRequestAsCSVTaskRunner.DEFAULT_RETRY_DELAY, e.getDelay()); return; } fail("RetryLaterException missing"); }
@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(); } }
protected void assertStep(final BusinessProcessModel process, final String bean) throws InterruptedException { LOG.info("assertStep action = " + bean); try { final ProcessTaskModel processTaskModel = taskServiceStub.runProcessTask(bean); if (processTaskModel == null) { final StringBuffer found = new StringBuffer(); for (final TaskModel task : taskServiceStub.getTasks()) { if (task instanceof ProcessTaskModel) { found.append(((ProcessTaskModel) task).getAction()).append("; "); } } assertNotNull("No task found for bean " + bean + ", action(s): " + found, processTaskModel); } } catch (final RetryLaterException e) { fail(e.toString()); } }