Extended test for zones
This commit is contained in:
parent
bfbda8d753
commit
ee96ffbc52
|
@ -26,11 +26,13 @@ public class JsonPlantDatabaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Check if results are retrieved completely")
|
@DisplayName("Check if results are retrieved completely")
|
||||||
void getPlantList() {
|
void getPlantListNotEmpty() {
|
||||||
List<Plant> testList;
|
List<Plant> testList;
|
||||||
try {
|
try {
|
||||||
testList = testDatabase.getPlantList(HardinessZone.ZONE_8A);
|
testList = testDatabase.getPlantList(HardinessZone.ZONE_8A);
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (HardinessZoneNotSetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
Assertions.assertEquals(3, testList.size());
|
Assertions.assertEquals(3, testList.size());
|
||||||
|
@ -40,13 +42,50 @@ public class JsonPlantDatabaseTest {
|
||||||
Assertions.assertEquals(expected,names);
|
Assertions.assertEquals(expected,names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Check if results are retrieved correctly when empty")
|
||||||
|
void getPlantListEmpty() {
|
||||||
|
List<Plant> testList;
|
||||||
|
try {
|
||||||
|
testList = testDatabase.getPlantList(HardinessZone.ZONE_1A);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (HardinessZoneNotSetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
Assertions.assertEquals(0, testList.size());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Check whether single access works.")
|
@DisplayName("Check whether single access works.")
|
||||||
void getPlantById() {
|
void getPlantByIdAndZone() {
|
||||||
Optional<Plant> testPlant;
|
Optional<Plant> testPlant;
|
||||||
try {
|
try {
|
||||||
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 1);
|
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 1);
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (HardinessZoneNotSetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
Assertions.assertTrue(testPlant.isPresent());
|
||||||
|
Assertions.assertEquals("Early Carrot", testPlant.get().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Check whether single access respects zone correctly.")
|
||||||
|
void getPlantByIdAndWrongZone() {
|
||||||
|
Optional<Plant> testPlant;
|
||||||
|
try {
|
||||||
|
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_1A, 1);
|
||||||
|
Assertions.assertFalse(testPlant.isPresent());
|
||||||
|
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 1);
|
||||||
|
Assertions.assertTrue(testPlant.isPresent());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (HardinessZoneNotSetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
Assertions.assertTrue(testPlant.isPresent());
|
Assertions.assertTrue(testPlant.isPresent());
|
||||||
|
@ -59,7 +98,9 @@ public class JsonPlantDatabaseTest {
|
||||||
Optional<Plant> testPlant;
|
Optional<Plant> testPlant;
|
||||||
try {
|
try {
|
||||||
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 99);
|
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 99);
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (HardinessZoneNotSetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
Assertions.assertFalse(testPlant.isPresent());
|
Assertions.assertFalse(testPlant.isPresent());
|
||||||
|
@ -68,4 +109,3 @@ public class JsonPlantDatabaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue