diff --git a/exec/pom.xml b/exec/pom.xml
index 803c4ad..c4293e4 100755
--- a/exec/pom.xml
+++ b/exec/pom.xml
@@ -4,7 +4,7 @@
org.smartregister
opensrp-gateway-plugin
- 2.0.4
+ 2.0.5
exec
@@ -70,7 +70,7 @@
org.smartregister
plugins
- 2.0.4
+ 2.0.5
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 328bcab..e17ccd6 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -4,7 +4,7 @@
org.smartregister
opensrp-gateway-plugin
- 2.0.4
+ 2.0.5
plugins
diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java
index a931c8a..24c1f9f 100644
--- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java
+++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java
@@ -411,6 +411,9 @@ public List generateAdminLevels(
public List filterLocationsByAdminLevels(
List locations, List postFetchAdminLevels) {
+ if (postFetchAdminLevels == null) {
+ return locations;
+ }
List allLocations = new ArrayList<>();
for (Location location : locations) {
for (CodeableConcept codeableConcept : location.getType()) {
diff --git a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java
index 184d8d0..62a14c5 100644
--- a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java
+++ b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java
@@ -299,6 +299,21 @@ public void testFilterLocationsByAdminLevelsBasic() {
Assert.assertEquals("3", filteredLocations.get(1).getId());
}
+ @Test
+ public void testFilterLocationsByAdminLevelsWithNullAdminLevelsDoesNotFilter() {
+ List locations = createLocationList(5, true);
+
+ List 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");
diff --git a/pom.xml b/pom.xml
index c2a3ac3..871b1cd 100755
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
org.smartregister
opensrp-gateway-plugin
- 2.0.4
+ 2.0.5
pom