ExternalPayloadStorageUtils { @VisibleForTesting void failTask(Task task, PayloadType payloadType, String errorMsg) { logger.error(errorMsg); task.setReasonForIncompletion(errorMsg); task.setStatus(Task.Status.FAILED_WITH_TERMINAL_ERROR); if (payloadType == PayloadType.TASK_INPUT) { task.setInputData(null); } else { task.setOutputData(null); } throw new TerminateWorkflowException(errorMsg, Workflow.WorkflowStatus.FAILED, task); } @Inject  ExternalPayloadStorageUtils(ExternalPayloadStorage externalPayloadStorage,
                                       Configuration configuration,
                                       ObjectMapper objectMapper); @SuppressWarnings("unchecked") Map<String, Object> downloadPayload(String path); void verifyAndUpload(T entity, PayloadType payloadType);  }
@Test public void testFailTaskWithInputPayload() { Task task = new Task(); task.setInputData(new HashMap<>()); expectedException.expect(TerminateWorkflowException.class); externalPayloadStorageUtils.failTask(task, ExternalPayloadStorage.PayloadType.TASK_INPUT, "error"); assertNotNull(task); assertNull(task.getInputData()); }
@Test public void testFailTaskWithOutputPayload() { Task task = new Task(); task.setOutputData(new HashMap<>()); expectedException.expect(TerminateWorkflowException.class); externalPayloadStorageUtils.failTask(task, ExternalPayloadStorage.PayloadType.TASK_OUTPUT, "error"); assertNotNull(task); assertNull(task.getOutputData()); }