Skip to content

Commit

Permalink
Merge pull request #20895 from BimsaraBodaragama/master
Browse files Browse the repository at this point in the history
Add Trace ID Validation to Integration Tests for Organization Management Error Responses
  • Loading branch information
SujanSanjula96 committed Aug 14, 2024
2 parents 5608579 + f9aff03 commit d49c365
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testGetOrganizationsWithInvalidOperator() {
String filterQuery = "?filter=name ca G&limit=10&recursive=false";
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60059");
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "ORG-60059");
}

@Test(dependsOnMethods = "testGetOrganizationsWithInvalidOperator")
Expand All @@ -144,7 +144,7 @@ public void testGetOrganizationsWithUnsupportedAttribute() {
String filterQuery = "?filter=attribute.Country co S&limit=10&recursive=false";
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60023");
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "ORG-60023");
}

@Test(dependsOnMethods = "testGetOrganizationsWithUnsupportedAttribute")
Expand All @@ -153,7 +153,7 @@ public void testGetOrganizationsMetaAttributesWithInvalidOperator() {
String filterQuery = "?filter=attributes ca C&limit=10&recursive=false";
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + "/meta-attributes" + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60059");
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "ORG-60059");
}

@Test(dependsOnMethods = "testGetOrganizationsMetaAttributesWithInvalidOperator")
Expand All @@ -162,7 +162,7 @@ public void testGetOrganizationsMetaAttributesWithUnsupportedAttribute() {
String filterQuery = "?filter=attribute co S&limit=10&recursive=false";
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + "/meta-attributes" + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60023");
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "ORG-60023");
}

@Test(dependsOnMethods = "testGetOrganizationsMetaAttributesWithUnsupportedAttribute")
Expand All @@ -180,7 +180,7 @@ public void testAddDiscoveryAttributesWithoutAddingConfig() throws IOException {
String requestBody = readResource("add-discovery-attributes-request-body.json");
requestBody = requestBody.replace("${organizationID}", organizationIDs.get(0));
Response response = getResponseOfPostWithOAuth2(endpointURL, requestBody, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60080");
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "ORG-60080");
}

@Test(dependsOnMethods = "testAddDiscoveryAttributesWithoutAddingConfig")
Expand Down Expand Up @@ -237,8 +237,7 @@ public void testAddDiscoveryAttributesToNonExistingOrganization() throws IOExcep
String requestBody = readResource("add-discovery-attributes-request-body.json");
requestBody = requestBody.replace("${organizationID}", invalidOrganizationID);
Response response = getResponseOfPostWithOAuth2(endpointURL, requestBody, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015", invalidOrganizationID);
}

@Test(dependsOnMethods = "testAddDiscoveryAttributesToNonExistingOrganization")
Expand All @@ -260,8 +259,7 @@ public void testAddDiscoveryAttributesWhenAlreadyAdded() throws IOException {
Response firstResponse = getResponseOfPostWithOAuth2(endpointURL, requestBody, m2mToken);
validateHttpStatusCode(firstResponse, HttpStatus.SC_CREATED);
Response secondResponse = getResponseOfPostWithOAuth2(endpointURL, requestBody, m2mToken);
validateErrorResponseWithoutTraceId(secondResponse, HttpStatus.SC_BAD_REQUEST, "ORG-60085",
organizationIDs.get(0));
validateErrorResponse(secondResponse, HttpStatus.SC_BAD_REQUEST, "ORG-60085", organizationIDs.get(0));
}

@Test(dependsOnMethods = "testAddDiscoveryAttributesWhenAlreadyAdded")
Expand All @@ -278,8 +276,7 @@ public void testGetDiscoveryAttributesOfNonExistingOrganization() {
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + PATH_SEPARATOR + invalidOrganizationID
+ ORGANIZATION_DISCOVERY_API_PATH;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015", invalidOrganizationID);
}

@Test(dependsOnMethods = "testGetDiscoveryAttributesOfNonExistingOrganization")
Expand All @@ -297,8 +294,7 @@ public void testDeleteDiscoveryAttributesOfNonExistingOrganization() {
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + PATH_SEPARATOR + invalidOrganizationID
+ ORGANIZATION_DISCOVERY_API_PATH;
Response response = getResponseOfDeleteWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015", invalidOrganizationID);
}

@Test(dependsOnMethods = "testDeleteDiscoveryAttributesOfNonExistingOrganization")
Expand All @@ -321,7 +317,7 @@ public void testUpdateWithUnavailableDiscoveryAttributes() throws IOException {
Response firstResponse = getResponseOfPutWithOAuth2(firstEndpointURL, requestBody, m2mToken);
validateHttpStatusCode(firstResponse, HttpStatus.SC_OK);
Response secondResponse = getResponseOfPutWithOAuth2(secondEndpointURL, requestBody, m2mToken);
validateErrorResponseWithoutTraceId(secondResponse, HttpStatus.SC_BAD_REQUEST, "ORG-60083");
validateErrorResponse(secondResponse, HttpStatus.SC_BAD_REQUEST, "ORG-60083");
}

@Test(dependsOnMethods = "testUpdateWithUnavailableDiscoveryAttributes")
Expand All @@ -331,8 +327,7 @@ public void testUpdateDiscoveryAttributesOfNonExistingOrganization() throws IOEx
+ ORGANIZATION_DISCOVERY_API_PATH;
String requestBody = readResource("update-discovery-attributes-request-body.json");
Response response = getResponseOfPutWithOAuth2(endpointURL, requestBody, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015", invalidOrganizationID);
}

@Test(dependsOnMethods = "testUpdateDiscoveryAttributesOfNonExistingOrganization")
Expand Down

0 comments on commit d49c365

Please sign in to comment.