FINERACT-1658:GroupFilter_In_Center
This commit is contained in:
committed by
Arnold Gálovics
parent
c2d5a735d6
commit
e4e5fc0ceb
+6
-3
@@ -185,6 +185,12 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
|
||||
sqlBuilder.append(" ").append(extraCriteria.getSQLTemplate());
|
||||
|
||||
if (searchParameters != null) {
|
||||
if (searchParameters.isOrphansOnly()) {
|
||||
sqlBuilder.append(" and g.parent_id is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
if (parameters != null) {
|
||||
if (parameters.isOrderByRequested()) {
|
||||
sqlBuilder.append(parameters.orderBySql());
|
||||
@@ -226,9 +232,6 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
}
|
||||
extraCriteria.addNonNullCriteria("g.staff_id =", searchCriteria.getStaffId());
|
||||
|
||||
if (searchCriteria.isOrphansOnly()) {
|
||||
extraCriteria.addNonNullCriteria("g.parent_id IS", "NULL");
|
||||
}
|
||||
return extraCriteria;
|
||||
}
|
||||
|
||||
|
||||
+25
@@ -32,6 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import org.apache.fineract.integrationtests.common.CenterDomain;
|
||||
import org.apache.fineract.integrationtests.common.CenterHelper;
|
||||
import org.apache.fineract.integrationtests.common.GroupHelper;
|
||||
import org.apache.fineract.integrationtests.common.OfficeHelper;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
|
||||
@@ -259,4 +260,28 @@ public class CenterIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCentersOrphanGroups() {
|
||||
|
||||
int officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
|
||||
|
||||
String name = "TestBasicCreation" + new Timestamp(new java.util.Date().getTime());
|
||||
int resourceId = CenterHelper.createCenter(name, officeId, requestSpec, responseSpec);
|
||||
CenterDomain center = CenterHelper.retrieveByID(resourceId, requestSpec, responseSpec);
|
||||
|
||||
Assertions.assertNotNull(center);
|
||||
|
||||
int id = CenterHelper.listCenters(requestSpec, responseSpec).get(0).getId();
|
||||
Assertions.assertTrue(id > 0);
|
||||
|
||||
CenterDomain retrievedCenter = CenterHelper.retrieveByID(id, requestSpec, responseSpec);
|
||||
Assertions.assertNotNull(retrievedCenter);
|
||||
Assertions.assertNotNull(retrievedCenter.getName());
|
||||
Assertions.assertNotNull(retrievedCenter.getHierarchy());
|
||||
Assertions.assertNotNull(retrievedCenter.getOfficeName());
|
||||
|
||||
int[] groupMembers = generateGroupMembers(2, officeId);
|
||||
CenterHelper.associateGroups(resourceId, groupMembers, requestSpec, responseSpec);
|
||||
GroupHelper.verifyOrphanGroupDetails(requestSpec, responseSpec, officeId);
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -230,6 +230,15 @@ public class GroupHelper {
|
||||
assertTrue(list.toString().contains("id=" + groupMember.toString()), "ERROR IN GROUP MEMBER");
|
||||
}
|
||||
|
||||
public static void verifyOrphanGroupDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
int officeId) {
|
||||
LOG.info("------------------------------CHECK ORPHAN GROUP DETAILS------------------------------------\n");
|
||||
final String GROUP_URL = "/fineract-provider/api/v1/groups" + "?officeId=" + officeId + "&orphansOnly=true&"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
final String responseValue = Utils.performGetTextResponse(requestSpec, responseSpec, GROUP_URL);
|
||||
assertEquals("[]", responseValue); // Since, all groups got center as Parent, OrphanGroups is null.
|
||||
}
|
||||
|
||||
public static void verifyEmptyGroupMembers(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID) {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user