diff --git a/conductor-clients/java/conductor-java-sdk/orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/conductor-clients/java/conductor-java-sdk/orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index 0b47c6ff3..c98bc9e68 100644 --- a/conductor-clients/java/conductor-java-sdk/orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/conductor-clients/java/conductor-java-sdk/orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import com.netflix.conductor.common.run.WorkflowTestRequest; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.concurrent.BasicThreadFactory; @@ -202,6 +203,10 @@ public void skipTaskFromWorkflow(String workflowId, String taskReferenceName) { workflowClient.skipTaskFromWorkflow(workflowId, taskReferenceName); } + public Workflow testWorkflow(WorkflowTestRequest testRequest) { + return workflowClient.testWorkflow(testRequest); + } + public SearchResult search(String query) { return workflowClient.search(query); } diff --git a/conductor-clients/java/conductor-java-sdk/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java b/conductor-clients/java/conductor-java-sdk/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java index 465ec03b8..9cc149f9d 100644 --- a/conductor-clients/java/conductor-java-sdk/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java +++ b/conductor-clients/java/conductor-java-sdk/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java @@ -16,6 +16,9 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import com.netflix.conductor.common.metadata.tasks.TaskResult; +import com.netflix.conductor.common.metadata.workflow.WorkflowTask; +import com.netflix.conductor.common.run.WorkflowTestRequest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -184,6 +187,28 @@ void testExecuteWorkflow() { // TODO } + @Test + void testWorkflow() { + WorkflowDef workflowDef = new WorkflowDef(); + workflowDef.setName("testable-flow"); + WorkflowTask task = new WorkflowTask(); + task.setName("testable-task"); + task.setTaskReferenceName("testable-task-ref"); + List tasks = List.of(task); + workflowDef.setTasks(tasks); + + WorkflowTestRequest testRequest = new WorkflowTestRequest(); + testRequest.setWorkflowDef(workflowDef); + testRequest.setName("testable-flow"); + testRequest.setTaskRefToMockOutput(Map.of( + "testable-task-ref", + List.of(new WorkflowTestRequest.TaskMock(TaskResult.Status.COMPLETED, Map.of("result", "ok"))) + )); + Workflow workflow = workflowClient.testWorkflow(testRequest); + Assertions.assertNotNull(workflow); + Assertions.assertEquals("ok", workflow.getOutput().get("result")); + } + StartWorkflowRequest getStartWorkflowRequest() { StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest(); startWorkflowRequest.setName(Commons.WORKFLOW_NAME);