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

Commit

Permalink
Extract shared code in integration-tests
Browse files Browse the repository at this point in the history
Each integration-tests that execute a workflow share the same structure:
1. Create a project
2. Verify workflow-definition exists
3. Run a workflow

The projects are created the same and can be placed in a shared location
in which the project creation is part of test initialization.

Signed-off-by: Moti Asayag <masayag@redhat.com>
  • Loading branch information
masayag committed May 22, 2023
1 parent 3893eb5 commit f0317d9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.redhat.parodos.sdk.api.WorkflowDefinitionApi;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.model.ArgumentRequestDTO;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowContextResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
Expand All @@ -31,16 +30,10 @@
@Slf4j
public class ComplexWorkFlowTest extends BaseIntegrationTest {

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

private static final String projectDescription = "an example project";

@Test
public void runComplexWorkFlow() throws ApiException, InterruptedException {
log.info("Running complex flow");

ProjectResponseDTO testProject = SdkUtils.getProjectAsync(apiClient, projectName, projectDescription);

WorkflowApi workflowApi = new WorkflowApi();
log.info("******** Running The Complex WorkFlow ********");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import com.redhat.parodos.flows.base.BaseIntegrationTest;
import com.redhat.parodos.sdk.api.WorkflowApi;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
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 org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

Expand All @@ -21,14 +19,9 @@
@Slf4j
public class EscalationFlowTest extends BaseIntegrationTest {

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

private static final String projectDescription = "an example project";

@Test
public void runEscalationFlow() throws ApiException, InterruptedException {
log.info("Running escalation flow");
ProjectResponseDTO testProject = getProjectAsync(apiClient, projectName, projectDescription);
WorkflowApi workflowApi = new WorkflowApi();

log.info("******** Running The Escalation WorkFlow ********");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.redhat.parodos.sdk.api.WorkflowDefinitionApi;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.model.ArgumentRequestDTO;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdk.model.WorkDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
Expand All @@ -30,18 +29,12 @@
@Slf4j
public class PrebuiltWorkFlowTest extends BaseIntegrationTest {

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

private static final String projectDescription = "an example project";

@Test
public void runPreBuiltWorkFlow() throws ApiException, InterruptedException {
String workFlowName = "prebuiltWorkFlow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW;

log.info("Running pre-built flow (name: {})", workFlowName);

ProjectResponseDTO testProject = SdkUtils.getProjectAsync(apiClient, projectName, projectDescription);

// GET preBuiltWorkFlow DEFINITIONS
WorkflowDefinitionApi workflowDefinitionApi = new WorkflowDefinitionApi(apiClient);
List<WorkFlowDefinitionResponseDTO> prebuiltWorkFlowDefinitions = workflowDefinitionApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.redhat.parodos.sdk.api.WorkflowApi;
import com.redhat.parodos.sdk.api.WorkflowDefinitionApi;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
Expand All @@ -26,16 +25,10 @@
@Slf4j
public class SimpleRollbackWorkFlowTest extends BaseIntegrationTest {

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

private static final String projectDescription = "an example project";

@Test
public void runRollbackWorkFlow() throws ApiException, InterruptedException {
log.info("Running simple flow");

ProjectResponseDTO testProject = SdkUtils.getProjectAsync(apiClient, projectName, projectDescription);

// GET simpleSequentialWorkFlow DEFINITIONS
WorkflowDefinitionApi workflowDefinitionApi = new WorkflowDefinitionApi();
List<WorkFlowDefinitionResponseDTO> simpleFailedWorkFlowDefinitions = workflowDefinitionApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.redhat.parodos.sdk.api.WorkflowDefinitionApi;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.model.ArgumentRequestDTO;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdk.model.WorkDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
Expand All @@ -35,16 +34,10 @@
@Slf4j
public class SimpleWorkFlowTest extends BaseIntegrationTest {

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

private static final String projectDescription = "an example project";

@Test
public void runSimpleWorkFlow() throws ApiException, InterruptedException {
log.info("Running simple flow");

ProjectResponseDTO testProject = SdkUtils.getProjectAsync(apiClient, projectName, projectDescription);

// GET simpleSequentialWorkFlow DEFINITIONS
WorkflowDefinitionApi workflowDefinitionApi = new WorkflowDefinitionApi();
List<WorkFlowDefinitionResponseDTO> simpleSequentialWorkFlowDefinitions = workflowDefinitionApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,35 @@

import com.redhat.parodos.sdk.invoker.ApiClient;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdkutils.SdkUtils;
import org.junit.Before;

import static com.redhat.parodos.sdkutils.SdkUtils.getParodosAPiClient;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* @author Gloria Ciavarrini (Github: gciavarrini)
*/
public class BaseIntegrationTest {

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

private static final String projectDescription = "an example project";

protected ApiClient apiClient;

protected ProjectResponseDTO testProject;

@Before
public void setUp() throws ApiException, InterruptedException {
apiClient = getParodosAPiClient();
initProject();
}

private void initProject() throws ApiException {
this.testProject = SdkUtils.getProjectAsync(apiClient, projectName, projectDescription);
assertNotNull(testProject);
}

}

0 comments on commit f0317d9

Please sign in to comment.