Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests for Organizations Meta Attributes GET API #21054

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