Compare commits
2 Commits
f452b73233
...
6c00b7f182
Author | SHA1 | Date |
---|---|---|
gulerdav | 6c00b7f182 | |
schrom01 | 98ff259d95 |
|
@ -110,7 +110,9 @@ public class PlantListModel {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<Plant> getFilteredPlantListByString(HardinessZone zone, String searchString) throws HardinessZoneNotSetException, IOException {
|
public List<Plant> 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 {
|
try {
|
||||||
return getFilteredPlantListById(zone, Long.parseLong(searchString.substring(1)));
|
return getFilteredPlantListById(zone, Long.parseLong(searchString.substring(1)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
|
@ -173,6 +173,8 @@ class PlantListModelTest {
|
||||||
assertEquals(examplePlantList.get(1), plantListResult.get(0));
|
assertEquals(examplePlantList.get(1), plantListResult.get(0));
|
||||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "apple");
|
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "apple");
|
||||||
assertEquals(0, plantListResult.size());
|
assertEquals(0, plantListResult.size());
|
||||||
|
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "");
|
||||||
|
assertEquals(3, plantListResult.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue