From 00be979863e4564054064408bb09591344ff9580 Mon Sep 17 00:00:00 2001 From: Gian-Andrea Hutter Date: Fri, 9 Dec 2022 00:08:32 +0100 Subject: [PATCH] #23 implemented test class for WeatherGradenTaskPlanner --- .../weather/WeatherGardenTaskPlannerTest.java | 3 +- .../backgroundtask/weather/test-plantdb.json | 215 ------------------ .../weather/test-user-crops.json | 2 - 3 files changed, 1 insertion(+), 219 deletions(-) delete mode 100644 src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-plantdb.json delete mode 100644 src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-user-crops.json diff --git a/src/test/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGardenTaskPlannerTest.java b/src/test/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGardenTaskPlannerTest.java index 1100165..8222484 100644 --- a/src/test/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGardenTaskPlannerTest.java +++ b/src/test/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGardenTaskPlannerTest.java @@ -19,7 +19,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class WeatherGardenTaskPlannerTest { - private final URL dbDataSource = JsonCropListTest.class.getResource("test-crops.json"); private final URL testFile = JsonCropListTest.class.getResource("test-taskdb.json"); Plant examplePlantOnion; Crop exampleCropOnion; @@ -85,7 +84,7 @@ public class WeatherGardenTaskPlannerTest { taskList.saveTask(exampleTask); weatherGradenTaskPlanner.refreshTasks(); assertEquals(exampleTask.getName(),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(0).getName()); - assertEquals(LocalDate.of(2022,12,10),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(0).getNextExecution()); + assertEquals(LocalDate.now().plusDays(2L),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(0).getNextExecution()); assertEquals(exampleWeatherTask.getName(),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(1).getName()); assertEquals(exampleWeatherTask.getStartDate(),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(1).getStartDate()); } diff --git a/src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-plantdb.json b/src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-plantdb.json deleted file mode 100644 index abd61ef..0000000 --- a/src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-plantdb.json +++ /dev/null @@ -1,215 +0,0 @@ -[ - { - "id": 0, - "name": "Potato", - "description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.", - "light": 6, - "spacing": "35", - "soil": "sandy", - "image": "potato.jpg", - "pests": [ - { - "name": "Rot", - "description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.", - "measures": "Less water." - } - ], - "wateringCycle": { - "litersPerSqM": 25, - "interval": null, - "notes": [] - }, - "lifecycle": [ - { - "startDate": "03-10", - "endDate": "04-10", - "type": "SOW", - "zone": "ZONE_8A", - "group": 0, - "taskTemplates": [ - { - "name": "Germinate", - "relativeStartDate": -14, - "relativeEndDate": null, - "description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.", - "interval": null - } - ] - }, - { - "startDate": "04-10", - "endDate": "07-10", - "type": "PLANT", - "zone": "ZONE_8A", - "group": 0, - "taskTemplates": [ - { - "name": "hilling", - "relativeStartDate": 0, - "relativeEndDate": null, - "description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.", - "interval": 21 - } - ] - }, - { - "startDate": "06-10", - "endDate": "08-10", - "type": "HARVEST", - "zone": "ZONE_8A", - "group": 0, - "taskTemplates": [ - { - "name": "Harvest", - "relativeStartDate": 0, - "relativeEndDate": null, - "description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.", - "interval": null - } - ] - } - ] - }, - { - "id": 1, - "name": "Early Carrot", - "description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.", - "image": "carrot.jpg", - "wateringCycle": { - "litersPerSqM": 15, - "interval": 3, - "notes": [] - }, - "lifecycle": [ - { - "startDate": "02-20", - "endDate": "03-10", - "zone": "ZONE_8A", - "type": "SOW", - "group": 0, - - "taskTemplates": [ - { - "name": "hilling", - "relativeStartDate": 0, - "relativeEndDate": 0, - "description": "Mound up the soil around the plant until just the top few leaves show above the soil. ", - "interval": null - } - ] - }, - { - "startDate": "03-10", - "endDate": "05-10", - "zone": "ZONE_8A", - "type": "PLANT", - "group": 0, - "taskTemplates": [ - { - "name": "hilling", - "relativeStartDate": 0, - "relativeEndDate": null, - "description": "Mound up the soil around the plant until just the top few leaves show above the soil. ", - "interval": 15 - } - ] - }, - { - "startDate": "05-10", - "endDate": "05-20", - "zone": "ZONE_8A", - "type": "HARVEST", - "group": 0, - "taskTemplates": [ - { - "name": "Harvesting", - "relativeStartDate": 0, - "relativeEndDate": 14, - "description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.", - "interval": null - } - ] - } - ], - "soil": "sandy to loamy, loose soil, free of stones", - "spacing": "5,35,2.5", - "pests": [ - { - "name": "Rot", - "description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.", - "measures": "less water" - } - ] - }, - { - "id": 2, - "name": "Summertime Onion", - "description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.", - "image": "onion.jpg", - "wateringCycle": { - "litersPerSqM": 15, - "interval": 4, - "notes": [ - ] - }, - "lifecycle": [ - { - "startDate": "03-15", - "endDate": "04-10", - "type": "SOW", - "zone": "ZONE_8A", - "group": 0, - "taskTemplates": [ - { - "name": "Plant Sets", - "relativeStartDate": 0, - "relativeEndDate": 0, - "description": "Plant the sets about 5cm deep into the soil.", - "interval": null - } - ] - }, - { - "startDate": "04-10", - "endDate": "07-10", - "type": "PLANT", - "zone": "ZONE_8A", - "group": 0, - "taskTemplates": [ - { - "name": "hilling", - "relativeStartDate": 0, - "relativeEndDate": null, - "description": "Mound up the soil around the plant until just the top few leaves show above the soil. ", - "interval": 15 - } - ] - }, - { - "startDate": "07-10", - "endDate": "09-20", - "type": "HARVEST", - "zone": "ZONE_8A", - "group": 0, - "taskTemplates": [ - { - "name": "Harvesting", - "relativeStartDate": 0, - "relativeEndDate": 14, - "description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter", - "interval": null - } - ] - } - ], - "soil": "sandy to loamy, loose soil, free of stones", - "spacing": "15,30,2", - "pests": [ - { - "name": "Rot", - "description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.", - "measures": "less water" - } - ] - } -] diff --git a/src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-user-crops.json b/src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-user-crops.json deleted file mode 100644 index 32960f8..0000000 --- a/src/test/resources/ch/zhaw/gartenverwaltung/backgroundtask/weather/test-user-crops.json +++ /dev/null @@ -1,2 +0,0 @@ -[ -] \ No newline at end of file