Commit 2ea3391d authored by Aalekh Jain's avatar Aalekh Jain
Browse files

Updated TestConstants

parent 7aa38622
package org.opengroup.osdu.azure.workflow.framework.workflow;
import com.google.gson.JsonObject;
import com.sun.jersey.api.client.ClientResponse;
import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Test;
import org.opengroup.osdu.azure.workflow.framework.util.HTTPClient;
import org.opengroup.osdu.azure.workflow.framework.util.TestBase;
import javax.ws.rs.HttpMethod;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opengroup.osdu.azure.workflow.framework.consts.TestConstants.*;
import static org.opengroup.osdu.azure.workflow.framework.consts.TestDAGNames.TEST_DUMMY_DAG;
import static org.opengroup.osdu.azure.workflow.framework.consts.TestDAGNames.TEST_DUMMY_DAG_SYSTEM;
import static org.opengroup.osdu.azure.workflow.framework.util.CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD;
import static org.opengroup.osdu.azure.workflow.framework.util.CreateWorkflowTestsBuilder.getValidCreateWorkflowRequest;
import static org.opengroup.osdu.azure.workflow.framework.util.TestDataUtil.getWorkflow;
import static org.opengroup.osdu.azure.workflow.framework.util.TriggerWorkflowTestsBuilder.buildTriggerWorkflowPayload;
import static org.opengroup.osdu.azure.workflow.framework.util.TriggerWorkflowTestsBuilder.getWorkflowRunIdFromPayload;
import static org.opengroup.osdu.azure.workflow.framework.workflow.PostCreateWorkflowIntegrationTests.TEST_WORKFLOW_FILE_NAME;
public abstract class DeleteSystemWorkflowIntegrationTests extends TestBase {
private static final String INVALID_WORKFLOW_ID = "Invalid-Workflow-ID";
@Test
public void should_delete_when_given_valid_workflow_id() throws Exception {
String createWorkflowRequestBody = getValidCreateWorkflowRequest(TEST_DUMMY_DAG_SYSTEM,
TEST_WORKFLOW_FILE_NAME);
ClientResponse response = client.send(
HttpMethod.POST,
CREATE_SYSTEM_WORKFLOW_URL,
createWorkflowRequestBody,
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
JsonObject responseBody = gson.fromJson(response.getEntity(String.class), JsonObject.class);
ClientResponse deleteResponse = client.send(
HttpMethod.DELETE,
String.format(GET_SYSTEMWORKFLOW_BY_ID_URL, responseBody.get(WORKFLOW_ID_FIELD).getAsString()),
null,
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getStatus());
}
@Test
public void should_throw_error_when_given_invalid_workflow_id() throws Exception {
ClientResponse deleteResponse = client.send(
HttpMethod.DELETE,
String.format(GET_SYSTEMWORKFLOW_BY_ID_URL, INVALID_WORKFLOW_ID),
null,
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.SC_NOT_FOUND, deleteResponse.getStatus());
}
}
package org.opengroup.osdu.azure.workflow.workflow;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.opengroup.osdu.azure.workflow.framework.workflow.DeleteSystemWorkflowIntegrationTests;
import org.opengroup.osdu.azure.workflow.framework.workflow.DeleteWorkflowIntegrationTests;
import org.opengroup.osdu.azure.workflow.utils.HTTPClientAzure;
public class TestDeleteSystemWorkflowIntegration extends DeleteSystemWorkflowIntegrationTests {
@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
this.client = new HTTPClientAzure();
this.headers = client.getCommonHeaderWithoutPartition();
}
@AfterEach
@Override
public void tearDown() throws Exception {
super.tearDown();
this.client = null;
this.headers = null;
}
}
......@@ -26,6 +26,9 @@ public class TestConstants {
public static final String CREATE_WORKFLOW_RUN_API_ENDPOINT = CREATE_WORKFLOW_API_ENDPOINT + "/%s/workflowRun";
public static final String GET_WORKFLOW_BY_ID_API_ENDPOINT = "v1/workflow/%s";
public static final String GET_WORKFLOW_RUN_BY_ID_API_ENDPOINT = CREATE_WORKFLOW_API_ENDPOINT + "/%s/workflowRun/%s";
public static final String CREATE_SYSTEM_WORKFLOW_API_ENDPOINT ="v1/workflow/system";
public static final String GET_SYSTEM_WORKFLOW_BY_ID_API_ENDPOINT = "v1/workflow/system/%s";
public static final String GET_SERVICE_INFO_API_ENDPOINT = "info";
public static final String GET_ALL_WORKFLOW_PREFIX = "?prefix=";
public static final String WORKFLOW_TYPE_INGEST = "ingest";
......@@ -51,10 +54,14 @@ public class TestConstants {
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + CREATE_WORKFLOW_API_ENDPOINT;
public static final String CREATE_WORKFLOW_RUN_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + CREATE_WORKFLOW_RUN_API_ENDPOINT;
public static final String CREATE_SYSTEM_WORKFLOW_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + CREATE_SYSTEM_WORKFLOW_API_ENDPOINT;
public static final String GET_WORKFLOW_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_WORKFLOW_BY_ID_API_ENDPOINT;
public static final String GET_WORKFLOW_RUN_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_WORKFLOW_RUN_BY_ID_API_ENDPOINT;
public static final String GET_SYSTEM_WORKFLOW_BY_ID_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_SYSTEM_WORKFLOW_BY_ID_API_ENDPOINT;
public static final String GET_DETAILS_WORKFLOW_RUN_URL =
getEnvironmentVariableOrDefaultKey(WORKFLOW_HOST) + GET_WORKFLOW_RUN_BY_ID_API_ENDPOINT;
public static final String GET_SERVICE_INFO_URL =
......
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