From e75ececedb26447a112a052c56166bdfe05698c8 Mon Sep 17 00:00:00 2001 From: Elias Csomor Date: Sat, 26 Nov 2022 14:29:49 +0100 Subject: [PATCH] Refactored AllSEASONS to ALLSEASONS and added tests --- .../gartenverwaltung/PlantsController.java | 4 +- .../zhaw/gartenverwaltung/types/Seasons.java | 2 +- .../gartenverwaltung/types/SeasonsTest.java | 38 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/test/java/ch/zhaw/gartenverwaltung/types/SeasonsTest.java diff --git a/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java b/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java index 5961c5f..2acee0d 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java @@ -233,11 +233,11 @@ public class PlantsController { RadioButton radioButton = new RadioButton(season.getName()); radioButton.setToggleGroup(seasonGroup); radioButton.setPadding(new Insets(0, 0, 10, 0)); - if (season.equals(Seasons.AllSEASONS)) { + if (season.equals(Seasons.ALLSEASONS)) { radioButton.setSelected(true); } radioButton.selectedProperty().addListener((observable, oldValue, newValue) -> { - if (season.equals(Seasons.AllSEASONS)) { + if (season.equals(Seasons.ALLSEASONS)) { fillPlantListWithHardinessZone(); } else { try { diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java b/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java index 2a2d2d0..fd2601c 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java @@ -3,7 +3,7 @@ package ch.zhaw.gartenverwaltung.types; import java.time.MonthDay; public enum Seasons { - AllSEASONS("--01-01", "--12-31", "All Seasons"), + ALLSEASONS("--01-01", "--12-31", "All Seasons"), SPRING("--03-01", "--05-30", "Spring"), SUMMER("--06-01", "--08-30", "Summer"), AUTUMN("--09-01", "--11-30", "Autumn"), diff --git a/src/test/java/ch/zhaw/gartenverwaltung/types/SeasonsTest.java b/src/test/java/ch/zhaw/gartenverwaltung/types/SeasonsTest.java new file mode 100644 index 0000000..520a937 --- /dev/null +++ b/src/test/java/ch/zhaw/gartenverwaltung/types/SeasonsTest.java @@ -0,0 +1,38 @@ +package ch.zhaw.gartenverwaltung.types; + +import org.junit.jupiter.api.Test; + +import java.time.MonthDay; + +import static org.junit.jupiter.api.Assertions.*; + +class SeasonsTest { + + @Test + void getStartDate() { + assertEquals(MonthDay.of(1,1), Seasons.ALLSEASONS.getStartDate()); + assertEquals(MonthDay.of(3,1), Seasons.SPRING.getStartDate()); + assertEquals(MonthDay.of(6,1), Seasons.SUMMER.getStartDate()); + assertEquals(MonthDay.of(9,1), Seasons.AUTUMN.getStartDate()); + assertEquals(MonthDay.of(12,1), Seasons.WINTER.getStartDate()); + } + + @Test + void getEndDate() { + assertEquals(MonthDay.of(12,31), Seasons.ALLSEASONS.getEndDate()); + assertEquals(MonthDay.of(5,30), Seasons.SPRING.getEndDate()); + assertEquals(MonthDay.of(8,30), Seasons.SUMMER.getEndDate()); + assertEquals(MonthDay.of(11,30), Seasons.AUTUMN.getEndDate()); + assertEquals(MonthDay.of(2,28), Seasons.WINTER.getEndDate()); + } + + @Test + void getName() { + assertEquals("All Seasons", Seasons.ALLSEASONS.getName()); + assertEquals("Spring", Seasons.SPRING.getName()); + assertEquals("Summer", Seasons.SUMMER.getName()); + assertEquals("Autumn", Seasons.AUTUMN.getName()); + assertEquals("Winter", Seasons.WINTER.getName()); + + } +} \ No newline at end of file