Commit ce8d9396 authored by NSarda's avatar NSarda
Browse files

Added test case for tags attribute at root level

parent 9de5b164
Pipeline #24617 failed with stages
in 3 minutes and 21 seconds
......@@ -163,6 +163,24 @@ public class IntegrationTestStepDefs implements En {
| responseCode.equals(AutomationConstants.REQUEST_SUCCESS);
assertTrue(recordCreatedOrUpdated);
});
Then("Transformed record should be created in storage with {string}", (String tagsblock) -> {
String responseCode = pollStorageForWksOfCustomRecordInContext(AutomationConstants.OS_TARGET_SCHEMA_KIND);
boolean recordCreatedOrUpdated = responseCode.equals(AutomationConstants.RECORD_CREATED)
| responseCode.equals(AutomationConstants.REQUEST_SUCCESS);
assertTrue(recordCreatedOrUpdated);
HttpResponse responseBody = pollStorageForWksOfCustomRecordBodyInContext(AutomationConstants.OS_TARGET_SCHEMA_KIND);
String response = responseBody.getBody();
JsonElement responseGiven = new Gson().fromJson(response, JsonElement.class);
JsonArray tagsResponseArray = responseGiven.getAsJsonObject().getAsJsonArray("tags");
String expectedMetaBody = this.context.getFileUtils().read(tagsblock);
JsonElement expectedJsonBody = new Gson().fromJson(expectedMetaBody, JsonElement.class);
JsonArray tagsExpectedArray = expectedJsonBody.getAsJsonObject().getAsJsonArray("tags");
assertTrue(tagsResponseArray.toString().contentEquals(tagsExpectedArray.toString()));
});
Then("Transformed records should be created in storage", () -> {
......@@ -587,7 +605,20 @@ public class IntegrationTestStepDefs implements En {
LOGGER.log(Level.INFO, "Storage Response for searching WKS record: " + this.context.getHttpResponse());
return responseCode;
}
private HttpResponse pollStorageForWksOfCustomRecordBodyInContext(String targetSchemaKind) {
long initial = System.currentTimeMillis();
HttpResponse responseBody = null;
String wksRecordIdForCustomRawRecord = createWksRecordIdFromCustomRawRecord(this.context.getCustomRecordId(), targetSchemaKind);
this.context.setWksRecordIdForCustomRawRecord(wksRecordIdForCustomRawRecord);
LOGGER.log(Level.INFO, "transformed record id to search - " + wksRecordIdForCustomRawRecord);
while ((System.currentTimeMillis() - initial) < (AutomationConstants.RECORD_SEARCH_MAX_TIMEOUT_SEC) * 1000) {
responseBody = storageGetAndSaveResponseBody(wksRecordIdForCustomRawRecord);
}
LOGGER.log(Level.INFO, "Storage Response for searching WKS record: " + this.context.getHttpResponse());
return responseBody;
}
private List<String> pollStorageForMultipleWksOfCustomRecordInContext(List<String> targetSchemaKinds) {
List<String> responseCodes = new ArrayList<>();
......@@ -731,6 +762,20 @@ public class IntegrationTestStepDefs implements En {
}
return responseCode;
}
private HttpResponse storageGetAndSaveResponseBody(String recordId) {
String reqURI = System.getProperty("STORAGE_URL", System.getenv("STORAGE_URL")).replaceAll("/$", "")
+ AutomationConstants.GET_ENDPOINT + recordId;
HttpRequest httpRequest = HttpRequest.builder().url(reqURI).httpMethod(HttpRequest.GET)
.requestHeaders(this.context.getAuthHeaders()).build();
HttpResponse response = HttpClientFactory.getInstance().send(httpRequest);
String responseCode = String.valueOf(response.getCode());
if (responseCode.equals(AutomationConstants.RECORD_CREATED)
| responseCode.equals(AutomationConstants.REQUEST_SUCCESS)) {
this.context.addNewResponse(response);
}
return response;
}
public static void customStaticWaitForSeconds(long timeout) {
Awaitility.setDefaultTimeout(Duration.ONE_MINUTE);
......
......@@ -43,7 +43,15 @@ Feature: Covers all positive and negative test cases around WKS transformation s
| payload | updatePayload |
| "/input_payloads/payload_for_create_operation.json" | "/input_payloads/payload_for_update_operation.json" |
@WksService_WIP
Scenario Outline: Wks record to be created with tags attribute on raw record creation.
When I hit Storage service put end point with <payload>
Then Transformed record should be created in storage with <tagsblock>
Examples: # This test case can be enabled after storage service is ready to accept tags attribute at root level
| payload | tagsblock |
#| "/input_payloads/payload_withTagsAndMeta_for_create_operation.json" | "/input_payloads/payload_with_tags_In_output.json" |
@WksService
Scenario Outline: Multiple Wks records should be created on raw record creation. WKS records should be updated on corresponding raw record update.
When I hit Storage service put end point with <payload>
......@@ -52,9 +60,10 @@ Feature: Covers all positive and negative test cases around WKS transformation s
When I hit Storage service put end point to update raw record with <updatePayload>
Then Existing WKS records in storage should get updated
Examples:
| payload | updatePayload |
Examples:
| payload | updatePayload |
| "/input_payloads/payload_for_create_operation_multiple_wks.json" | "/input_payloads/payload_for_update_operation_multiple_wks.json" |
@WksService
Scenario Outline: Metablock should get updated as per mapping file and ancestry should be correctly updated.
When I hit Storage service put end point with <payload>
......@@ -107,7 +116,7 @@ Feature: Covers all positive and negative test cases around WKS transformation s
When I hit wks service with <parentPayload> whose raw record contains relationship to record raw1
And Transformed record should contain relationship to raw record raw1 <relatedEntityPayload> as per <expectedRelationshipBlock>
Examples:
Examples:
| relatedEntityPayload | parentPayload | expectedRelationshipBlock |
| "/input_payloads/relationship/raw_having_no_wks_mapping.json" | "/input_payloads/relationship/recordRelatedToAnotherRecordWithNoWKS.json" | "/input_payloads/relationship/expectedRelationship_for_rawWithNoWks.json" |
......@@ -116,7 +125,7 @@ Feature: Covers all positive and negative test cases around WKS transformation s
Given I hit wks service with <parentPayload> whose raw record contains relationship to non-existing record,say raw1
Then Transformed record should contain relationship to record raw1 <parentPayload> as per <expectedRelationshipBlock>
Examples:
Examples:
| parentPayload | expectedRelationshipBlock |
| "/input_payloads/relationship/recordRelatedToAnotherUnavailableRecord.json" | "/input_payloads/relationship/expectedRelationship_for_nonExistentRaw.json" |
......@@ -127,12 +136,11 @@ Feature: Covers all positive and negative test cases around WKS transformation s
When I hit Storage service put end point with <parentPayload> whose raw record contains relationship to record raw1
Then Transformed record should contain relationship to wks with same authority of raw1 <relatedEntityPayload> as per <expectedRelationshipBlock>
Examples:
| relatedEntityPayload | parentPayload | expectedRelationshipBlock |
Examples:
| relatedEntityPayload | parentPayload | expectedRelationshipBlock |
| "/input_payloads/relationship/raw_having_wks_created_log_entity.json" | "/input_payloads/relationship/recordRelatedToEntityHavingWksCreatedLogEntity.json" | "/input_payloads/relationship/expectedRelationship_for_rawHavingWksCreated.json" |
@Not_yet_implemented_for_gitlab_gcp
@RelationshipValidation
Scenario Outline: WKS record relationships block should show relation to wks record created by wks service, with mapping definition targeted to schema of same authority and having higher major version
Given I hit Storage service put end point with <relatedEntityPayload> to persist a record say raw1
And I verify that three wks records are created for this raw record raw1
......@@ -140,33 +148,6 @@ Feature: Covers all positive and negative test cases around WKS transformation s
When I hit Storage service put end point with <parentPayload> whose raw record contains relationship to record raw1
Then Transformed record should contain relationship to wks with same authority of raw1 <relatedEntityPayload> and with higher major version as per <expectedRelationshipBlock>
Examples:
Examples:
| relatedEntityPayload | relatedEntityPayload2 | parentPayload | expectedRelationshipBlock |
| "/input_payloads/relationship/raw_having_wks_created_well_entity.json" | "/input_payloads/relationship/recordRelatedToAnotherRawButNotCreatedByWKSService.json" | "/input_payloads/relationship/recordRelatedToEntityHavingWksCreatedWellEntity.json" | "/input_payloads/relationship/expectedRelationship_for_rawHavingWksCreated.json" |
# Below scenarios are not applicable any more but they might be in future
# @RelationshipValidation
# Scenario Outline: WKS record relationships block should show relation to wks record created using mapping definition targeted to schema of same authority and with latest major version
# Given I hit Storage service put end point with <relatedEntityPayload> to persist a record say raw1
# And I hit Storage service put end point with <multipleWksWithDifferentMajorVersions> having raw1 as ancestry
# Then I hit wks service with <parentPayload> whose raw record contains relationship to raw1
# And Transformed record should contain relationship to highest major version wks of raw1, as per <expectedRelationshipBlock>
#
# Examples:
# | relatedEntityPayload | multipleWksWithDifferentMajorVersions | parentPayload | expectedRelationshipBlock |
# | "" | "/input_payloads/relationship/multiple_wks_major_versions.json" | "/input_payloads/relationship/recordRelatedToAnotherRawWithMultipleWks.json" | "/input_payloads/relationship/expectedRelationship_for_multipleWks.json" |
#
# @RelationshipValidation
# Scenario Outline: WKS record should show relation to single wks of related entity in case multiple wks record versions are present
# Given I hit Storage service put end point with <relatedEntityPayload> to persist a record say raw1
# And I hit Storage service put end point with <updatedVersionOfAboveRecord> to upadte record raw1
# And I verify that wks is created for above raw record
# Then I hit wks service with <parentPayload> whose raw record contains relationship to raw1
# And Transformed record should contain relationship to record raw1 as per <expectedRelationshipBlock>
#
# Examples:
# | relatedEntityPayload | updatedVersionOfAboveRecord | parentPayload | expectedRelationshipBlock |
# | "/input_payloads/relationship/raw_for_wks_record_version1.json" | "/input_payloads/relationship/raw_for_wks_record_version2.json" | "/input_payloads/relationship/recordRelatedToAnotherRawWithMultipleWksRecordVersions.json" | "/input_payloads/relationship/expectedRelationship_for_multipleWksRecordVersions.json" |
[
{
"data": {
"Spud date": "atspud",
"UWI": "<RandomText>"
},
"id": "<CreateUniqueID>",
"version": 1591087431362345,
"kind": "<tenant_name>:at:wellbore:1.0.0",
"tags": {
"name": {
"id": [
{
"kind": "12587932"
}
]
}
},
"acl": {
"viewers": [
"<acl_viewers>@<tenant_name>.<cloud_domain>"
],
"owners": [
"<acl_owners>@<tenant_name>.<cloud_domain>"
]
},
"legal": {
"legaltags": [
"<legal_tags>"
],
"otherRelevantDataCountries": [
"US"
],
"status": "compliant"
},
"createUser": "integrationtester"
}
]
{
"tags": {
"name": {
"id": [
{
"kind": "12587932"
}
]
}
}
}
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