@SuppressWarnings("unchecked")
@Test
public void testUploadWorkflowPayload() throws IOException {

    AtomicInteger uploadCount = new AtomicInteger(0);
    InputStream stream = ExternalPayloadStorageUtilsTest.class.getResourceAsStream("/payload.json");
    Map<String, Object> payload = objectMapper.readValue(stream, Map.class);
    when(externalPayloadStorage.getLocation(ExternalPayloadStorage.Operation.WRITE, ExternalPayloadStorage.PayloadType.WORKFLOW_OUTPUT, "")).thenReturn(location);
    doAnswer(invocation -> {
        uploadCount.incrementAndGet();
        return null;
    }).when(externalPayloadStorage).upload(anyString(), any(), anyLong());
    Workflow workflow = new Workflow();
    workflow.setOutput(payload);
    externalPayloadStorageUtils.verifyAndUpload(workflow, ExternalPayloadStorage.PayloadType.WORKFLOW_OUTPUT);
    assertNull(workflow.getOutput());
    assertEquals(1, uploadCount.get());
    assertNotNull(workflow.getExternalOutputPayloadStoragePath());
}