Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7fa58344c | ||
|
|
6523e1d791 |
@@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to document bugs.
|
|
||||||
title: "[BUG]"
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Class / Methods**
|
|
||||||
List of classes or methods which contains the bug. (If known)
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Features to implement
|
|
||||||
title: "[FEATURE]"
|
|
||||||
labels: feature
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Description of Usecase**
|
|
||||||
A clear and concise description of what the feature allows to do.
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**List of Classes and Methods to implement**
|
|
||||||
List all Classes and Methods which have to be implemented.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Tests
|
|
||||||
about: Tests to implement
|
|
||||||
title: "[TEST]"
|
|
||||||
labels: Tests
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Feature description**
|
|
||||||
A clear and concise description of the functionality which have to be tested.
|
|
||||||
|
|
||||||
**Test cases**
|
|
||||||
A list of cases which have to be tested.
|
|
||||||
|
|
||||||
**List of affected Classes and Methods**
|
|
||||||
A clear and concise list of the classes and methods which have to be tested.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
@@ -3,6 +3,7 @@ plugins {
|
|||||||
id 'application'
|
id 'application'
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.13'
|
id 'org.openjfx.javafxplugin' version '0.0.13'
|
||||||
id 'org.beryx.jlink' version '2.25.0'
|
id 'org.beryx.jlink' version '2.25.0'
|
||||||
|
id 'jacoco'
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'ch.zhaw.gartenverwaltung'
|
group 'ch.zhaw.gartenverwaltung'
|
||||||
@@ -45,6 +46,15 @@ dependencies {
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
|
finalizedBy jacocoTestReport
|
||||||
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
dependsOn test
|
||||||
|
}
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.8.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
jlink {
|
jlink {
|
||||||
|
|||||||
@@ -4,44 +4,117 @@ import ch.zhaw.gartenverwaltung.types.Task;
|
|||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class JsonTaskDatabaseTest {
|
public class JsonTaskDatabaseTest {
|
||||||
|
|
||||||
TaskDatabase testDatabase;
|
TaskDatabase testDatabase;
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||||
@BeforeEach
|
|
||||||
void connectToDb() {
|
|
||||||
// testDatabase = new JsonTaskDatabase();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private final URL dbDataSource = this.getClass().getResource("taskdb.json");
|
||||||
|
private final URL testFile = this.getClass().getResource("test-taskdb.json");
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void connectToDb() throws URISyntaxException, IOException {
|
||||||
|
assertNotNull(testFile);
|
||||||
|
assertNotNull(dbDataSource);
|
||||||
|
Files.copy(Path.of(testFile.toURI()), Path.of(dbDataSource.toURI()), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
testDatabase = new JsonTaskDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Check if results are retrieved completely")
|
@DisplayName("Check if results are retrieved completely")
|
||||||
void getTasks(){
|
void getTasks() {
|
||||||
/*
|
|
||||||
List<Task> taskList=null;
|
List<Task> taskList = null;
|
||||||
try {
|
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) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(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), 1);
|
||||||
|
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), 1).withId(2);
|
||||||
|
try {
|
||||||
|
testDatabase.removeTask(task);
|
||||||
|
List<Task> taskList = null;
|
||||||
|
|
||||||
|
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
||||||
|
LocalDate.parse("31.05.2022", formatter));
|
||||||
|
|
||||||
|
Assertions.assertEquals(2, taskList.size());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getTaskForCrop() {
|
void getTaskForCrop() {
|
||||||
// TODO implement Test
|
List<Task> taskList = null;
|
||||||
|
try {
|
||||||
|
taskList = testDatabase.getTaskForCrop(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assertions.assertEquals(6, taskList.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void removeTasksForCrop() {
|
void removeTasksForCrop() {
|
||||||
// TODO implement Test
|
List<Task> taskList = null;
|
||||||
|
try {
|
||||||
|
testDatabase.removeTasksForCrop(0);
|
||||||
|
taskList = testDatabase.getTaskForCrop(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assertions.assertEquals(0, taskList.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id" : 1,
|
||||||
|
"name" : "sow plant",
|
||||||
|
"description": "Plant the seeds, crops in de bed.",
|
||||||
|
"startDate" : "2022-05-01",
|
||||||
|
"endDate" : "2022-05-01",
|
||||||
|
"interval" : 0,
|
||||||
|
"cropId" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 2,
|
||||||
|
"name" : "water plant",
|
||||||
|
"description": "water the plant, so that the soil is wet around the plant.",
|
||||||
|
"startDate" : "2022-05-01",
|
||||||
|
"endDate" : "2022-09-01",
|
||||||
|
"interval" : 2,
|
||||||
|
"cropId" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 3,
|
||||||
|
"name" : "fertilize plant",
|
||||||
|
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
||||||
|
"startDate" : "2022-06-01",
|
||||||
|
"endDate" : "2022-08-01",
|
||||||
|
"interval" : 28,
|
||||||
|
"cropId" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 4,
|
||||||
|
"name" : "covering plant",
|
||||||
|
"description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage",
|
||||||
|
"startDate" : "2022-07-01",
|
||||||
|
"endDate" : "2022-07-01",
|
||||||
|
"interval" : 0,
|
||||||
|
"cropId" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 5,
|
||||||
|
"name" : "look after plant",
|
||||||
|
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
||||||
|
"startDate" : "2022-05-01",
|
||||||
|
"endDate" : "2022-09-01",
|
||||||
|
"interval" : 5,
|
||||||
|
"cropId" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 6,
|
||||||
|
"name" : "harvest plant",
|
||||||
|
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
||||||
|
"startDate" : "2022-09-01",
|
||||||
|
"endDate" : "2022-09-01",
|
||||||
|
"interval" : 0,
|
||||||
|
"cropId" : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user