Skip to content

Commit b91a074

Browse files
authored
Merge pull request #333 from conductor-oss/fix/add-test-workflow-method
Add testWorkflow to OrkesWorkflowClient
2 parents 1259a4a + a6be214 commit b91a074

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

conductor-clients/java/conductor-java-sdk/orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.netflix.conductor.common.run.SearchResult;
3737
import com.netflix.conductor.common.run.Workflow;
3838
import com.netflix.conductor.common.run.WorkflowSummary;
39+
import com.netflix.conductor.common.run.WorkflowTestRequest;
3940

4041
import io.orkes.conductor.client.model.CorrelationIdsSearchRequest;
4142
import io.orkes.conductor.client.model.WorkflowRun;
@@ -202,6 +203,10 @@ public void skipTaskFromWorkflow(String workflowId, String taskReferenceName) {
202203
workflowClient.skipTaskFromWorkflow(workflowId, taskReferenceName);
203204
}
204205

206+
public Workflow testWorkflow(WorkflowTestRequest testRequest) {
207+
return workflowClient.testWorkflow(testRequest);
208+
}
209+
205210
public SearchResult<WorkflowSummary> search(String query) {
206211
return workflowClient.search(query);
207212
}

conductor-clients/java/conductor-java-sdk/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java

+25
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import java.util.concurrent.TimeUnit;
1717
import java.util.stream.Collectors;
1818

19+
import com.netflix.conductor.common.metadata.tasks.TaskResult;
20+
import com.netflix.conductor.common.metadata.workflow.WorkflowTask;
21+
import com.netflix.conductor.common.run.WorkflowTestRequest;
1922
import org.junit.jupiter.api.Assertions;
2023
import org.junit.jupiter.api.BeforeAll;
2124
import org.junit.jupiter.api.Test;
@@ -184,6 +187,28 @@ void testExecuteWorkflow() {
184187
// TODO
185188
}
186189

190+
@Test
191+
void testWorkflow() {
192+
WorkflowTask task = new WorkflowTask();
193+
task.setName("testable-task");
194+
task.setTaskReferenceName("testable-task-ref");
195+
196+
WorkflowDef workflowDef = new WorkflowDef();
197+
workflowDef.setName("testable-flow");
198+
workflowDef.setTasks(List.of(task));
199+
200+
WorkflowTestRequest testRequest = new WorkflowTestRequest();
201+
testRequest.setName("testable-flow");
202+
testRequest.setWorkflowDef(workflowDef);
203+
testRequest.setTaskRefToMockOutput(Map.of(
204+
"testable-task-ref",
205+
List.of(new WorkflowTestRequest.TaskMock(TaskResult.Status.COMPLETED, Map.of("result", "ok")))
206+
));
207+
208+
Workflow workflow = workflowClient.testWorkflow(testRequest);
209+
Assertions.assertEquals("ok", workflow.getOutput().get("result"));
210+
}
211+
187212
StartWorkflowRequest getStartWorkflowRequest() {
188213
StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest();
189214
startWorkflowRequest.setName(Commons.WORKFLOW_NAME);

0 commit comments

Comments
 (0)