#23 implemented test class for WeatherGradenTaskPlanner

This commit is contained in:
Gian-Andrea Hutter
2022-12-09 00:02:21 +01:00
parent d119fd1331
commit 86386d8a91
6 changed files with 317 additions and 8 deletions
@@ -20,7 +20,7 @@ public class WeatherGradenTaskPlanner {
private final PlantList plantList;
private final CropList cropList;
WeatherService weatherService;
private final LocalDate dateSevereWeather = LocalDate.of(2022,12,15);
private final LocalDate dateSevereWeather = LocalDate.now();
public WeatherGradenTaskPlanner(TaskList taskList, PlantList plantList, CropList cropList) {
this.taskList = taskList;
@@ -64,7 +64,7 @@ public class WeatherGradenTaskPlanner {
Task preHailTask = new Task("Hail",
"During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin",
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L),1L);
taskList.saveTask(preHailTask);
}
@@ -76,7 +76,7 @@ public class WeatherGradenTaskPlanner {
private void createPreFrostTask() throws IOException {
Task preFrostTask = new Task("Frost",
"The temperatur falls below zero degrees, cover especially the root with wool",
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L),1L);
taskList.saveTask(preFrostTask);
}
@@ -87,7 +87,7 @@ public class WeatherGradenTaskPlanner {
private void createPreSnowTask() throws IOException {
Task preSnowTask = new Task("Snow",
"The weather brings little snowfall. Cover your crops",
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L),1L);
taskList.saveTask(preSnowTask);
}
@@ -113,9 +113,6 @@ public class WeatherGradenTaskPlanner {
/**
* Method to set next execution date of the water plant tasks
* @param cropTaskList List with tasks from crops
* @throws IOException If the database cannot be accessed
* @throws HardinessZoneNotSetException If the hardiness zone is not available
* @throws PlantNotFoundException if the plant is not available for the watering task
*/
private void adjustNextExecutionOfWateringTasks(List<Task> cropTaskList){
for(Task task : cropTaskList){
@@ -44,10 +44,11 @@ public class Task {
/**
* Constructor for weather events
*/
public Task(String name, String description, LocalDate startDate, LocalDate endDate) {
public Task(String name, String description, LocalDate startDate, LocalDate endDate, long cropId) {
this.name = name;
this.description = description;
this.startDate = startDate;
nextExecution = startDate;
this.endDate = endDate;
}