Commit 1a5c07d1 authored by Dmitrii Novikov (EPAM)'s avatar Dmitrii Novikov (EPAM) Committed by Riabokon Stanislav(EPAM)[GCP]
Browse files

Fixed get workflow status request by workflowName (GONRG-3007)

parent c0142e85
......@@ -437,8 +437,14 @@ public class WorkflowEngineServiceImplTest {
private WorkflowEngineRequest workflowEngineRequest(String workflowEngineExecutionDate,
boolean isDeployedThroughWorkflowService) {
return new WorkflowEngineRequest(RUN_ID, WORKFLOW_ID, WORKFLOW_NAME, EXECUTION_TIMESTAMP,
workflowEngineExecutionDate, isDeployedThroughWorkflowService);
return WorkflowEngineRequest.builder()
.runId(RUN_ID)
.workflowId(WORKFLOW_ID)
.workflowName(WORKFLOW_NAME)
.executionTimeStamp(EXECUTION_TIMESTAMP)
.workflowEngineExecutionDate(workflowEngineExecutionDate)
.isDeployedThroughWorkflowService(isDeployedThroughWorkflowService)
.build();
}
private Map<String, Object> registrationInstructions(String dagContent) {
......
......@@ -35,7 +35,7 @@ public abstract class GetCustomOperatorByIdIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseData = gson.fromJson(response.getEntity(String.class), JsonObject.class);
assertEquals(testOperatorData, responseData);
}
......
......@@ -59,7 +59,7 @@ public abstract class GetCustomOperatorsIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseData = gson.fromJson(response.getEntity(String.class), JsonObject.class);
assertTrue(responseData.has(RESPONSE_ITEMS_KEY));
if(testDataOperatorNameToInfo.size() < DEFAULT_LIMIT) {
......@@ -80,7 +80,7 @@ public abstract class GetCustomOperatorsIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseData = gson.fromJson(response.getEntity(String.class), JsonObject.class);
assertTrue(responseData.has(RESPONSE_ITEMS_KEY));
assertEquals(limit, responseData.getAsJsonArray(RESPONSE_ITEMS_KEY).size());
......@@ -98,7 +98,7 @@ public abstract class GetCustomOperatorsIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseData = gson.fromJson(response.getEntity(String.class), JsonObject.class);
assertTrue(responseData.has(RESPONSE_ITEMS_KEY));
assertTrue(responseData.has(RESPONSE_CURSOR_KEY));
......@@ -115,7 +115,7 @@ public abstract class GetCustomOperatorsIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
responseData = gson.fromJson(response.getEntity(String.class), JsonObject.class);
assertTrue(responseData.has(RESPONSE_ITEMS_KEY));
assertEquals(limit, responseData.getAsJsonArray(RESPONSE_ITEMS_KEY).size());
......
......@@ -134,7 +134,7 @@ public class PreIntegrationSetup {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
return gson.fromJson(response.getEntity(String.class), Map.class);
}
}
......@@ -160,7 +160,7 @@ public abstract class TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
trackTriggeredWorkflowRun(workflowId, getWorkflowRunIdFromPayload(triggerWorkflowPayload));
......
......@@ -31,7 +31,7 @@ public abstract class DeleteWorkflowIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
trackTriggeredWorkflowRun(existingWorkflowId,
getWorkflowRunIdFromPayload(triggerWorkflowPayload));
......
......@@ -67,7 +67,7 @@ public abstract class GetAllRunInstancesIntegrationTests extends TestBase {
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
Type WorkflowRunsListType = new TypeToken<ArrayList<WorkflowRun>>(){}.getType();
List<WorkflowRun> workflowRunsList =
gson.fromJson(response.getEntity(String.class), WorkflowRunsListType);
......@@ -88,7 +88,7 @@ public abstract class GetAllRunInstancesIntegrationTests extends TestBase {
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
Type WorkflowRunsListType = new TypeToken<ArrayList<WorkflowRun>>(){}.getType();
List<WorkflowRun> workflowRunsList =
gson.fromJson(response.getEntity(String.class), WorkflowRunsListType);
......@@ -109,7 +109,7 @@ public abstract class GetAllRunInstancesIntegrationTests extends TestBase {
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
Type WorkflowRunsListType = new TypeToken<ArrayList<WorkflowRun>>(){}.getType();
List<WorkflowRun> workflowRunsList =
......
......@@ -42,7 +42,7 @@ public abstract class GetSignedUrlIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject workflowResponse = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
assertTrue(workflowResponse.has(SIGNED_URL_FIELD));
String signedUrl = workflowResponse.get(SIGNED_URL_FIELD).getAsString();
......
......@@ -108,7 +108,7 @@ public abstract class PostCreateWorkflowIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
String workflowId = new Gson().fromJson(createWorkflowRequestBody, JsonObject.class).get(WORKFLOW_NAME_FIELD)
.getAsString();
......
......@@ -31,7 +31,7 @@ public abstract class PostGetStatusIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
String responseBody = response.getEntity(String.class);
......
......@@ -34,7 +34,7 @@ public abstract class PostStartWorkflowIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject workflowResponse = gson.fromJson(response.getEntity(String.class), JsonObject.class);
......@@ -80,7 +80,7 @@ public abstract class PostStartWorkflowIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseBody = gson.fromJson(response.getEntity(String.class), JsonObject.class);
......
......@@ -52,7 +52,7 @@ public abstract class PostUpdateStatusIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseBody = gson.fromJson(response.getEntity(String.class), JsonObject.class);
......
......@@ -66,7 +66,7 @@ public class TestPostStartWorkflowIntegration extends PostStartWorkflowIntegrati
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject workflowResponse = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......@@ -87,7 +87,7 @@ public class TestPostStartWorkflowIntegration extends PostStartWorkflowIntegrati
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject workflowResponse = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......@@ -117,7 +117,7 @@ public class TestPostStartWorkflowIntegration extends PostStartWorkflowIntegrati
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseBody = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......
......@@ -74,7 +74,7 @@ public class TestPostUpdateStatusIntegration extends PostUpdateStatusIntegratio
PayloadBuilder.buildUpdateStatus(expectedWorkflowId, WORKFLOW_STATUS_TYPE_FINISHED),
headers,client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseBody = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......@@ -141,7 +141,7 @@ public class TestPostUpdateStatusIntegration extends PostUpdateStatusIntegratio
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
}
......
......@@ -17,14 +17,19 @@
package org.opengroup.osdu.workflow.util.v3;
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_URL;
import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_WORKFLOW_NAME;
import static org.opengroup.osdu.workflow.consts.TestConstants.FINISHED_WORKFLOW_RUN_STATUSES;
import static org.opengroup.osdu.workflow.consts.TestConstants.GET_WORKFLOW_RUN_URL;
import static org.opengroup.osdu.workflow.util.PayloadBuilder.buildCreateWorkflowRunValidPayload;
import static org.opengroup.osdu.workflow.util.PayloadBuilder.buildCreateWorkflowValidPayload;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.jersey.api.client.ClientResponse;
import lombok.extern.slf4j.Slf4j;
import org.opengroup.osdu.workflow.util.HTTPClient;
import org.springframework.http.HttpStatus;
import javax.ws.rs.HttpMethod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
......@@ -33,16 +38,10 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
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_URL;
import static org.opengroup.osdu.workflow.consts.TestConstants.CREATE_WORKFLOW_WORKFLOW_NAME;
import static org.opengroup.osdu.workflow.consts.TestConstants.FINISHED_WORKFLOW_RUN_STATUSES;
import static org.opengroup.osdu.workflow.consts.TestConstants.GET_WORKFLOW_RUN_URL;
import static org.opengroup.osdu.workflow.util.PayloadBuilder.buildCreateWorkflowRunValidPayload;
import static org.opengroup.osdu.workflow.util.PayloadBuilder.buildCreateWorkflowValidPayload;
import javax.ws.rs.HttpMethod;
import lombok.extern.slf4j.Slf4j;
import org.opengroup.osdu.workflow.util.HTTPClient;
import org.springframework.http.HttpStatus;
@Slf4j
public abstract class TestBase {
......@@ -69,7 +68,7 @@ public abstract class TestBase {
headers,
client.getAccessToken()
);
assertEquals(HttpStatus.OK.value(), response.getStatus());
assertEquals(HttpStatus.OK.value(), response.getStatus(), response.toString());
return response.getEntity(String.class);
}
......@@ -185,12 +184,15 @@ public abstract class TestBase {
client.getAccessToken()
);
if(response.getStatus() == org.apache.http.HttpStatus.SC_OK) {
Map<String, String> workflowRunInfo = new ObjectMapper().readValue(response.getEntity(String.class), HashMap.class);
return workflowRunInfo.get("status");
if (response.getStatus() == org.apache.http.HttpStatus.SC_OK) {
Map<String, String> workflowRunInfo =
new ObjectMapper().readValue(response.getEntity(String.class), HashMap.class);
return workflowRunInfo.get(WORKFLOW_RUN_STATUS_FIELD);
} else {
throw new Exception(String.format("Error getting status for workflow run id %s",
workflowRunId));
throw new Exception(
String.format(
"Error getting status for workflow run id %s. Status code: %s. Response: %s",
workflowRunId, response.getStatus(), response));
}
}
......
......@@ -45,7 +45,7 @@ public abstract class GetServiceInfoIntegrationTest extends TestBase {
""
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
VersionInfoUtils.VersionInfo responseObject = VERSION_INFO_UTILS.getVersionInfoFromResponse(response);
......
......@@ -30,7 +30,7 @@ public abstract class PostGetStatusIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
String responseBody = response.getEntity(String.class);
......
......@@ -34,7 +34,7 @@ public abstract class PostStartWorkflowIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject workflowResponse = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......@@ -80,7 +80,7 @@ public abstract class PostStartWorkflowIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseBody = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......
......@@ -52,7 +52,7 @@ public abstract class PostUpdateStatusIntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertEquals(HttpStatus.SC_OK, response.getStatus(), response.toString());
JsonObject responseBody = new Gson().fromJson(response.getEntity(String.class), JsonObject.class);
......
......@@ -84,7 +84,7 @@ public abstract class WorkflowRunV3IntegrationTests extends TestBase {
client.getAccessToken()
);
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus());
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus(), response.toString());
}
@Test
......@@ -420,7 +420,7 @@ public abstract class WorkflowRunV3IntegrationTests extends TestBase {
Map<String, String> updateWorkflowRunInfo = new ObjectMapper().readValue(response.getEntity(String.class), HashMap.class);
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus());
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus(), response.toString());
assertEquals(updateWorkflowRunInfo.get(WORKFLOW_RUN_ID_FIELD), workflowRunInfo.get(WORKFLOW_RUN_ID_FIELD));
assertEquals(updateWorkflowRunInfo.get(WORKFLOW_RUN_STATUS_FIELD), WORKFLOW_STATUS_TYPE_RUNNING);
......@@ -451,7 +451,7 @@ public abstract class WorkflowRunV3IntegrationTests extends TestBase {
Map<String, String> updateWorkflowRunInfo = new ObjectMapper().readValue(response.getEntity(String.class), HashMap.class);
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus());
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus(), response.toString());
assertEquals(updateWorkflowRunInfo.get(WORKFLOW_RUN_ID_FIELD), workflowRunInfo.get(WORKFLOW_RUN_ID_FIELD));
assertEquals(updateWorkflowRunInfo.get(WORKFLOW_RUN_STATUS_FIELD), WORKFLOW_STATUS_TYPE_FINISHED);
......@@ -524,7 +524,7 @@ public abstract class WorkflowRunV3IntegrationTests extends TestBase {
Map<String, String> updateWorkflowRunInfo = new ObjectMapper().readValue(response.getEntity(String.class), HashMap.class);
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus());
assertEquals(org.apache.http.HttpStatus.SC_OK, response.getStatus(), response.toString());
assertEquals(updateWorkflowRunInfo.get(WORKFLOW_RUN_ID_FIELD), workflowRunInfo.get(WORKFLOW_RUN_ID_FIELD));
assertEquals(updateWorkflowRunInfo.get(WORKFLOW_RUN_STATUS_FIELD), WORKFLOW_STATUS_TYPE_FINISHED);
......
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