From 3dcfa584f070e6ab11a182fb073983611f306fa6 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Thu, 14 May 2020 21:02:49 +0200 Subject: [PATCH] made some fields private --- .../dto/AutomationFastUpdateRequest.java | 14 ++++++----- .../AutomationFastUpdateRequestTest.java | 24 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java index ada8906..f086fef 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java @@ -8,6 +8,8 @@ import javax.validation.constraints.NotNull; import lombok.Data; @Data +@Getter +@Setter public class AutomationFastUpdateRequest { public abstract static class TriggerDTO { @NotNull public long deviceId; @@ -28,8 +30,8 @@ public class AutomationFastUpdateRequest { } public static class RangeTriggerDTO extends TriggerDTO { - @NotNull public Operator operator; - @NotNull public double range; + @NotNull private Operator operator; + @NotNull private double range; @Override public Trigger toModel() { @@ -77,8 +79,8 @@ public class AutomationFastUpdateRequest { public static class RangeConditionDTO extends ConditionDTO { - @NotNull public Operator operator; - @NotNull public double range; + @NotNull private Operator operator; + @NotNull private double range; @Override public Condition toModel() { @@ -92,8 +94,8 @@ public class AutomationFastUpdateRequest { public static class ThermostatConditionDTO extends ConditionDTO { - @NotNull public ThermostatCondition.Operator operator; - @NotNull public Thermostat.Mode mode; + @NotNull private ThermostatCondition.Operator operator; + @NotNull private Thermostat.Mode mode; @Override public Condition toModel() { diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/AutomationFastUpdateRequestTest.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/AutomationFastUpdateRequestTest.java index 70e1f99..013f067 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/AutomationFastUpdateRequestTest.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/AutomationFastUpdateRequestTest.java @@ -32,13 +32,13 @@ public class AutomationFastUpdateRequestTest { @DisplayName(" checking range trigger ") public void rangeTriggerDTOTest() { rangeTriggerDTO = new AutomationFastUpdateRequest.RangeTriggerDTO(); - rangeTriggerDTO.operator = Operator.EQUAL; + rangeTriggerDTO.setOperator(Operator.EQUAL); rangeTriggerDTO.deviceId = 420; - rangeTriggerDTO.range = 12; + rangeTriggerDTO.setRange(12); RangeTrigger rangeTrigger = (RangeTrigger) rangeTriggerDTO.toModel(); - assertEquals(rangeTrigger.getOperator(), rangeTriggerDTO.operator); - assertEquals(rangeTrigger.getRange(), rangeTriggerDTO.range); + assertEquals(rangeTrigger.getOperator(), rangeTriggerDTO.getOperator()); + assertEquals(rangeTrigger.getRange(), rangeTriggerDTO.getRange()); assertEquals(rangeTrigger.getDeviceId(), rangeTriggerDTO.deviceId); } @@ -70,13 +70,13 @@ public class AutomationFastUpdateRequestTest { @DisplayName(" checking range condition ") public void rangeConditionDTOTest() { rangeConditionDTO = new AutomationFastUpdateRequest.RangeConditionDTO(); - rangeConditionDTO.operator = Operator.LESS; - rangeConditionDTO.range = 82.01; + rangeConditionDTO.setOperator(Operator.LESS); + rangeConditionDTO.setRange(82.01); rangeConditionDTO.deviceId = 13; RangeCondition rangeCondition = (RangeCondition) rangeConditionDTO.toModel(); - assertEquals(rangeCondition.getOperator(), rangeConditionDTO.operator); - assertEquals(rangeCondition.getRange(), rangeConditionDTO.range); + assertEquals(rangeCondition.getOperator(), rangeConditionDTO.getOperator()); + assertEquals(rangeCondition.getRange(), rangeConditionDTO.getRange()); assertEquals(rangeCondition.getDeviceId(), rangeConditionDTO.deviceId); } @@ -85,13 +85,13 @@ public class AutomationFastUpdateRequestTest { public void thermostatConditionDTOTest() { thermostatConditionDTO = new AutomationFastUpdateRequest.ThermostatConditionDTO(); thermostatConditionDTO.deviceId = 25; - thermostatConditionDTO.operator = ThermostatCondition.Operator.EQUAL; - thermostatConditionDTO.mode = Thermostat.Mode.HEATING; + thermostatConditionDTO.setOperator(ThermostatCondition.Operator.EQUAL); + thermostatConditionDTO.setMode(Thermostat.Mode.HEATING); ThermostatCondition thermostatCondition = (ThermostatCondition) thermostatConditionDTO.toModel(); - assertEquals(thermostatCondition.getMode(), thermostatConditionDTO.mode); - assertEquals(thermostatCondition.getOperator(), thermostatConditionDTO.operator); + assertEquals(thermostatCondition.getMode(), thermostatConditionDTO.getMode()); + assertEquals(thermostatCondition.getOperator(), thermostatConditionDTO.getOperator()); assertEquals(thermostatCondition.getDeviceId(), thermostatConditionDTO.deviceId); } }