|
16 | 16 |
|
17 | 17 | package com.bytechef.platform.workflow.test.facade; |
18 | 18 |
|
| 19 | +import com.bytechef.platform.workflow.test.dto.ExecutionErrorEventDTO; |
| 20 | +import com.bytechef.platform.workflow.test.dto.JobStatusEventDTO; |
| 21 | +import com.bytechef.platform.workflow.test.dto.TaskStatusEventDTO; |
19 | 22 | import com.bytechef.platform.workflow.test.dto.WorkflowTestExecutionDTO; |
20 | 23 | import java.util.Map; |
| 24 | +import java.util.function.Consumer; |
21 | 25 |
|
22 | 26 | /** |
23 | 27 | * @author Ivica Cardic |
24 | 28 | */ |
25 | 29 | public interface WorkflowTestFacade { |
26 | 30 |
|
| 31 | + /** |
| 32 | + * Tests the execution of a workflow given its identifier, input parameters, and execution environment. |
| 33 | + * |
| 34 | + * @param workflowId The unique identifier of the workflow to be tested. |
| 35 | + * @param inputs A map of input parameters to be supplied to the workflow during execution. |
| 36 | + * @param environmentId The unique identifier of the environment in which the workflow will be executed. |
| 37 | + * @return A {@code WorkflowTestExecutionDTO} object that encapsulates the details of the test execution, including |
| 38 | + * the executed job and any associated trigger execution details. |
| 39 | + */ |
27 | 40 | WorkflowTestExecutionDTO testWorkflow(String workflowId, Map<String, Object> inputs, long environmentId); |
| 41 | + |
| 42 | + /** |
| 43 | + * Initiates the test workflow execution for the specified workflow ID and environment. |
| 44 | + * |
| 45 | + * @param workflowId The unique identifier of the workflow to be tested. |
| 46 | + * @param inputs A map of input parameters required to execute the workflow. |
| 47 | + * @param environmentId The identifier of the environment in which the workflow is to be tested. |
| 48 | + * @return The unique job ID assigned to the test workflow execution. |
| 49 | + */ |
| 50 | + long startTestWorkflow(String workflowId, Map<String, Object> inputs, long environmentId); |
| 51 | + |
| 52 | + /** |
| 53 | + * Waits for the result of a test workflow execution associated with a specific job ID. |
| 54 | + * |
| 55 | + * @param jobId The unique identifier of the job whose test result is being awaited. |
| 56 | + * @return A {@link WorkflowTestExecutionDTO} object containing details about the test execution, including job and |
| 57 | + * trigger execution information. |
| 58 | + */ |
| 59 | + WorkflowTestExecutionDTO awaitTestResult(long jobId); |
| 60 | + |
| 61 | + /** |
| 62 | + * Attempts to stop the running test job with the given job id. |
| 63 | + * |
| 64 | + * @param jobId The job identifier |
| 65 | + */ |
| 66 | + void stopTest(long jobId); |
| 67 | + |
| 68 | + /** |
| 69 | + * Registers a listener to monitor job status updates for a specific job. The listener will be triggered with |
| 70 | + * {@link JobStatusEventDTO} objects whenever the job status changes. |
| 71 | + * |
| 72 | + * @param jobId The unique identifier of the job whose status updates should be monitored. |
| 73 | + * @param listener The consumer that will process {@link JobStatusEventDTO} instances representing job status |
| 74 | + * changes. |
| 75 | + * @return An {@link AutoCloseable} instance that can be used to unregister the listener and stop receiving job |
| 76 | + * status updates. |
| 77 | + */ |
| 78 | + AutoCloseable addJobStatusListener(long jobId, Consumer<JobStatusEventDTO> listener); |
| 79 | + |
| 80 | + /** |
| 81 | + * Registers a listener to monitor task start events for a specific job. The listener will be triggered with |
| 82 | + * {@link TaskStatusEventDTO} objects whenever a task in the given job transitions to the "STARTED" state. |
| 83 | + * |
| 84 | + * @param jobId The unique identifier of the job for which task start events should be monitored. |
| 85 | + * @param listener The consumer that will process {@link TaskStatusEventDTO} instances representing task start |
| 86 | + * events. |
| 87 | + * @return An {@link AutoCloseable} instance that can be used to unregister the listener and stop receiving task |
| 88 | + * start notifications. |
| 89 | + */ |
| 90 | + AutoCloseable addTaskStartedListener(long jobId, Consumer<TaskStatusEventDTO> listener); |
| 91 | + |
| 92 | + /** |
| 93 | + * Registers a listener to monitor task execution completion events for a specific job. The listener will be |
| 94 | + * triggered with {@link TaskStatusEventDTO} objects whenever a task in the given job transitions to the "COMPLETED" |
| 95 | + * state. |
| 96 | + * |
| 97 | + * @param jobId The unique identifier of the job for which task completion events should be monitored. |
| 98 | + * @param listener The consumer that will process {@link TaskStatusEventDTO} instances representing task completion |
| 99 | + * events. |
| 100 | + * @return An {@link AutoCloseable} instance that can be used to unregister the listener and stop receiving task |
| 101 | + * completion notifications. |
| 102 | + */ |
| 103 | + AutoCloseable addTaskExecutionCompleteListener(long jobId, Consumer<TaskStatusEventDTO> listener); |
| 104 | + |
| 105 | + /** |
| 106 | + * Registers a listener to monitor error events for a specific job. The listener will be triggered with |
| 107 | + * {@link ExecutionErrorEventDTO} objects whenever an error occurs during the execution of the specified job. |
| 108 | + * |
| 109 | + * @param jobId The unique identifier of the job for which error events should be monitored. |
| 110 | + * @param listener The consumer that will process {@link ExecutionErrorEventDTO} instances representing execution |
| 111 | + * error events. |
| 112 | + * @return An {@link AutoCloseable} instance that can be used to unregister the listener and stop receiving |
| 113 | + * execution error notifications. |
| 114 | + */ |
| 115 | + AutoCloseable addErrorListener(long jobId, Consumer<ExecutionErrorEventDTO> listener); |
28 | 116 | } |
0 commit comments