Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Rename test class name to end with Test #345

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 @@ -20,7 +20,6 @@
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import static com.redhat.parodos.sdkutils.SdkUtils.waitWorkflowStatusAsync;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -59,7 +58,7 @@ public void runComplexWorkFlow() throws ApiException, InterruptedException {
log.info("workflow submitted successfully with response: {}", workFlowResponseDTO);

// wait till assessment workflow is completed
WorkFlowStatusResponseDTO workFlowStatusResponseDTO = waitWorkflowStatusAsync(workflowApi,
WorkFlowStatusResponseDTO workFlowStatusResponseDTO = SdkUtils.waitWorkflowStatusAsync(workflowApi,
workFlowResponseDTO.getWorkFlowExecutionId());
assertNotNull(workFlowStatusResponseDTO);
if (workFlowStatusResponseDTO.getStatus() != WorkFlowStatusResponseDTO.StatusEnum.COMPLETED) {
Expand Down Expand Up @@ -111,7 +110,8 @@ public void runComplexWorkFlow() throws ApiException, InterruptedException {
assertEquals(workFlowResponseDTO.getWorkStatus(), WorkStatusEnum.IN_PROGRESS);
log.info("Onboarding workflow execution id: {}", workFlowResponseDTO.getWorkFlowExecutionId());

workFlowStatusResponseDTO = waitWorkflowStatusAsync(workflowApi, workFlowResponseDTO.getWorkFlowExecutionId());
workFlowStatusResponseDTO = SdkUtils.waitWorkflowStatusAsync(workflowApi,
workFlowResponseDTO.getWorkFlowExecutionId());

assertNotNull(workFlowStatusResponseDTO);
assertNotNull(workFlowStatusResponseDTO.getWorkFlowExecutionId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowStatusResponseDTO;
import com.redhat.parodos.sdkutils.SdkUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import static com.redhat.parodos.sdkutils.SdkUtils.getProjectAsync;
import static com.redhat.parodos.sdkutils.SdkUtils.waitWorkflowStatusAsync;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

Expand Down Expand Up @@ -47,7 +47,7 @@ public void runEscalationFlow() throws ApiException, InterruptedException {
log.info("Simple Escalation Flow {}", workFlowResponseDTO.getWorkStatus());
log.info("Waiting for checkers to complete...");

WorkFlowStatusResponseDTO workFlowStatusResponseDTO = waitWorkflowStatusAsync(workflowApi,
WorkFlowStatusResponseDTO workFlowStatusResponseDTO = SdkUtils.waitWorkflowStatusAsync(workflowApi,
workFlowResponseDTO.getWorkFlowExecutionId());

assertNotNull(workFlowStatusResponseDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.redhat.parodos.sdk.model.WorkFlowStatusResponseDTO;
import com.redhat.parodos.sdkutils.SdkUtils;
import com.redhat.parodos.workflow.consts.WorkFlowConstants;
import com.redhat.parodos.workflow.enums.WorkFlowType;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

Expand All @@ -25,7 +24,7 @@
* @author Richard Wang (Github: richrdW98)
*/
@Slf4j
public class SimpleRollbackWorkFlow extends BaseIntegrationTest {
public class SimpleRollbackWorkFlowTest extends BaseIntegrationTest {

private static final String projectName = "project-1";

Expand All @@ -52,7 +51,8 @@ public void runRollbackWorkFlow() throws ApiException, InterruptedException {
simpleSequentialWorkFlowDefinition.getName());
assertEquals(WorkFlowDefinitionResponseDTO.ProcessingTypeEnum.SEQUENTIAL,
simpleSequentialWorkFlowDefinition.getProcessingType());
assertEquals(WorkFlowType.INFRASTRUCTURE.toString(), simpleSequentialWorkFlowDefinition.getType().name());
assertEquals(WorkFlowDefinitionResponseDTO.TypeEnum.INFRASTRUCTURE,
simpleSequentialWorkFlowDefinition.getType());

// Define WorkRequests

Expand All @@ -72,11 +72,11 @@ public void runRollbackWorkFlow() throws ApiException, InterruptedException {
assertEquals(WorkStatusEnum.IN_PROGRESS, workFlowResponseDTO.getWorkStatus());

WorkFlowStatusResponseDTO workFlowStatusResponseDTO = SdkUtils.waitWorkflowStatusAsync(workflowApi,
workFlowResponseDTO.getWorkFlowExecutionId());
workFlowResponseDTO.getWorkFlowExecutionId(), WorkFlowStatusResponseDTO.StatusEnum.FAILED);

assertNotNull(workFlowStatusResponseDTO.getWorkFlowExecutionId());
assertNotNull(workFlowStatusResponseDTO.getStatus());
assertEquals(WorkStatusEnum.FAILED.name(), workFlowStatusResponseDTO.getStatus().name());
assertEquals(WorkFlowStatusResponseDTO.StatusEnum.FAILED, workFlowStatusResponseDTO.getStatus());
log.info("workflow finished successfully with response: {}", workFlowResponseDTO);
log.info("******** Simple Failed Flow Completed ********");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,28 @@ public void execute(@NonNull ApiCallback<List<ProjectResponseDTO>> callback) thr
*/
public static WorkFlowStatusResponseDTO waitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId)
throws InterruptedException, ApiException {
return waitWorkflowStatusAsync(workflowApi, workFlowExecutionId,
WorkFlowStatusResponseDTO.StatusEnum.COMPLETED);
}

/**
* Invokes @see com.redhat.parodos.sdk.api.WorkflowApi#getStatusAsync(String,
* ApiCallback<WorkFlowStatusResponseDTO>) and retries for 60 seconds.
* @param workflowApi the WorkflowAPI
* @param workFlowExecutionId the workflow execution Id to monitor, as {String}
* @param status the status to wait for
* @return the workflow status if it's equal to @see
* com.redhat.parodos.workflows.work.WorkStatus#COMPLETED
* @throws InterruptedException If the async call reaches the waiting timeout
* @throws ApiException If the API method invocation fails
*/
public static WorkFlowStatusResponseDTO waitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId,
WorkFlowStatusResponseDTO.StatusEnum status) throws InterruptedException, ApiException {

WorkFlowStatusResponseDTO workFlowStatusResponseDTO = waitAsyncResponse(new FuncExecutor<>() {
@Override
public boolean check(WorkFlowStatusResponseDTO result, int statusCode) {
return !result.getStatus().equals(WorkFlowStatusResponseDTO.StatusEnum.COMPLETED);
return result.getStatus() != status;
}

@Override
Expand Down