Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testWorkflow to OrkesWorkflowClient #333

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.netflix.conductor.common.run.SearchResult;
import com.netflix.conductor.common.run.Workflow;
import com.netflix.conductor.common.run.WorkflowSummary;
import com.netflix.conductor.common.run.WorkflowTestRequest;

import io.orkes.conductor.client.model.CorrelationIdsSearchRequest;
import io.orkes.conductor.client.model.WorkflowRun;
Expand Down Expand Up @@ -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<WorkflowSummary> search(String query) {
return workflowClient.search(query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -184,6 +187,28 @@ void testExecuteWorkflow() {
// TODO
}

@Test
void testWorkflow() {
WorkflowTask task = new WorkflowTask();
task.setName("testable-task");
task.setTaskReferenceName("testable-task-ref");

WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("testable-flow");
workflowDef.setTasks(List.of(task));

WorkflowTestRequest testRequest = new WorkflowTestRequest();
testRequest.setName("testable-flow");
testRequest.setWorkflowDef(workflowDef);
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.assertEquals("ok", workflow.getOutput().get("result"));
}

StartWorkflowRequest getStartWorkflowRequest() {
StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest();
startWorkflowRequest.setName(Commons.WORKFLOW_NAME);
Expand Down
Loading