fix: pre-copying test files

By some accursed class loading magic, files in the test-resources with the same name as one in the main resources were read/written in the main resources, causing some problems.

Renamed all of the test files to fix this.
This commit is contained in:
David Guler
2022-11-20 08:53:56 +01:00
parent b70a758099
commit bfe3fcfb79
14 changed files with 72 additions and 360 deletions
@@ -53,6 +53,7 @@ public class JsonCropList implements CropList {
public JsonCropList(URL dataSource) {
this.dataSource = dataSource;
}
/**
* {@inheritDoc}
*/
@@ -25,7 +25,7 @@ import java.util.Optional;
* The reads are cached to minimize file-io operations.
*/
public class JsonPlantList implements PlantList {
private final URL dataSource = getClass().getResource("plantdb.json");
private final URL dataSource;
private HardinessZone currentZone;
private Map<Long, Plant> plantMap = Collections.emptyMap();
@@ -44,6 +44,13 @@ public class JsonPlantList implements PlantList {
imageModule.addDeserializer(Image.class, new PlantImageDeserializer());
}
public JsonPlantList() {
this.dataSource = getClass().getResource("plantdb.json");
}
public JsonPlantList(URL dataSource) {
this.dataSource = dataSource;
}
/**
* If no data is currently loaded, or the specified zone differs
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
@@ -25,7 +25,7 @@ import java.util.Map;
*/
public class JsonTaskList implements TaskList {
IdProvider idProvider;
private final URL dataSource = getClass().getResource("taskdb.json");
private final URL dataSource;
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
private Map<Long, Task> taskMap = Collections.emptyMap();
@@ -43,6 +43,13 @@ public class JsonTaskList implements TaskList {
timeModule.addSerializer(LocalDate.class, dateSerializer);
}
public JsonTaskList() {
this.dataSource = getClass().getResource("taskdb.json");
}
public JsonTaskList(URL dataSource) {
this.dataSource = dataSource;
}
/**
* If no data is currently loaded, data is loaded from {@link #dataSource}.
* In any case, the values of {@link #taskMap} are returned.