From f04f9bf3da2ec9196b69e580c0f2fa4b4b4e488d Mon Sep 17 00:00:00 2001 From: Shaikjubedha Date: Mon, 18 Nov 2024 09:47:24 +0530 Subject: [PATCH] adding testcase for Entity CRUD Operations --- Elevate_QA_API.xml | 1 + .../Automation_ElevateAPI_QA.properties | 1 + .../ep/TestElevateEntityCRUDOperations.java | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Elevate_QA_API.xml b/Elevate_QA_API.xml index e7dad6c..995807d 100644 --- a/Elevate_QA_API.xml +++ b/Elevate_QA_API.xml @@ -52,6 +52,7 @@ + diff --git a/src/main/resources/config/Automation_ElevateAPI_QA.properties b/src/main/resources/config/Automation_ElevateAPI_QA.properties index ee481e0..2822d39 100644 --- a/src/main/resources/config/Automation_ElevateAPI_QA.properties +++ b/src/main/resources/config/Automation_ElevateAPI_QA.properties @@ -29,3 +29,4 @@ elevate.qa.fetchentity.list.endpoint=entity-management/v1/entities/list/ elevate.qa.mapping.entity.endpoint=entity-management/v1/entities/mappingUpload elevate.qa.update.entitytype.name=school elevate.qa.parent.entity.externalId=Automation_ExternalId123 +elevate.qa.targetedroles.endpoint=entity-management/v1/entities/targetedRoles \ No newline at end of file diff --git a/src/test/java/org/shikshalokam/backend/ep/TestElevateEntityCRUDOperations.java b/src/test/java/org/shikshalokam/backend/ep/TestElevateEntityCRUDOperations.java index 3aaa863..e2d0f4d 100644 --- a/src/test/java/org/shikshalokam/backend/ep/TestElevateEntityCRUDOperations.java +++ b/src/test/java/org/shikshalokam/backend/ep/TestElevateEntityCRUDOperations.java @@ -25,6 +25,8 @@ public class TestElevateEntityCRUDOperations extends ElevateProjectBaseTest { private String randomExternalId = RandomStringUtils.randomAlphabetic(10); private String updatedEntityName = RandomStringUtils.randomAlphabetic(10); private String updatedEntityExternalId = RandomStringUtils.randomAlphabetic(10); + private String userRolenametitle = RandomStringUtils.randomAlphabetic(10); + private String userRoleId = RandomStringUtils.randomAlphabetic(10); @BeforeMethod public void setUp() { @@ -128,6 +130,19 @@ public void fetchEntityListBasedOnEntityId() { logger.info("Validations related to fetching entity list based on entity Id is verified"); } + @Test(description = "Fetch targeted roles for updated entity") + public void testFetchTargetedRolesForEntity() { + createUserRoleExtension(userRolenametitle, userRoleId, PropertyLoader.PROP_LIST.getProperty("elevate.qa.automation.entitytype.name"), PropertyLoader.PROP_LIST.getProperty("elevate.qa.automation.entitytype.Id")); + getEntityId(PropertyLoader.PROP_LIST.getProperty("elevate.qa.parent.entity.externalId")); + Response response = fetchTargetedRoles(entity_Id); + Assert.assertEquals(response.getStatusCode(), 200, "roles not found"); + Assert.assertTrue(response.asString().contains(userRolenametitle)); + Assert.assertEquals(response.jsonPath().getString("message"), "ROLES_FETCHED_SUCCESSFULLY", "Roles fetching failed"); + List rolesData = response.jsonPath().getList("result.data"); + Assert.assertTrue(rolesData.size() > 0, "Expected non-empty roles data for the entity"); + logger.info("validation related to entity targeted roles is verified"); + } + // Method to add the entity private Response addEntity(String entityName, String externalId, String entityTypeName) { getEntitytype_Id(entityTypeName); @@ -235,4 +250,16 @@ private Response bulkUploadMappingCSV(String targetPath, String endpoint) { response.prettyPrint(); return response; } + + // Method to fetch targeted roles for a given entity ID + private Response fetchTargetedRoles(String entityId) { + Response response = given() + .header("internal-access-token", INTERNAL_ACCESS_TOKEN) + .header("x-auth-token", X_AUTH_TOKEN) + .header("Content-Type", "application/json") + .pathParam("entity_id", entityId) + .get(PropertyLoader.PROP_LIST.getProperty("elevate.qa.targetedroles.endpoint") + "{entity_id}"); + response.prettyPrint(); + return response; + } } \ No newline at end of file