Merge branch 'dev' into feature_json-gardenplan_M2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package ch.zhaw.gartenverwaltung.io;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.Task;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
public class JsonTaskDatabaseTest {
|
||||
|
||||
TaskDatabase testDatabase;
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
|
||||
@BeforeEach
|
||||
void connectToDb() {
|
||||
// testDatabase = new JsonTaskDatabase();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Check if results are retrieved completely")
|
||||
void getTasks(){
|
||||
/*
|
||||
List<Task> taskList=null;
|
||||
try {
|
||||
taskList = testDatabase.getTaskList(formatter.parse("01.05.2022"), formatter.parse("01.08.2022"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Assertions.assertTrue(taskList.size()>0);
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package ch.zhaw.gartenverwaltung.plantList;
|
||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||
import ch.zhaw.gartenverwaltung.io.JsonPlantDatabase;
|
||||
import ch.zhaw.gartenverwaltung.io.PlantDatabase;
|
||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||
import ch.zhaw.gartenverwaltung.types.*;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.MonthDay;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -43,31 +43,39 @@ class PlantListModelTest {
|
||||
20,
|
||||
"summertime onion",
|
||||
"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.",
|
||||
null,
|
||||
"15,30,2",
|
||||
0,
|
||||
"sandy to loamy, loose soil, free of stones",
|
||||
new ArrayList<>(),
|
||||
new ArrayList<>())
|
||||
List.of(new GrowthPhase(MonthDay.of(6, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.HARVEST, HardinessZone.ZONE_8A, new ArrayList<>()),
|
||||
new GrowthPhase(MonthDay.of(4, 3), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
|
||||
new GrowthPhase(MonthDay.of(8, 5), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
|
||||
new GrowthPhase(MonthDay.of(2, 8), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
|
||||
new GrowthPhase(MonthDay.of(10, 2), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())))
|
||||
);
|
||||
examplePlantList.add(new Plant(
|
||||
0,
|
||||
"Potato",
|
||||
"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.",
|
||||
null,
|
||||
"35",
|
||||
6,
|
||||
"sandy",
|
||||
new ArrayList<>(),
|
||||
new ArrayList<>())
|
||||
List.of(new GrowthPhase(MonthDay.of(6, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.HARVEST, HardinessZone.ZONE_8A, new ArrayList<>()),
|
||||
new GrowthPhase(MonthDay.of(6, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())))
|
||||
);
|
||||
examplePlantList.add(new Plant(
|
||||
1,
|
||||
"Early Carrot",
|
||||
"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.",
|
||||
null,
|
||||
"5,35,2.5",
|
||||
0,
|
||||
"sandy to loamy, loose soil, free of stones",
|
||||
new ArrayList<>(),
|
||||
new ArrayList<>())
|
||||
List.of(new GrowthPhase(MonthDay.of(4, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -146,4 +154,46 @@ class PlantListModelTest {
|
||||
assertEquals(1, plantListResult.size());
|
||||
assertEquals(examplePlantList.get(0), plantListResult.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getFilteredPlantListByString() throws HardinessZoneNotSetException, IOException {
|
||||
model.setCurrentZone(HardinessZone.ZONE_1A);
|
||||
List<Plant> plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "#2");
|
||||
assertEquals(0, plantListResult.size());
|
||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "#20");
|
||||
assertEquals(1, plantListResult.size());
|
||||
assertEquals(examplePlantList.get(0), plantListResult.get(0));
|
||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "#a2");
|
||||
assertEquals(0, plantListResult.size());
|
||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "onion");
|
||||
assertEquals(1, plantListResult.size());
|
||||
assertEquals(examplePlantList.get(0), plantListResult.get(0));
|
||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "white roots");
|
||||
assertEquals(1, plantListResult.size());
|
||||
assertEquals(examplePlantList.get(1), plantListResult.get(0));
|
||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "apple");
|
||||
assertEquals(0, plantListResult.size());
|
||||
plantListResult = model.getFilteredPlantListByString(HardinessZone.ZONE_8A, "");
|
||||
assertEquals(3, plantListResult.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getFilteredPlantListByPlantingSaison() throws HardinessZoneNotSetException, IOException {
|
||||
model.setCurrentZone(HardinessZone.ZONE_1A);
|
||||
List<Plant> plantListResult = model.getFilteredPlantListByPlantingSaison(HardinessZone.ZONE_8A, MonthDay.of(4, 4), MonthDay.of(8, 4));
|
||||
assertEquals(2, plantListResult.size());
|
||||
assertEquals(examplePlantList.get(2), plantListResult.get(0));
|
||||
assertEquals(examplePlantList.get(1), plantListResult.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getFilteredPlantListByHarvestSaison() throws HardinessZoneNotSetException, IOException {
|
||||
model.setCurrentZone(HardinessZone.ZONE_1A);
|
||||
List<Plant> plantListResult = model.getFilteredPlantListByHarvestSaison(HardinessZone.ZONE_8A, MonthDay.of(4, 4), MonthDay.of(8, 4));
|
||||
assertEquals(2, plantListResult.size());
|
||||
assertEquals(examplePlantList.get(1), plantListResult.get(0));
|
||||
assertEquals(examplePlantList.get(0), plantListResult.get(1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user