From 710c7666dddda4ec60ce5e9a8e52ec32247e3c44 Mon Sep 17 00:00:00 2001 From: "Claudio Maggioni (maggicl)" Date: Sun, 24 May 2020 23:42:47 +0200 Subject: [PATCH] Fixes --- .../{model => models}/AutomationTests.java | 3 +-- .../BooleanConditionTests.java | 4 +--- .../BooleanTriggerTests.java | 4 +--- .../{model => models}/ButtonDimmerTests.java | 5 +---- .../{model => models}/ConditionTests.java | 3 +-- .../ConfirmationTokenTests.java | 4 +--- .../{model => models}/CurtainsTests.java | 3 +-- .../{model => models}/DimmableLightTests.java | 3 +-- .../{model => models}/DimmableStateTests.java | 4 +--- .../{model => models}/DimmableTests.java | 3 +-- .../{model => models}/DimmerTests.java | 4 +--- .../{model => models}/KnobDimmerTests.java | 11 ++++++---- .../{model => models}/MotionSensorTests.java | 4 ++-- .../smarthut/models/OperatorTests.java | 21 +++++++++++++++++++ .../RangeConditionTests.java | 5 +---- .../{model => models}/RangeTriggerTests.java | 5 +---- .../{model => models}/RegularLightTests.java | 3 +-- .../smarthut/{model => models}/RoomTests.java | 6 +----- .../{model => models}/ScenePriorityTests.java | 3 +-- .../{model => models}/SceneTests.java | 3 +-- .../SecurityCameraTests.java | 3 +-- .../{model => models}/SensorTests.java | 5 ++--- .../{model => models}/SmartPlugTests.java | 3 +-- .../{model => models}/StateTests.java | 5 +---- .../{model => models}/SwitchTests.java | 3 +-- .../SwitchableStateTests.java | 3 +-- .../ThermostatConditionTests.java | 12 ++++++++--- .../{model => models}/ThermostatTests.java | 3 +-- .../{model => models}/TriggerTests.java | 5 +---- .../smarthut/{model => models}/UserTests.java | 3 +-- .../smarthut/utils/UtilsTests.java | 10 +++++++++ 31 files changed, 76 insertions(+), 80 deletions(-) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/AutomationTests.java (96%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/BooleanConditionTests.java (89%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/BooleanTriggerTests.java (88%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/ButtonDimmerTests.java (85%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/ConditionTests.java (88%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/ConfirmationTokenTests.java (90%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/CurtainsTests.java (90%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/DimmableLightTests.java (96%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/DimmableStateTests.java (83%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/DimmableTests.java (95%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/DimmerTests.java (85%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/KnobDimmerTests.java (82%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/MotionSensorTests.java (83%) create mode 100644 src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/OperatorTests.java rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/RangeConditionTests.java (86%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/RangeTriggerTests.java (86%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/RegularLightTests.java (91%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/RoomTests.java (86%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/ScenePriorityTests.java (89%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/SceneTests.java (91%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/SecurityCameraTests.java (89%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/SensorTests.java (85%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/SmartPlugTests.java (89%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/StateTests.java (82%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/SwitchTests.java (96%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/SwitchableStateTests.java (82%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/ThermostatConditionTests.java (82%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/ThermostatTests.java (96%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/TriggerTests.java (86%) rename src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/{model => models}/UserTests.java (94%) diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/AutomationTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/AutomationTests.java similarity index 96% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/AutomationTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/AutomationTests.java index 7c4e7c7..f4d4019 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/AutomationTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/AutomationTests.java @@ -1,9 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/BooleanConditionTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/BooleanConditionTests.java similarity index 89% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/BooleanConditionTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/BooleanConditionTests.java index 824a8fb..de37a8f 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/BooleanConditionTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/BooleanConditionTests.java @@ -1,10 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanCondition; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Switch; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/BooleanTriggerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/BooleanTriggerTests.java similarity index 88% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/BooleanTriggerTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/BooleanTriggerTests.java index a1fc6e7..9f4bfb0 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/BooleanTriggerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/BooleanTriggerTests.java @@ -1,10 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanTrigger; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Switch; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ButtonDimmerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ButtonDimmerTests.java similarity index 85% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ButtonDimmerTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ButtonDimmerTests.java index 7aab4ce..c5a9fc4 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ButtonDimmerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ButtonDimmerTests.java @@ -1,10 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ButtonDimmer; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Dimmable; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ConditionTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ConditionTests.java similarity index 88% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ConditionTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ConditionTests.java index b676b28..be5c7ba 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ConditionTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ConditionTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanCondition; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ConfirmationTokenTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ConfirmationTokenTests.java similarity index 90% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ConfirmationTokenTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ConfirmationTokenTests.java index 5503552..4ae4c72 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ConfirmationTokenTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ConfirmationTokenTests.java @@ -1,9 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ConfirmationToken; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User; import java.util.Date; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/CurtainsTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/CurtainsTests.java similarity index 90% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/CurtainsTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/CurtainsTests.java index c366510..a0303cf 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/CurtainsTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/CurtainsTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Curtains; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableLightTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLightTests.java similarity index 96% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableLightTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLightTests.java index a72b16e..830abbd 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableLightTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLightTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableStateTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableStateTests.java similarity index 83% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableStateTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableStateTests.java index 9b58d94..dac93e1 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableStateTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableStateTests.java @@ -1,9 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableState; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableTests.java similarity index 95% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableTests.java index a50d2cb..b720a3c 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmableTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; import java.util.HashSet; import java.util.Set; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmerTests.java similarity index 85% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmerTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmerTests.java index 6dfc46c..5c473e6 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/DimmerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmerTests.java @@ -1,10 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.KnobDimmer; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/KnobDimmerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/KnobDimmerTests.java similarity index 82% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/KnobDimmerTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/KnobDimmerTests.java index def3f7f..d7b8b34 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/KnobDimmerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/KnobDimmerTests.java @@ -1,10 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Dimmable; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.KnobDimmer; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -44,4 +41,10 @@ public class KnobDimmerTests { } } } + + @Test + public void testReadTriggerState() { + this.knobDimmer.setLightIntensity(1); + assertEquals(1, this.knobDimmer.readTriggerState()); + } } diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/MotionSensorTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/MotionSensorTests.java similarity index 83% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/MotionSensorTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/MotionSensorTests.java index 9c4d9ac..60e09cb 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/MotionSensorTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/MotionSensorTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -22,5 +21,6 @@ public class MotionSensorTests { public void setAndGetDetected() { this.motionSensor.setDetected(true); assertTrue(this.motionSensor.isDetected()); + assertTrue(this.motionSensor.readTriggerState()); } } diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/OperatorTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/OperatorTests.java new file mode 100644 index 0000000..197e36a --- /dev/null +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/OperatorTests.java @@ -0,0 +1,21 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +public class OperatorTests { + @Test + public void testOperators() { + assertThat(Operator.EQUAL.checkAgainst(30, 30)).isTrue(); + assertThat(Operator.EQUAL.checkAgainst(20, 30)).isFalse(); + assertThat(Operator.LESS.checkAgainst(20, 30)).isTrue(); + assertThat(Operator.LESS.checkAgainst(40, 30)).isFalse(); + assertThat(Operator.LESS_EQUAL.checkAgainst(30, 30)).isTrue(); + assertThat(Operator.LESS_EQUAL.checkAgainst(40, 30)).isFalse(); + assertThat(Operator.GREATER.checkAgainst(40, 30)).isTrue(); + assertThat(Operator.GREATER.checkAgainst(30, 30)).isFalse(); + assertThat(Operator.GREATER_EQUAL.checkAgainst(30, 30)).isTrue(); + assertThat(Operator.GREATER_EQUAL.checkAgainst(20, 30)).isFalse(); + } +} diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RangeConditionTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RangeConditionTests.java similarity index 86% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RangeConditionTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RangeConditionTests.java index d963fda..91b5bab 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RangeConditionTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RangeConditionTests.java @@ -1,10 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Operator; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeCondition; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RangeTriggerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RangeTriggerTests.java similarity index 86% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RangeTriggerTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RangeTriggerTests.java index 27a5623..df38df5 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RangeTriggerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RangeTriggerTests.java @@ -1,10 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Operator; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeTrigger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RegularLightTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RegularLightTests.java similarity index 91% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RegularLightTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RegularLightTests.java index 97a66b4..9777cc8 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RegularLightTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RegularLightTests.java @@ -1,9 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RegularLight; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RoomTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RoomTests.java similarity index 86% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RoomTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RoomTests.java index 538806f..1b0724d 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/RoomTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/RoomTests.java @@ -1,11 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Icon; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Room; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ScenePriorityTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ScenePriorityTests.java similarity index 89% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ScenePriorityTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ScenePriorityTests.java index b2309b4..a01c5d5 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ScenePriorityTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ScenePriorityTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ScenePriority; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SceneTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SceneTests.java similarity index 91% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SceneTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SceneTests.java index a72557c..0e7dad9 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SceneTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SceneTests.java @@ -1,9 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Scene; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SecurityCameraTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SecurityCameraTests.java similarity index 89% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SecurityCameraTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SecurityCameraTests.java index 1fc45fc..b02900c 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SecurityCameraTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SecurityCameraTests.java @@ -1,9 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.SecurityCamera; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SensorTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SensorTests.java similarity index 85% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SensorTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SensorTests.java index f9c49ad..0aa1089 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SensorTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SensorTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Sensor; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Sensor.SensorType; import java.math.BigDecimal; import org.junit.jupiter.api.BeforeEach; @@ -32,7 +31,7 @@ public class SensorTests { public void getAndSetValue() { sensor.setValue(new BigDecimal(40)); - assertEquals(new BigDecimal(40), sensor.getValue()); + assertEquals(40.0, sensor.readTriggerState()); } @Test diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SmartPlugTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SmartPlugTests.java similarity index 89% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SmartPlugTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SmartPlugTests.java index 046a2d2..c8fe22b 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SmartPlugTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SmartPlugTests.java @@ -1,9 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.SmartPlug; import java.math.BigDecimal; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/StateTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java similarity index 82% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/StateTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java index 7b1e513..4b4224d 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/StateTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java @@ -1,10 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableState; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Scene; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SwitchTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SwitchTests.java similarity index 96% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SwitchTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SwitchTests.java index 3358b84..c83bd5f 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SwitchTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SwitchTests.java @@ -1,9 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SwitchableStateTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SwitchableStateTests.java similarity index 82% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SwitchableStateTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SwitchableStateTests.java index c9be074..8fcd326 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/SwitchableStateTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/SwitchableStateTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertTrue; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.SwitchableState; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ThermostatConditionTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatConditionTests.java similarity index 82% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ThermostatConditionTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatConditionTests.java index 3e3de78..182867f 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ThermostatConditionTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatConditionTests.java @@ -1,10 +1,8 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Thermostat; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Thermostat.Mode; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ThermostatCondition; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ThermostatCondition.Operator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -49,5 +47,13 @@ public class ThermostatConditionTests { thermostatCondition.setOperator(Operator.NOTEQUAL); assertFalse(thermostatCondition.triggered()); + + t.setMode(Mode.COOLING); + + thermostatCondition.setOperator(Operator.EQUAL); + assertFalse(thermostatCondition.triggered()); + + thermostatCondition.setOperator(Operator.NOTEQUAL); + assertTrue(thermostatCondition.triggered()); } } diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ThermostatTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatTests.java similarity index 96% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ThermostatTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatTests.java index c708c93..e189131 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/ThermostatTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Thermostat; import java.math.BigDecimal; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/TriggerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/TriggerTests.java similarity index 86% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/TriggerTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/TriggerTests.java index ca8dec0..643242a 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/TriggerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/TriggerTests.java @@ -1,10 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Automation; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanTrigger; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RegularLight; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/UserTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/UserTests.java similarity index 94% rename from src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/UserTests.java rename to src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/UserTests.java index 9a4c1e0..c93cd9d 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/model/UserTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/UserTests.java @@ -1,8 +1,7 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.model; +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.*; -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/utils/UtilsTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/utils/UtilsTests.java index c5fcc8d..e30eed6 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/utils/UtilsTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/utils/UtilsTests.java @@ -43,5 +43,15 @@ public class UtilsTests { assertThatThrownBy(() -> Utils.returnIfGuest(userRepository, "toReturn", 2L, principal)) .isInstanceOf(NotFoundException.class); + + host.getGuests().clear(); + + assertThatThrownBy( + () -> + assertThat( + Utils.returnIfGuest( + userRepository, "toReturn", 1L, principal)) + .isEqualTo("toReturn")) + .isInstanceOf(NotFoundException.class); } }