Commit 0e66576b authored by Mayank Saggar [Microsoft]'s avatar Mayank Saggar [Microsoft]
Browse files

Switching from string-replace method for endpoint to using string-format method

parent d8b62d08
Pipeline #18070 failed with stages
in 7 minutes and 4 seconds
......@@ -12,15 +12,12 @@ public class TestConstants {
public static final String HEADER_DATA_PARTITION_ID = "data-partition-id";
public static final String INVALID_PARTITION = "invalid-partition";
//Util constants
public static final int WORKFLOW_READY_DELAY = 100;
//Api endpoints
public static final String START_WORKFLOW_API_ENDPOINT = "/startWorkflow";
public static final String GET_STATUS_API_ENDPOINT = "/getStatus";
public static final String UPDATE_STATUS_API_ENDPOINT = "/updateStatus";
public static final String CREATE_WORKFLOW_API_ENDPOINT = "/workflow";
public static final String TRIGGER_WORKFLOW_API_ENDPOINT = "/workflow/{id}/workflowRun";
public static final String TRIGGER_WORKFLOW_API_ENDPOINT = "/workflow/%s/workflowRun";
public static final String WORKFLOW_TYPE_INGEST = "ingest";
......@@ -47,7 +44,7 @@ public class TestConstants {
public static final String WORKFLOW_TYPE_NOT_NULL_MESSAGE = "WorkflowType: must not be null";
public static final String WORKFLOW_ALREADY_HAS_STATUS_MESSAGE = "Workflow status for workflow id: %s already has status:%s and can not be updated";
public static final String WORKFLOW_STATUS_NOT_ALLOWED_MESSAGE = "Status: Not allowed workflow status type: SUBMITTED, Should be one of: [RUNNING, FINISHED, FAILED]";
public static final String WORKFLOW_NOT_FOUND_MESSAGE = "Workflow: {id} doesn't exist";
public static final String WORKFLOW_NOT_FOUND_MESSAGE = "Workflow: %s doesn't exist";
public static String getValidWorkflowPayload(){
return buildStartWorkflow(buildContext(), WORKFLOW_TYPE_INGEST);
......
......@@ -20,13 +20,15 @@ import static org.opengroup.osdu.workflow.util.TestDataUtil.getWorkflow;
public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
public static final String INVALID_WORKFLOW_ID = "Invalid-Workflow-ID";
@Test
public void should_returnSuccess_when_givenValidRequest() throws Exception{
String triggerWorkflowRequestBody = getValidTriggerWorkflowRunRequest();
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_PYTHON_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
triggerWorkflowRequestBody,
headers,
......@@ -51,7 +53,7 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_HTTP_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
triggerWorkflowRequestBody,
headers,
......@@ -76,7 +78,7 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_KUBERNETES_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
triggerWorkflowRequestBody,
headers,
......@@ -102,7 +104,7 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_PYTHON_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
triggerWorkflowRequestBody,
headers,
......@@ -116,7 +118,7 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
public void should_return_WorkflowNotFound_when_givenWrongWorkflowId() throws Exception {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}", "F8x"),
String.format(TRIGGER_WORKFLOW_URL, INVALID_WORKFLOW_ID),
getValidTriggerWorkflowRunRequest(),
headers,
client.getAccessToken()
......@@ -125,14 +127,14 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatus());
String error = response.getEntity(String.class);
assertTrue(error.contains(WORKFLOW_NOT_FOUND_MESSAGE.replace("{id}", "F8x")));
assertTrue(error.contains(String.format(WORKFLOW_NOT_FOUND_MESSAGE, INVALID_WORKFLOW_ID)));
}
@Test
public void should_returnUnauthorized_when_notGivenAccessToken() throws Exception {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_PYTHON_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
getValidTriggerWorkflowRunRequest(),
headers,
......@@ -146,7 +148,7 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
public void should_returnUnauthorized_when_givenNoDataAccessToken() throws Exception {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_PYTHON_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
getValidTriggerWorkflowRunRequest(),
headers,
......@@ -160,7 +162,7 @@ public abstract class PostTriggerWorkflowIntegrationTests extends TestBase {
public void should_returnUnauthorized_when_givenInvalidPartition() throws Exception {
ClientResponse response = client.send(
HttpMethod.POST,
TRIGGER_WORKFLOW_URL.replace("{id}",
String.format(TRIGGER_WORKFLOW_URL,
getWorkflow(TEST_SIMPLE_PYTHON_DAG).get(CreateWorkflowTestsBuilder.WORKFLOW_ID_FIELD).getAsString()),
getValidTriggerWorkflowRunRequest(),
HTTPClient.overrideHeader(headers, INVALID_PARTITION),
......
Markdown is supported
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