From 177717a2f7457f7a3e486d6359b440b160ab1fe5 Mon Sep 17 00:00:00 2001 From: sadilchamishka <35717390+sadilchamishka@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:49:51 +0530 Subject: [PATCH] Address review comments --- .../integration/test/rest/api/common/B2BRESTTestBase.java | 7 ++++--- .../management/v1/OrganizationManagementBaseTest.java | 2 +- .../management/v1/OrganizationManagementFailureTest.java | 7 ++++--- .../management/v1/OrganizationManagementSuccessTest.java | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/common/B2BRESTTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/common/B2BRESTTestBase.java index 41186758e35..fbc37f5c2b6 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/common/B2BRESTTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/common/B2BRESTTestBase.java @@ -92,6 +92,7 @@ protected Response getResponseOfGet(String endpointUri) { * @return Response of post request. */ protected Response getResponseOfPost(String endpointUri, String body) { + return given().auth().preemptive().basic(authenticatingUserName, authenticatingCredential) .contentType(ContentType.JSON) .header(HttpHeaders.ACCEPT, ContentType.JSON) @@ -140,7 +141,7 @@ protected void validateErrorResponse(Response response, int httpStatusCode, Stri } /** - * Validate http status code of the response + * Validate http status code of the response. * * @param response Response. * @param httpStatusCode Expected status code. @@ -155,7 +156,7 @@ protected void validateHttpStatusCode(Response response, int httpStatusCode) { } /** - * Validate error description of the response, if an entry is available in RESTAPIErrors.properties + * Validate error description of the response, if an entry is available in RESTAPIErrors.properties. * * @param response Response. * @param errorCode Error code. @@ -179,7 +180,7 @@ private void validateErrorMessage(Response response, String errorCode) { } /** - * Validate elements in error response against entries in RESTAPIErrors.properties + * Validate elements in error response against entries in RESTAPIErrors.properties. * * @param response Response. * @param errorCode API error code. diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementBaseTest.java index 2913cf35d32..326c1f532e4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementBaseTest.java @@ -86,7 +86,7 @@ public void init(ITestContext context) throws Exception { orgId = SUPER_ORGANIZATION_ID; } this.subOrganizationId = orgId; - if (this.organizationType.name().equals("SUPER_ORGANIZATION")) { + if (OrganizationType.SUPER_ORGANIZATION.equals(this.organizationType)) { super.testInitWithoutTenantQualifiedPath(API_VERSION, swaggerDefinition); } else { this.tenant = subOrganizationId; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementFailureTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementFailureTest.java index f5dd55f002a..d75de0cfa6e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementFailureTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementFailureTest.java @@ -19,6 +19,7 @@ package org.wso2.identity.integration.test.rest.api.server.organization.management.v1; import io.restassured.response.Response; +import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.testng.annotations.AfterMethod; @@ -52,7 +53,7 @@ public void testCreateOrganizationWithoutRequiredField() throws Exception { JSONObject organizationObject = new JSONObject(); String parentId; - if (organizationType.name().equals("SUPER_ORGANIZATION")) { + if (OrganizationType.SUPER_ORGANIZATION.equals(this.organizationType)) { parentId = SUPER_ORGANIZATION_NAME; } else { parentId = subOrganizationId; @@ -70,12 +71,12 @@ public void testCreateOrganizationWithABlankName() throws Exception { JSONObject organizationObject = new JSONObject(); String parentId; - if (organizationType.name().equals("SUPER_ORGANIZATION")) { + if (OrganizationType.SUPER_ORGANIZATION.equals(this.organizationType)) { parentId = SUPER_ORGANIZATION_NAME; } else { parentId = subOrganizationId; } - organizationObject.put(ORGANIZATION_NAME, ""); + organizationObject.put(ORGANIZATION_NAME, StringUtils.EMPTY); organizationObject.put(ORGANIZATION_PARENT_ID, parentId); String payload = organizationObject.toString(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementSuccessTest.java index 5733df3c029..5c624cde9c7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/organization/management/v1/OrganizationManagementSuccessTest.java @@ -70,7 +70,7 @@ public void createOrganization() throws Exception { String org; String parentId; - if (organizationType.name().equals("SUPER_ORGANIZATION")) { + if (OrganizationType.SUPER_ORGANIZATION.equals(this.organizationType)) { org = "Level1Org"; parentId = SUPER_ORGANIZATION_NAME; } else {