Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c653005652 | ||
|
|
ceb448c1ff | ||
|
|
8c651aec2b | ||
|
|
56fac84e12 | ||
|
|
8b3a0c1570 | ||
|
|
516a185546 |
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
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.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
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.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
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,7 +3,6 @@ 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'
|
||||||
@@ -46,15 +45,6 @@ dependencies {
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
finalizedBy jacocoTestReport
|
|
||||||
}
|
|
||||||
|
|
||||||
jacocoTestReport {
|
|
||||||
dependsOn test
|
|
||||||
}
|
|
||||||
|
|
||||||
jacoco {
|
|
||||||
toolVersion = "0.8.8"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jlink {
|
jlink {
|
||||||
|
|||||||
@@ -4,117 +4,44 @@ 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;
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
|
||||||
private final URL dbDataSource = this.getClass().getResource("taskdb.json");
|
|
||||||
private final URL testFile = this.getClass().getResource("test-taskdb.json");
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void connectToDb() throws URISyntaxException, IOException {
|
void connectToDb() {
|
||||||
assertNotNull(testFile);
|
// testDatabase = new JsonTaskDatabase();
|
||||||
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(LocalDate.parse("30.04.2022", formatter),
|
taskList = testDatabase.getTaskList(formatter.parse("01.05.2022"), formatter.parse("01.08.2022"));
|
||||||
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.assertEquals(3, taskList.size());
|
Assertions.assertTrue(taskList.size()>0);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//@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() {
|
||||||
List<Task> taskList = null;
|
// TODO implement Test
|
||||||
try {
|
|
||||||
taskList = testDatabase.getTaskForCrop(0);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assertions.assertEquals(6, taskList.size());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void removeTasksForCrop() {
|
void removeTasksForCrop() {
|
||||||
List<Task> taskList = null;
|
// TODO implement Test
|
||||||
try {
|
|
||||||
testDatabase.removeTasksForCrop(0);
|
|
||||||
taskList = testDatabase.getTaskForCrop(0);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assertions.assertEquals(0, taskList.size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"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