Skip to content

Commit

Permalink
Merge pull request #80 from orkes-io/workflow_test_model
Browse files Browse the repository at this point in the history
Update to WorkflowTestRequest for sub-workflow testing
  • Loading branch information
v1r3n authored Feb 10, 2023
2 parents eba3488 + 65c5509 commit 8d679a0
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.orkes.conductor.client.model;

import com.netflix.conductor.common.metadata.tasks.Task;
import com.netflix.conductor.common.metadata.tasks.TaskResult;
import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest;
import lombok.AllArgsConstructor;
Expand All @@ -8,6 +9,7 @@
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
Expand All @@ -17,22 +19,39 @@
public class WorkflowTestRequest extends StartWorkflowRequest {

//Map of task reference name to mock output for the task
private Map<String, List<TaskMock>> taskRefToMockOutput;
private Map<String, List<TaskMock>> taskRefToMockOutput = new HashMap<>();

//If there are sub-workflows inside the workflow
//The map of task reference name to the mock for the sub-workflow
private Map<String, WorkflowTestRequest> subWorkflowTestRequest = new HashMap<>();

@Data
@NoArgsConstructor
@AllArgsConstructor
public static class TaskMock {
private TaskResult.Status status = TaskResult.Status.COMPLETED;
Map<String, Object> output;
private Map<String, Object> output = new HashMap<>();
//Time in millis for the execution of the task.
//Set this value to view the execution timeline view and also trigger any timeouts associated with the tasks
long executionTime;
private long executionTime;

private long queueWaitTime;

public TaskMock(TaskResult.Status status, Map<String, Object> output) {
this.status = status;
this.output = output;
}

public TaskMock(Task.Status status, Map<String, Object> output, long executionTime, long queueWaitTime) {
try {
this.status = TaskResult.Status.valueOf(status.name());
} catch (IllegalArgumentException invalidValue) {
this.status = TaskResult.Status.IN_PROGRESS;
}
this.output = output;
this.executionTime = executionTime;
this.queueWaitTime = queueWaitTime;
}
}

}

0 comments on commit 8d679a0

Please sign in to comment.