diff --git a/src/test/java/ch/zhaw/gartenverwaltung/io/JsonPlantListTest.java b/src/test/java/ch/zhaw/gartenverwaltung/io/JsonPlantListTest.java index b28c486..4ceeb25 100644 --- a/src/test/java/ch/zhaw/gartenverwaltung/io/JsonPlantListTest.java +++ b/src/test/java/ch/zhaw/gartenverwaltung/io/JsonPlantListTest.java @@ -95,5 +95,16 @@ public class JsonPlantListTest { } + @Test + void testDefaultConstructor(){ + JsonPlantList db = new JsonPlantList(); + try { + assertNotNull(db.getPlantList(HardinessZone.ZONE_8A)); + } catch (IOException | HardinessZoneNotSetException e) { + throw new RuntimeException(e); + } + + } + } diff --git a/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskListTest.java b/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskListTest.java index 359ea9a..00e21e3 100644 --- a/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskListTest.java +++ b/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskListTest.java @@ -2,6 +2,8 @@ package ch.zhaw.gartenverwaltung.io; import ch.zhaw.gartenverwaltung.types.Task; import org.junit.jupiter.api.*; +import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; import java.io.IOException; import java.net.URISyntaxException; @@ -14,6 +16,8 @@ import java.time.format.DateTimeFormatter; import java.util.List; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; public class JsonTaskListTest { @@ -113,4 +117,27 @@ public class JsonTaskListTest { Assertions.assertEquals(0, taskList.size()); } + + @Test + void testDefaultConstructor(){ + JsonTaskList db = new JsonTaskList(); + try { + assertNotNull(db.getTaskForCrop(0)); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + + @Test + void testSubscription() { + TaskList.TaskListObserver mockObs = Mockito.mock(TaskList.TaskListObserver.class); + testDatabase.subscribe(mockObs); + try { + testDatabase.removeTasksForCrop(0); + } catch (IOException e) { + throw new RuntimeException(e); + } + verify(mockObs, times(1)).onChange(ArgumentMatchers.anyList()); + } } \ No newline at end of file