From 516a185546a2e03ed735fdca69bf51c71c1b85c8 Mon Sep 17 00:00:00 2001 From: Roman Schenk Date: Tue, 18 Oct 2022 11:18:36 +0200 Subject: [PATCH 1/5] Update issue templates --- .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From 8b3a0c1570522f3c85037876f194673ca70afaeb Mon Sep 17 00:00:00 2001 From: Roman Schenk Date: Tue, 18 Oct 2022 11:19:24 +0200 Subject: [PATCH 2/5] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +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. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. From 8c651aec2b6ec3ecc4e47146c2f33e3e72ce0395 Mon Sep 17 00:00:00 2001 From: Roman Schenk Date: Thu, 20 Oct 2022 20:02:18 +0200 Subject: [PATCH 3/5] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 21 +++++---------------- .github/ISSUE_TEMPLATE/feature_request.md | 14 +++++++------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7..a9019a2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,8 +1,8 @@ --- name: Bug report -about: Create a report to help us improve -title: '' -labels: '' +about: Create a report to document bugs. +title: "[BUG]" +labels: bug assignees: '' --- @@ -20,19 +20,8 @@ Steps to reproduce the behavior: **Expected behavior** A clear and concise description of what you expected to happen. -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] +**Class / Methods** +List of classes or methods which contains the bug. (If known) **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7..3ec670c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,20 +1,20 @@ --- name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' +about: Features to implement +title: "[FEATURE]" +labels: feature assignees: '' --- -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] +**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. -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. +**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. From ceb448c1ff8d93bfdd8d684d167191ce6a063889 Mon Sep 17 00:00:00 2001 From: Roman Schenk Date: Thu, 20 Oct 2022 20:05:31 +0200 Subject: [PATCH 4/5] Update issue templates --- .github/ISSUE_TEMPLATE/tests.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/tests.md diff --git a/.github/ISSUE_TEMPLATE/tests.md b/.github/ISSUE_TEMPLATE/tests.md new file mode 100644 index 0000000..31c646c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/tests.md @@ -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. From 6737e67cda643a6c655785684f50b0b441fd41f4 Mon Sep 17 00:00:00 2001 From: Elias Csomor Date: Sun, 13 Nov 2022 16:30:53 +0100 Subject: [PATCH 5/5] Task Test Copied over from dev --- .../io/JsonTaskDatabaseTest.java | 106 +++++++++++++++--- .../zhaw/gartenverwaltung/io/test-taskdb.json | 56 +++++++++ 2 files changed, 146 insertions(+), 16 deletions(-) create mode 100644 src/test/resources/ch/zhaw/gartenverwaltung/io/test-taskdb.json diff --git a/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskDatabaseTest.java b/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskDatabaseTest.java index d3710ab..255117e 100644 --- a/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskDatabaseTest.java +++ b/src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskDatabaseTest.java @@ -4,44 +4,118 @@ import ch.zhaw.gartenverwaltung.types.Task; import org.junit.jupiter.api.*; 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.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class JsonTaskDatabaseTest { TaskDatabase testDatabase; - SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy"); - @BeforeEach - void connectToDb() { - // testDatabase = new JsonTaskDatabase(); - } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); + 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 @DisplayName("Check if results are retrieved completely") - void getTasks(){ - /* - List taskList=null; + void getTasks() { + + List 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 adding 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 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 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 void getTaskForCrop() { - // TODO implement Test + List taskList = null; + try { + taskList = testDatabase.getTaskForCrop(0); + } catch (IOException e) { + throw new RuntimeException(e); + } + + Assertions.assertEquals(6, taskList.size()); + } + @Disabled("Disabled until removing works") @Test void removeTasksForCrop() { - // TODO implement Test + List taskList = null; + try { + testDatabase.removeTasksForCrop(0); + taskList = testDatabase.getTaskForCrop(0); + } catch (IOException e) { + throw new RuntimeException(e); + } + + Assertions.assertEquals(0, taskList.size()); } -} +} \ No newline at end of file diff --git a/src/test/resources/ch/zhaw/gartenverwaltung/io/test-taskdb.json b/src/test/resources/ch/zhaw/gartenverwaltung/io/test-taskdb.json new file mode 100644 index 0000000..7728bb0 --- /dev/null +++ b/src/test/resources/ch/zhaw/gartenverwaltung/io/test-taskdb.json @@ -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 + } +] \ No newline at end of file