Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
 Handle null adminlevels in post filtering location hierarchy
  • Loading branch information
lincmba committed Aug 5, 2024
1 parent efab847 commit c78b77a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
</parent>

<artifactId>exec</artifactId>
Expand Down Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>org.smartregister</groupId>
<artifactId>plugins</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
</parent>

<artifactId>plugins</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ public List<String> generateAdminLevels(

public List<Location> filterLocationsByAdminLevels(
List<Location> locations, List<String> postFetchAdminLevels) {
if (postFetchAdminLevels == null) {
return locations;
}
List<Location> allLocations = new ArrayList<>();
for (Location location : locations) {
for (CodeableConcept codeableConcept : location.getType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,21 @@ public void testFilterLocationsByAdminLevelsBasic() {
Assert.assertEquals("3", filteredLocations.get(1).getId());
}

@Test
public void testFilterLocationsByAdminLevelsWithNullAdminLevelsDoesNotFilter() {
List<Location> locations = createLocationList(5, true);

List<Location> filteredLocations =
locationHierarchyEndpointHelper.filterLocationsByAdminLevels(locations, null);

Assert.assertEquals(5, filteredLocations.size());
Assert.assertEquals("0", filteredLocations.get(0).getId());
Assert.assertEquals("1", filteredLocations.get(1).getId());
Assert.assertEquals("2", filteredLocations.get(2).getId());
Assert.assertEquals("3", filteredLocations.get(3).getId());
Assert.assertEquals("4", filteredLocations.get(4).getId());
}

private Bundle getLocationBundle() {
Bundle bundleLocation = new Bundle();
bundleLocation.setId("Location/1234");
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<packaging>pom</packaging>

<modules>
Expand Down

0 comments on commit c78b77a

Please sign in to comment.