Commit 91277895 authored by Aalekh Jain's avatar Aalekh Jain
Browse files

Added method to create and delete system workflow in testbase

Minor refactoring
parent fb9869d1
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.opengroup.osdu.workflow.util.v3; package org.opengroup.osdu.workflow.util.v3;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -34,6 +35,7 @@ import java.util.concurrent.Callable; ...@@ -34,6 +35,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_SYSTEM_WORKFLOW_URL;
import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_RUN_URL; import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_RUN_URL;
import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_URL; import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_URL;
import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_WORKFLOW_NAME; import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_WORKFLOW_NAME;
...@@ -71,6 +73,18 @@ public abstract class TestBase { ...@@ -71,6 +73,18 @@ public abstract class TestBase {
return response.getEntity(String.class); return response.getEntity(String.class);
} }
protected String createSystemWorkflow() throws Exception {
ClientResponse response = client.send(
HttpMethod.POST,
CREATE_SYSTEM_WORKFLOW_URL,
buildCreateWorkflowValidPayload(),
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.OK.value(), response.getStatus());
return response.getEntity(String.class);
}
protected String createWorkflowRun() throws Exception { protected String createWorkflowRun() throws Exception {
ClientResponse response = client.send( ClientResponse response = client.send(
HttpMethod.POST, HttpMethod.POST,
...@@ -98,6 +112,12 @@ public abstract class TestBase { ...@@ -98,6 +112,12 @@ public abstract class TestBase {
sendDeleteRequest(url); sendDeleteRequest(url);
} }
protected void deleteTestSystemWorkflows(String workflowName) throws Exception {
String url = CREATE_SYSTEM_WORKFLOW_URL + "/" + workflowName;
sendDeleteRequest(url);
}
protected void waitForWorkflowRunsToComplete(List<Map<String, String>> createdWorkflowRuns, protected void waitForWorkflowRunsToComplete(List<Map<String, String>> createdWorkflowRuns,
Set<String> completedWorkflowRunIds) throws Exception { Set<String> completedWorkflowRunIds) throws Exception {
for(Map<String, String> createdWorkflow: createdWorkflowRuns) { for(Map<String, String> createdWorkflow: createdWorkflowRuns) {
...@@ -188,4 +208,8 @@ public abstract class TestBase { ...@@ -188,4 +208,8 @@ public abstract class TestBase {
log.info("Completed integration test at {}", integrationTestEndTime); log.info("Completed integration test at {}", integrationTestEndTime);
} }
} }
protected Map<String, String> getWorkflowInfoFromCreateWorkflowResponseBody(String responseBody) throws JsonProcessingException {
return new ObjectMapper().readValue(responseBody, HashMap.class);
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment