Skip to content

Commit

Permalink
Merge pull request #21054 from BimsaraBodaragama/fix/integration-test…
Browse files Browse the repository at this point in the history
…s-for-organization-meta-attribute-pagination
  • Loading branch information
SujanSanjula96 authored Sep 7, 2024
2 parents c9d41e0 + 2122b95 commit 0ad488d
Show file tree
Hide file tree
Showing 3 changed files with 315 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class OrganizationManagementBaseTest extends RESTAPIServerTestBase {
static final String ORGANIZATION_MANAGEMENT_API_BASE_PATH = "/organizations";
static final String ORGANIZATION_CONFIGS_API_BASE_PATH = "/organization-configs";
static final String ORGANIZATION_DISCOVERY_API_PATH = "/discovery";
static final String ORGANIZATION_META_ATTRIBUTES_API_PATH = "/meta-attributes";
static final String PATH_SEPARATOR = "/";

protected static final String ORGANIZATION_ID = "id";
Expand All @@ -65,6 +66,7 @@ public class OrganizationManagementBaseTest extends RESTAPIServerTestBase {
protected static final String START_INDEX_PATH_PARAM = "startIndex";

protected static final String ORGANIZATION_NAME_ATTRIBUTE = "organizationName";
protected static final String ORGANIZATION_MULTIPLE_META_ATTRIBUTE_ATTRIBUTES = "attributes";

protected static final String LINK_REL_PREVIOUS = "previous";
protected static final String LINK_REL_NEXT = "next";
Expand All @@ -85,6 +87,8 @@ public class OrganizationManagementBaseTest extends RESTAPIServerTestBase {

protected static final int NUM_OF_ORGANIZATIONS_FOR_PAGINATION_TESTS = 20;
protected static final int DEFAULT_ORG_LIMIT = 15;
protected static final int NUM_OF_ORGANIZATIONS_WITH_META_ATTRIBUTES = 3;
protected static final int DEFAULT_META_ATTRIBUTES_LIMIT = 15;

protected static String swaggerDefinition;
protected OAuth2RestClient oAuth2RestClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,33 @@ public void testGetPaginatedOrganizationsDiscoveryWithInvalidOffsetAndLimitZero(
validateErrorResponse(response, HttpStatus.SC_INTERNAL_SERVER_ERROR, ERROR_CODE_SERVER_ERROR);
}

@Test(dependsOnMethods = "testGetPaginatedOrganizationsDiscoveryWithInvalidLimitAndOffset")
public void testGetPaginatedMetaAttributesWithInvalidLimit() {

String invalidLimitUrl =
ORGANIZATION_MANAGEMENT_API_BASE_PATH + ORGANIZATION_META_ATTRIBUTES_API_PATH + QUESTION_MARK +
LIMIT_QUERY_PARAM + EQUAL + "-1";
Response response = getResponseOfGetWithOAuth2(invalidLimitUrl, m2mToken);
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, ERROR_CODE_BAD_REQUEST);
}

@Test(dependsOnMethods = "testGetPaginatedMetaAttributesWithInvalidLimit")
public void testGetPaginatedMetaAttributesWithInvalidAfterCursor() {

String invalidAfterCursorUrl =
ORGANIZATION_MANAGEMENT_API_BASE_PATH + ORGANIZATION_META_ATTRIBUTES_API_PATH + QUESTION_MARK +
LIMIT_QUERY_PARAM + EQUAL + "10" + AMPERSAND + AFTER_QUERY_PARAM + EQUAL + INVALID_CURSOR;
Response response = getResponseOfGetWithOAuth2(invalidAfterCursorUrl, m2mToken);
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, ERROR_CODE_INVALID_PAGINATION_CURSOR);
}

@Test(dependsOnMethods = "testGetPaginatedMetaAttributesWithInvalidAfterCursor")
public void testGetPaginatedMetaAttributesWithInvalidBeforeCursor() {

String invalidBeforeCursorUrl =
ORGANIZATION_MANAGEMENT_API_BASE_PATH + ORGANIZATION_META_ATTRIBUTES_API_PATH + QUESTION_MARK +
LIMIT_QUERY_PARAM + EQUAL + "10" + AMPERSAND + BEFORE_QUERY_PARAM + EQUAL + INVALID_CURSOR;
Response response = getResponseOfGetWithOAuth2(invalidBeforeCursorUrl, m2mToken);
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, ERROR_CODE_INVALID_PAGINATION_CURSOR);
}
}
Loading

0 comments on commit 0ad488d

Please sign in to comment.