Extended coverage for tests

This commit is contained in:
Elias Csomor 2022-11-26 12:49:42 +01:00
parent 4e720c2ddc
commit 560cea2ff9
2 changed files with 38 additions and 0 deletions

View File

@ -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);
}
}
}

View File

@ -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());
}
}