From 81a4e7c50320d69d0b7fe2c8b174e91ad64021ff Mon Sep 17 00:00:00 2001 From: megala21 Date: Thu, 20 Apr 2017 09:15:02 +0530 Subject: [PATCH] Fixing test case failure --- .../wso2/iot/integration/role/RoleManagement.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/role/RoleManagement.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/role/RoleManagement.java index 9ab7e675..d25076b2 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/role/RoleManagement.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/role/RoleManagement.java @@ -18,6 +18,7 @@ package org.wso2.iot.integration.role; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonParser; import junit.framework.Assert; import org.apache.commons.httpclient.HttpStatus; @@ -104,6 +105,7 @@ public class RoleManagement extends TestBase { @Test(description = "Test updating users with a given role.", dependsOnMethods = {"testGetRole"}) public void testUpdateRolesOfUser() throws FileNotFoundException, XPathExpressionException { + boolean isRoleNameExist = false; IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/users", PayloadGenerator.getJsonArray(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.RoleManagement.UPDATE_ROLES_METHOD).toString()); @@ -118,8 +120,16 @@ public class RoleManagement extends TestBase { JsonArray jsonArray = new JsonParser().parse(response.getBody()).getAsJsonObject().get("roles") .getAsJsonArray(); Assert.assertEquals("Error while retrieving the role details", HttpStatus.SC_OK, response.getStatus()); - Assert.assertEquals("The user is not updated with the roles list", "\"" + ROLE_NAME + "\"", - jsonArray.get(0).toString()); + + for (JsonElement jsonElement:jsonArray) { + if (jsonElement.getAsString().equals(ROLE_NAME)) { + isRoleNameExist = true; + break; + } + } + if (!isRoleNameExist) { + Assert.fail("The user is not assigned with the new role " + ROLE_NAME); + } } @Test(description = "Test remove user.", dependsOnMethods = {"testUpdateRolesOfUser"})