Skip to content

Commit

Permalink
Add integration tests to validate error response of organization mana…
Browse files Browse the repository at this point in the history
…gement with trace id
  • Loading branch information
BimsaraBodaragama committed Aug 13, 2024
1 parent 4d7b2cc commit fb1311b
Showing 1 changed file with 11 additions and 11 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,7 +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",
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
}

Expand All @@ -260,7 +260,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",
validateErrorResponse(secondResponse, HttpStatus.SC_BAD_REQUEST, "ORG-60085",
organizationIDs.get(0));
}

Expand All @@ -278,7 +278,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",
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
}

Expand All @@ -297,7 +297,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",
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
}

Expand All @@ -321,7 +321,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,7 +331,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",
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "ORG-60015",
invalidOrganizationID);
}

Expand Down

0 comments on commit fb1311b

Please sign in to comment.