From 02c5d4fd831f0f678a1cfca5a128d5603f3e5e68 Mon Sep 17 00:00:00 2001 From: gabriel-farache Date: Mon, 3 Jul 2023 16:20:47 +0200 Subject: [PATCH] Rework excpetion message while waiting for status --- .../parodos/flows/SimpleRestartWorkFlowTest.java | 10 +++++++--- .../redhat/parodos/sdkutils/WorkFlowServiceUtils.java | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/test/java/com/redhat/parodos/flows/SimpleRestartWorkFlowTest.java b/integration-tests/src/test/java/com/redhat/parodos/flows/SimpleRestartWorkFlowTest.java index 61aa60be6..4465cfc51 100644 --- a/integration-tests/src/test/java/com/redhat/parodos/flows/SimpleRestartWorkFlowTest.java +++ b/integration-tests/src/test/java/com/redhat/parodos/flows/SimpleRestartWorkFlowTest.java @@ -40,7 +40,7 @@ public class SimpleRestartWorkFlowTest { private static final String WORKFLOW_NAME = "onboardingComplexAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW; @Test - public void runRestartNotExistingWorkFlow() { + public void runRestartNotExistingWorkFlow() throws InterruptedException { TestComponents components = new WorkFlowTestBuilder().withDefaultProject().withWorkFlowDefinition(WORKFLOW_NAME) .build(); WorkflowApi workflowApi = new WorkflowApi(components.apiClient()); @@ -49,11 +49,12 @@ public void runRestartNotExistingWorkFlow() { assertThat(assertThrows(ApiException.class, () -> workflowApi.restartWorkFlow(execId))) .hasMessageContaining(String.format("Workflow execution with ID: %s not found", execId)) .hasMessageContaining("HTTP response code: 404"); + Thread.sleep(2000); } @Test - public void runRestartWorkFlow() throws ApiException { + public void runRestartWorkFlow() throws ApiException, InterruptedException { log.info("******** Running the assessment workFlow ********"); TestComponents components = new WorkFlowTestBuilder().withDefaultProject().withWorkFlowDefinition(WORKFLOW_NAME) .build(); @@ -87,11 +88,12 @@ public void runRestartWorkFlow() throws ApiException { log.info("The Following Option Is Available after restart: {}", infrastructureOptionRestarted); assertEquals(infrastructureOption, infrastructureOptionRestarted); + Thread.sleep(2000); } @Test - public void runRestartWorkFlowComplex() throws ApiException { + public void runRestartWorkFlowComplex() throws ApiException, InterruptedException { log.info("******** Running The Complex workFlow ********"); TestComponents components = new WorkFlowTestBuilder().withDefaultProject().withWorkFlowDefinition(WORKFLOW_NAME) .build(); @@ -218,6 +220,7 @@ public void runRestartWorkFlowComplex() throws ApiException { WorkFlowStatusResponseDTO restartedWorkflowStatus = workflowApi .getStatus(restartedWorkFlowStatusResponseDTO.getWorkFlowExecutionId()); assertEquals(workFlowResponseDTO.getWorkFlowExecutionId(), restartedWorkflowStatus.getOriginalExecutionId()); + Thread.sleep(2000); } @Test @@ -355,6 +358,7 @@ public void runRestartWorkFlowComplexMultipleTimes() throws ApiException, Interr assertEquals(workFlowResponseDTO.getWorkFlowExecutionId(), restartedWorkflowStatus.getOriginalExecutionId()); } + Thread.sleep(2000); } @Test diff --git a/sdk-utils/src/main/java/com/redhat/parodos/sdkutils/WorkFlowServiceUtils.java b/sdk-utils/src/main/java/com/redhat/parodos/sdkutils/WorkFlowServiceUtils.java index e6690afb2..75e486ddc 100644 --- a/sdk-utils/src/main/java/com/redhat/parodos/sdkutils/WorkFlowServiceUtils.java +++ b/sdk-utils/src/main/java/com/redhat/parodos/sdkutils/WorkFlowServiceUtils.java @@ -150,7 +150,8 @@ public static WorkFlowStatusResponseDTO waitWorkflowStatusAsync(WorkflowApi work } if (status.getStatus() != expectedStatus) { throw new WrongStatusException( - "Workflow status is not %s, it is %s ".formatted(expectedStatus, status.getStatus())); + "Workflow is finished and its status is %s while was expecting it to be %s" + .formatted(status.getStatus(), expectedStatus)); } return status; };