diff --git a/src/main/java/ch/zhaw/gartenverwaltung/plantList/PlantListModel.java b/src/main/java/ch/zhaw/gartenverwaltung/plantList/PlantListModel.java index 7039476..8e8a1b8 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/plantList/PlantListModel.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/plantList/PlantListModel.java @@ -110,7 +110,9 @@ public class PlantListModel { * @throws IOException If the database cannot be accessed */ public List getFilteredPlantListByString(HardinessZone zone, String searchString) throws HardinessZoneNotSetException, IOException { - if(searchString.charAt(0) == '#') { + if(searchString.length() == 0){ + return getPlantList(zone); + } else if(searchString.charAt(0) == '#') { try { return getFilteredPlantListById(zone, Long.parseLong(searchString.substring(1))); } catch (NumberFormatException e) { diff --git a/src/test/java/ch/zhaw/gartenverwaltung/plantList/PlantListModelTest.java b/src/test/java/ch/zhaw/gartenverwaltung/plantList/PlantListModelTest.java index 2bf6853..9ed857d 100644 --- a/src/test/java/ch/zhaw/gartenverwaltung/plantList/PlantListModelTest.java +++ b/src/test/java/ch/zhaw/gartenverwaltung/plantList/PlantListModelTest.java @@ -173,6 +173,8 @@ class PlantListModelTest { assertEquals(examplePlantList.get(1), plantListResult.get(0)); plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "apple"); assertEquals(0, plantListResult.size()); + plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, ""); + assertEquals(3, plantListResult.size()); } @Test