diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/base/APIMIntegrationConstants.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/base/APIMIntegrationConstants.java index b48fed1dfb..a1f561ddbf 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/base/APIMIntegrationConstants.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/base/APIMIntegrationConstants.java @@ -42,6 +42,15 @@ public class APIMIntegrationConstants { public static final String API_RESPONSE_ELEMENT_NAME_APIS = "apis"; public static final String API_RESPONSE_ELEMENT_NAME_ID = "id"; + public static final String API_NAME = "name"; + public static final String API_CONTEXT = "context"; + public static final String API_VERSION = "version"; + public static final String ENDPOINT_TYPE = "endpoint_type"; + public static final String SANDBOX_ENDPOINTS = "sandbox_endpoints"; + public static final String PRODUCTION_ENDPOINTS = "production_endpoints"; + public static final String ENDPOINT_CONFIG = "endpointConfig"; + public static final String POLICIES = "policies"; + public static final String OPERATIONS = "operations"; public static final String API_CONTEXT_MALFORMED_ERROR = "The API context is malformed"; public static final String API_PRODUCT_CONTEXT_MALFORMED_ERROR = "The API Product context is malformed"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/graphql/GraphqlTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/graphql/GraphqlTestCase.java index b928ca47d2..7fccde5a77 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/graphql/GraphqlTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/graphql/GraphqlTestCase.java @@ -204,22 +204,22 @@ public void testCreateAndPublishGraphQLAPIUsingSchemaWithMalformedContext() thro HttpResponse response = null; ArrayList policies = new ArrayList(); - policies.add("Unlimited"); + policies.add(APIMIntegrationConstants.API_TIER.UNLIMITED); JSONObject additionalPropertiesObj = new JSONObject(); - additionalPropertiesObj.put("name", "GraphQLAPIWithInvalidContext"); - additionalPropertiesObj.put("context", "invalidContext{version}"); - additionalPropertiesObj.put("version", API_VERSION_1_0_0); + additionalPropertiesObj.put(APIMIntegrationConstants.API_NAME, "GraphQLAPIWithInvalidContext"); + additionalPropertiesObj.put(APIMIntegrationConstants.API_CONTEXT, "invalidContext{version}"); + additionalPropertiesObj.put(APIMIntegrationConstants.API_VERSION, API_VERSION_1_0_0); JSONObject url = new JSONObject(); url.put("url", END_POINT_URL); JSONObject endpointConfig = new JSONObject(); - endpointConfig.put("endpoint_type", "http"); - endpointConfig.put("sandbox_endpoints", url); - endpointConfig.put("production_endpoints", url); - additionalPropertiesObj.put("endpointConfig", endpointConfig); - additionalPropertiesObj.put("policies", policies); - additionalPropertiesObj.put("operations", operations); + endpointConfig.put(APIMIntegrationConstants.ENDPOINT_TYPE, "http"); + endpointConfig.put(APIMIntegrationConstants.SANDBOX_ENDPOINTS, url); + endpointConfig.put(APIMIntegrationConstants.PRODUCTION_ENDPOINTS, url); + additionalPropertiesObj.put(APIMIntegrationConstants.ENDPOINT_CONFIG, endpointConfig); + additionalPropertiesObj.put(APIMIntegrationConstants.POLICIES, policies); + additionalPropertiesObj.put(APIMIntegrationConstants.OPERATIONS, operations); // create Graphql API response = restAPIPublisher.importGraphqlSchemaDefinitionWithInvalidContext(file, additionalPropertiesObj.toString()); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM18CreateAnAPIThroughThePublisherRestAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM18CreateAnAPIThroughThePublisherRestAPITestCase.java index f30fbb8ef5..09122d34c1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM18CreateAnAPIThroughThePublisherRestAPITestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM18CreateAnAPIThroughThePublisherRestAPITestCase.java @@ -166,11 +166,11 @@ public void testCreateAnAPIWithMalformedContextThroughThePublisherRest() apiCreationRequestBean.setVersion(apiVersion); apiCreationRequestBean.setDescription(apiDescription); apiCreationRequestBean.setTags(apiTag); - apiCreationRequestBean.setTier("Gold"); + apiCreationRequestBean.setTier(APIMIntegrationConstants.API_TIER.GOLD); HttpResponse response = restAPIPublisher.addAPIWithMalformedContext(apiCreationRequestBean); Assert.assertNotNull(response, "Response cannot be null"); - Assert.assertEquals(response.getResponseCode(), 400, "Response Code miss matched when creating the API"); + Assert.assertEquals(response.getResponseCode(), Response.Status.BAD_REQUEST.getStatusCode(), "Response Code miss matched when creating the API"); } @Test(groups = {"wso2.am"}, description = "Remove an API Through the Publisher Rest API", diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/websocket/WebSocketAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/websocket/WebSocketAPITestCase.java index efe8f8b52a..aa2405017b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/websocket/WebSocketAPITestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/websocket/WebSocketAPITestCase.java @@ -72,6 +72,7 @@ import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; import org.wso2.carbon.utils.xml.StringUtils; +import javax.ws.rs.core.Response; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -487,7 +488,7 @@ public void testCreateWebSocketAPIWithMalformedContext() throws Exception { apiRequest.setApiTier(APIMIntegrationConstants.API_TIER.UNLIMITED); HttpResponse response = restAPIPublisher.addAPIWithMalformedContext(apiRequest); - Assert.assertEquals(response.getResponseCode(), 400, "Response Code miss matched when creating the API"); + Assert.assertEquals(response.getResponseCode(), Response.Status.BAD_REQUEST.getStatusCode(), "Response Code miss matched when creating the API"); } /**