Extended taskDb tests
This commit is contained in:
parent
b79387abc2
commit
2510608117
|
@ -6,32 +6,80 @@ import org.junit.jupiter.api.*;
|
|||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class JsonTaskDatabaseTest {
|
||||
|
||||
TaskDatabase testDatabase;
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
@BeforeEach
|
||||
void connectToDb() {
|
||||
// testDatabase = new JsonTaskDatabase();
|
||||
testDatabase = new JsonTaskDatabase();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Check if results are retrieved completely")
|
||||
void getTasks(){
|
||||
/*
|
||||
|
||||
List<Task> taskList=null;
|
||||
try {
|
||||
taskList = testDatabase.getTaskList(formatter.parse("01.05.2022"), formatter.parse("01.08.2022"));
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022",formatter),
|
||||
LocalDate.parse("31.05.2022",formatter));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Assertions.assertTrue(taskList.size()>0);
|
||||
*/
|
||||
Assertions.assertEquals(3,taskList.size());
|
||||
|
||||
}
|
||||
|
||||
@Disabled("disabled until idProvider works")
|
||||
@Test
|
||||
@DisplayName("Add task.")
|
||||
void addTask(){
|
||||
Task task = new Task("Testtask","This is a test Task.",LocalDate.parse("01.05.2022",formatter));
|
||||
try {
|
||||
testDatabase.saveTask(task);
|
||||
List<Task> taskList=null;
|
||||
try {
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022",formatter),
|
||||
LocalDate.parse("31.05.2022",formatter));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Assertions.assertEquals(4,taskList.size());
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Remove task.")
|
||||
void removeTask(){
|
||||
Task task = new Task("Dummy","Dummy",LocalDate.parse("31.05.2022",formatter)).withId(2);
|
||||
try {
|
||||
testDatabase.removeTask(task);
|
||||
List<Task> taskList=null;
|
||||
try {
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022",formatter),
|
||||
LocalDate.parse("31.05.2022",formatter));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Assertions.assertEquals(2,taskList.size());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue