Skip to content

Commit

Permalink
Merge pull request #77 from onaio/bug_fix_null_admin_levels
Browse files Browse the repository at this point in the history
Bug Fix
  • Loading branch information
dubdabasoduba authored Aug 6, 2024
2 parents efab847 + c78b77a commit 17c78a2
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 17c78a2

Please sign in to comment.