Skip to content

Commit

Permalink
Merge pull request #112 from ELEVATE-Project/Suhas_local
Browse files Browse the repository at this point in the history
Entity CRUD operations
  • Loading branch information
SuhasVMM authored Nov 18, 2024
2 parents b41c548 + 8496853 commit ece295a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Elevate_QA_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<include name="testMappingEntities"/>
<include name="fetchEntityListBasedOnEntityId"/>
<include name="testFetchTargetedRolesForEntity"/>
<include name="testValidRelatedEntitiesBasedOnEntity"/>
<include name="testInvalidRelatedEntitiesBasedOnEntity"/>
<include name="testValidEntityDetails"/>
<include name="testInvalidEntityDetails"/>
</methods>
</class>
</classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ 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/
elevate.qa.targetedroles.endpoint=entity-management/v1/entities/targetedRoles/
elevate.qa.entity.realated.entities=entity-management/v1/entities/relatedEntities/
elevate.qa.entity.detailsbasedon.entityid.endpoint=entity-management/v1/entities/details/
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,51 @@ public void testFetchTargetedRolesForEntity() {
logger.info("validation related to entity targeted roles is verified");
}

@Test(description = "Test case for fetching entity related entities")
public void testValidRelatedEntitiesBasedOnEntity() {
getEntityId(PropertyLoader.PROP_LIST.getProperty("elevate.qa.parent.entity.externalId"));
Response response = relatedEntitiesBasedOnEntityId(entity_Id);
Assert.assertEquals(response.getStatusCode(), 200);
Assert.assertEquals(response.jsonPath().get("message"), "ENTITY_FETCHED");
logger.info("Validations related to fetching entity related entities is verified");
}

@Test(description = "Negative test case for fetching entity related entities with out the path parameter")
public void testInvalidRelatedEntitiesBasedOnEntity() {
Response response = given()
.header("internal-access-token", INTERNAL_ACCESS_TOKEN)
.header("x-auth-token", X_AUTH_TOKEN)
.header("Content-Type", "application/json")
.get("entity-management/v1/entities/relatedEntities");
response.prettyPrint();
Assert.assertEquals(response.getStatusCode(), 400);
Assert.assertTrue(response.asString().contains("required Entity id"));
logger.info("Validation related to Invalid fetching of entity related entities is verified");
}


@Test(dependsOnMethods = "testAddingValidEntity", description = "Test case to get entity details using entity Id")
public void testValidEntityDetails() {
Response response = ENtitydetailsBasedonEntityId(entity_Id);
Assert.assertEquals(response.getStatusCode(), 200);
Assert.assertEquals(response.jsonPath().getString("message"), "ENTITY_INFORMATION_FETCHED");
logger.info("Validations related to getting entity details using entity Id is verified");
}

@Test(description = "Negative test case to get entity details without path parameter")
public void testInvalidEntityDetails() {
Response response = given()
.header("internal-access-token", INTERNAL_ACCESS_TOKEN)
.header("x-auth-token", X_AUTH_TOKEN)
.header("Content-Type", "application/json")
.get("entity-management/v1/entities/details");
response.prettyPrint();
Assert.assertEquals(response.getStatusCode(), 400);
Assert.assertTrue(response.asString().contains("required state location id"));
logger.info("Validations related to getting entity details without path parameter is verified");

}

// Method to add the entity
private Response addEntity(String entityName, String externalId, String entityTypeName) {
getEntitytype_Id(entityTypeName);
Expand Down Expand Up @@ -262,4 +307,28 @@ private Response fetchTargetedRoles(String entityId) {
response.prettyPrint();
return response;
}

//Method to fetch related entities based on entity ID
private Response relatedEntitiesBasedOnEntityId(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("_id", entityid)
.get(PropertyLoader.PROP_LIST.getProperty("elevate.qa.entity.realated.entities") + "{_id}");
response.prettyPrint();
return response;
}

//Method to fetch entity details based on entity ID
private Response ENtitydetailsBasedonEntityId(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("_id", entityid)
.get(PropertyLoader.PROP_LIST.getProperty("elevate.qa.entity.detailsbasedon.entityid.endpoint") + "{_id}");
response.prettyPrint();
return response;
}
}

0 comments on commit ece295a

Please sign in to comment.