|
22 | 22 | import io.dapr.workflows.client.WorkflowInstanceStatus;
|
23 | 23 | import io.dapr.workflows.client.WorkflowRuntimeStatus;
|
24 | 24 | import io.dapr.config.Properties;
|
25 |
| -import net.bytebuddy.utility.dispatcher.JavaDispatcher; |
| 25 | +import io.dapr.workflows.client.WorkflowState; |
26 | 26 | import org.junit.jupiter.api.Tag;
|
27 | 27 | import org.junit.jupiter.api.Test;
|
28 | 28 | import org.testcontainers.containers.Network;
|
@@ -177,7 +177,46 @@ public void testMultiAppWorkflow() throws Exception {
|
177 | 177 | assertNotNull(instanceId, "Workflow instance ID should not be null");
|
178 | 178 | workflowClient.waitForWorkflowStart(instanceId, Duration.ofSeconds(30), false);
|
179 | 179 |
|
180 |
| - WorkflowInstanceStatus workflowStatus = workflowClient.waitForWorkflowCompletion(instanceId, null, true); |
| 180 | + WorkflowState workflowStatus = workflowClient.waitForWorkflowCompletion(instanceId, null, true); |
| 181 | + assertNotNull(workflowStatus, "Workflow status should not be null"); |
| 182 | + assertEquals(WorkflowRuntimeStatus.COMPLETED, workflowStatus.getRuntimeStatus(), |
| 183 | + "Workflow should complete successfully"); |
| 184 | + String workflowOutput = workflowStatus.readOutputAs(String.class); |
| 185 | + assertEquals(expectedOutput, workflowOutput, "Workflow output should match expected result"); |
| 186 | + } finally { |
| 187 | + workflowClient.close(); |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * It duplicates the {@link #testMultiAppWorkflow()} due to deprecated APIs. |
| 193 | + * It must be deleted after {@link WorkflowInstanceStatus} be removed. |
| 194 | + */ |
| 195 | + @Test |
| 196 | + @Deprecated(forRemoval = true) |
| 197 | + public void testMultiAppWorkflowOldApi() throws Exception { |
| 198 | + // TestContainers wait strategies ensure all containers are ready before this test runs |
| 199 | + |
| 200 | + String input = "Hello World"; |
| 201 | + String expectedOutput = "HELLO WORLD [TRANSFORMED BY APP2] [FINALIZED BY APP3]"; |
| 202 | + |
| 203 | + // Create workflow client connected to the main workflow orchestrator |
| 204 | + // Use the same endpoint configuration that the workers use |
| 205 | + // The workers use host.testcontainers.internal:50001 |
| 206 | + Map<String, String> propertyOverrides = Map.of( |
| 207 | + "dapr.grpc.endpoint", MAIN_WORKFLOW_SIDECAR.getGrpcEndpoint(), |
| 208 | + "dapr.http.endpoint", MAIN_WORKFLOW_SIDECAR.getHttpEndpoint() |
| 209 | + ); |
| 210 | + |
| 211 | + Properties clientProperties = new Properties(propertyOverrides); |
| 212 | + DaprWorkflowClient workflowClient = new DaprWorkflowClient(clientProperties); |
| 213 | + |
| 214 | + try { |
| 215 | + String instanceId = workflowClient.scheduleNewWorkflow(MultiAppWorkflow.class, input); |
| 216 | + assertNotNull(instanceId, "Workflow instance ID should not be null"); |
| 217 | + workflowClient.waitForWorkflowStart(instanceId, Duration.ofSeconds(30), false); |
| 218 | + |
| 219 | + WorkflowInstanceStatus workflowStatus = workflowClient.waitForInstanceCompletion(instanceId, null, true); |
181 | 220 | assertNotNull(workflowStatus, "Workflow status should not be null");
|
182 | 221 | assertEquals(WorkflowRuntimeStatus.COMPLETED, workflowStatus.getRuntimeStatus(),
|
183 | 222 | "Workflow should complete successfully");
|
|
0 commit comments