Skip to content

Commit

Permalink
Merge pull request #110 from ELEVATE-Project/JubedhEP
Browse files Browse the repository at this point in the history
adding testcase for Entity CRUD Operations
  • Loading branch information
Jubedhashaik authored Nov 18, 2024
2 parents 79c0383 + f04f9bf commit a2f4464
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions Elevate_QA_API.xml
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@
<include name="testFetchValidEntityDetails"/>
<include name="testMappingEntities"/>
<include name="fetchEntityListBasedOnEntityId"/>
<include name="testFetchTargetedRolesForEntity"/>
</methods>
</class>
</classes>
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit a2f4464

Please sign in to comment.