Fixed lombok in AutomationFastUpdateRequest

This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-17 12:49:40 +02:00
parent 3dcfa584f0
commit bc7b30f3ea
2 changed files with 37 additions and 37 deletions

View file

@ -6,37 +6,37 @@ import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data @Data
@Getter
@Setter
public class AutomationFastUpdateRequest { public class AutomationFastUpdateRequest {
public abstract static class TriggerDTO { public abstract static class TriggerDTO {
@NotNull public long deviceId; @NotNull @Getter @Setter private long deviceId;
public abstract Trigger<?> toModel(); public abstract Trigger<?> toModel();
} }
public static class BooleanTriggerDTO extends TriggerDTO { public static class BooleanTriggerDTO extends TriggerDTO {
@NotNull public boolean on; @NotNull @Getter @Setter private boolean on;
@Override @Override
public Trigger<?> toModel() { public Trigger<?> toModel() {
BooleanTrigger t = new BooleanTrigger(); BooleanTrigger t = new BooleanTrigger();
t.setDeviceId(this.deviceId); t.setDeviceId(this.getDeviceId());
t.setOn(this.on); t.setOn(this.on);
return t; return t;
} }
} }
public static class RangeTriggerDTO extends TriggerDTO { public static class RangeTriggerDTO extends TriggerDTO {
@NotNull private Operator operator; @NotNull @Getter @Setter private Operator operator;
@NotNull private double range; @NotNull @Getter @Setter private double range;
@Override @Override
public Trigger<?> toModel() { public Trigger<?> toModel() {
RangeTrigger t = new RangeTrigger(); RangeTrigger t = new RangeTrigger();
t.setDeviceId(this.deviceId); t.setDeviceId(this.getDeviceId());
t.setOperator(this.operator); t.setOperator(this.operator);
t.setRange(this.range); t.setRange(this.range);
return t; return t;
@ -44,11 +44,11 @@ public class AutomationFastUpdateRequest {
} }
public static class ScenePriorityDTO { public static class ScenePriorityDTO {
@NotNull public long sceneId; @NotNull @Getter @Setter private long sceneId;
@NotNull @NotNull
@Min(0) @Min(0)
public Integer priority; private @Getter @Setter Integer priority;
public ScenePriority toModel() { public ScenePriority toModel() {
ScenePriority s = new ScenePriority(); ScenePriority s = new ScenePriority();
@ -59,19 +59,19 @@ public class AutomationFastUpdateRequest {
} }
public abstract static class ConditionDTO { public abstract static class ConditionDTO {
@NotNull public long deviceId; @NotNull @Getter @Setter private long deviceId;
public abstract Condition<?> toModel(); public abstract Condition<?> toModel();
} }
public static class BooleanConditionDTO extends ConditionDTO { public static class BooleanConditionDTO extends ConditionDTO {
@NotNull public boolean on; @NotNull @Getter @Setter private boolean on;
@Override @Override
public Condition<?> toModel() { public Condition<?> toModel() {
BooleanCondition t = new BooleanCondition(); BooleanCondition t = new BooleanCondition();
t.setDeviceId(this.deviceId); t.setDeviceId(this.getDeviceId());
t.setOn(this.on); t.setOn(this.on);
return t; return t;
} }
@ -79,13 +79,13 @@ public class AutomationFastUpdateRequest {
public static class RangeConditionDTO extends ConditionDTO { public static class RangeConditionDTO extends ConditionDTO {
@NotNull private Operator operator; @NotNull @Getter @Setter private Operator operator;
@NotNull private double range; @NotNull @Getter @Setter private double range;
@Override @Override
public Condition<?> toModel() { public Condition<?> toModel() {
RangeCondition t = new RangeCondition(); RangeCondition t = new RangeCondition();
t.setDeviceId(this.deviceId); t.setDeviceId(this.getDeviceId());
t.setOperator(this.operator); t.setOperator(this.operator);
t.setRange(this.range); t.setRange(this.range);
return t; return t;
@ -94,13 +94,13 @@ public class AutomationFastUpdateRequest {
public static class ThermostatConditionDTO extends ConditionDTO { public static class ThermostatConditionDTO extends ConditionDTO {
@NotNull private ThermostatCondition.Operator operator; @NotNull @Getter @Setter private ThermostatCondition.Operator operator;
@NotNull private Thermostat.Mode mode; @NotNull @Getter @Setter private Thermostat.Mode mode;
@Override @Override
public Condition<?> toModel() { public Condition<?> toModel() {
ThermostatCondition t = new ThermostatCondition(); ThermostatCondition t = new ThermostatCondition();
t.setDeviceId(this.deviceId); t.setDeviceId(this.getDeviceId());
t.setOperator(this.operator); t.setOperator(this.operator);
t.setMode(this.mode); t.setMode(this.mode);
return t; return t;

View file

@ -21,11 +21,11 @@ public class AutomationFastUpdateRequestTest {
@DisplayName(" checking boolean trigger ") @DisplayName(" checking boolean trigger ")
public void booleanTriggerDTOTest() { public void booleanTriggerDTOTest() {
booleanTriggerDTO = new AutomationFastUpdateRequest.BooleanTriggerDTO(); booleanTriggerDTO = new AutomationFastUpdateRequest.BooleanTriggerDTO();
booleanTriggerDTO.on = true; booleanTriggerDTO.setOn(true);
booleanTriggerDTO.deviceId = 42; booleanTriggerDTO.setDeviceId(42);
BooleanTrigger booleanTrigger = (BooleanTrigger) booleanTriggerDTO.toModel(); BooleanTrigger booleanTrigger = (BooleanTrigger) booleanTriggerDTO.toModel();
assertEquals(booleanTrigger.isOn(), booleanTriggerDTO.on); assertEquals(booleanTrigger.isOn(), booleanTriggerDTO.isOn());
assertEquals(booleanTrigger.getDeviceId(), booleanTriggerDTO.deviceId); assertEquals(booleanTrigger.getDeviceId(), booleanTriggerDTO.getDeviceId());
} }
@Test @Test
@ -33,37 +33,37 @@ public class AutomationFastUpdateRequestTest {
public void rangeTriggerDTOTest() { public void rangeTriggerDTOTest() {
rangeTriggerDTO = new AutomationFastUpdateRequest.RangeTriggerDTO(); rangeTriggerDTO = new AutomationFastUpdateRequest.RangeTriggerDTO();
rangeTriggerDTO.setOperator(Operator.EQUAL); rangeTriggerDTO.setOperator(Operator.EQUAL);
rangeTriggerDTO.deviceId = 420; rangeTriggerDTO.setDeviceId(420);
rangeTriggerDTO.setRange(12); rangeTriggerDTO.setRange(12);
RangeTrigger rangeTrigger = (RangeTrigger) rangeTriggerDTO.toModel(); RangeTrigger rangeTrigger = (RangeTrigger) rangeTriggerDTO.toModel();
assertEquals(rangeTrigger.getOperator(), rangeTriggerDTO.getOperator()); assertEquals(rangeTrigger.getOperator(), rangeTriggerDTO.getOperator());
assertEquals(rangeTrigger.getRange(), rangeTriggerDTO.getRange()); assertEquals(rangeTrigger.getRange(), rangeTriggerDTO.getRange());
assertEquals(rangeTrigger.getDeviceId(), rangeTriggerDTO.deviceId); assertEquals(rangeTrigger.getDeviceId(), rangeTriggerDTO.getDeviceId());
} }
@Test @Test
@DisplayName(" checking scene priority ") @DisplayName(" checking scene priority ")
public void scenePriorityDTOTest() { public void scenePriorityDTOTest() {
scenePriorityDTO = new AutomationFastUpdateRequest.ScenePriorityDTO(); scenePriorityDTO = new AutomationFastUpdateRequest.ScenePriorityDTO();
scenePriorityDTO.priority = 67; scenePriorityDTO.setPriority(67);
scenePriorityDTO.sceneId = 21; scenePriorityDTO.setSceneId(21);
ScenePriority scenePriority = scenePriorityDTO.toModel(); ScenePriority scenePriority = scenePriorityDTO.toModel();
assertEquals(scenePriority.getPriority(), scenePriorityDTO.priority); assertEquals(scenePriority.getPriority(), scenePriorityDTO.getPriority());
assertEquals(scenePriority.getSceneId(), scenePriorityDTO.priority); assertEquals(scenePriority.getSceneId(), scenePriorityDTO.getSceneId());
} }
@Test @Test
@DisplayName(" checking boolean condition ") @DisplayName(" checking boolean condition ")
public void booleanConditionDTOTest() { public void booleanConditionDTOTest() {
booleanConditionDTO = new AutomationFastUpdateRequest.BooleanConditionDTO(); booleanConditionDTO = new AutomationFastUpdateRequest.BooleanConditionDTO();
booleanConditionDTO.on = true; booleanConditionDTO.setOn(true);
booleanConditionDTO.deviceId = 17; booleanConditionDTO.setDeviceId(17);
BooleanCondition booleanCondition = (BooleanCondition) booleanConditionDTO.toModel(); BooleanCondition booleanCondition = (BooleanCondition) booleanConditionDTO.toModel();
assertEquals(booleanCondition.isOn(), booleanConditionDTO.on); assertEquals(booleanCondition.isOn(), booleanConditionDTO.isOn());
assertEquals(booleanCondition.getDeviceId(), booleanConditionDTO.deviceId); assertEquals(booleanCondition.getDeviceId(), booleanConditionDTO.getDeviceId());
} }
@Test @Test
@ -72,19 +72,19 @@ public class AutomationFastUpdateRequestTest {
rangeConditionDTO = new AutomationFastUpdateRequest.RangeConditionDTO(); rangeConditionDTO = new AutomationFastUpdateRequest.RangeConditionDTO();
rangeConditionDTO.setOperator(Operator.LESS); rangeConditionDTO.setOperator(Operator.LESS);
rangeConditionDTO.setRange(82.01); rangeConditionDTO.setRange(82.01);
rangeConditionDTO.deviceId = 13; rangeConditionDTO.setDeviceId(13);
RangeCondition rangeCondition = (RangeCondition) rangeConditionDTO.toModel(); RangeCondition rangeCondition = (RangeCondition) rangeConditionDTO.toModel();
assertEquals(rangeCondition.getOperator(), rangeConditionDTO.getOperator()); assertEquals(rangeCondition.getOperator(), rangeConditionDTO.getOperator());
assertEquals(rangeCondition.getRange(), rangeConditionDTO.getRange()); assertEquals(rangeCondition.getRange(), rangeConditionDTO.getRange());
assertEquals(rangeCondition.getDeviceId(), rangeConditionDTO.deviceId); assertEquals(rangeCondition.getDeviceId(), rangeConditionDTO.getDeviceId());
} }
@Test @Test
@DisplayName(" checking thermostat condition ") @DisplayName(" checking thermostat condition ")
public void thermostatConditionDTOTest() { public void thermostatConditionDTOTest() {
thermostatConditionDTO = new AutomationFastUpdateRequest.ThermostatConditionDTO(); thermostatConditionDTO = new AutomationFastUpdateRequest.ThermostatConditionDTO();
thermostatConditionDTO.deviceId = 25; thermostatConditionDTO.setDeviceId(25);
thermostatConditionDTO.setOperator(ThermostatCondition.Operator.EQUAL); thermostatConditionDTO.setOperator(ThermostatCondition.Operator.EQUAL);
thermostatConditionDTO.setMode(Thermostat.Mode.HEATING); thermostatConditionDTO.setMode(Thermostat.Mode.HEATING);
@ -92,6 +92,6 @@ public class AutomationFastUpdateRequestTest {
(ThermostatCondition) thermostatConditionDTO.toModel(); (ThermostatCondition) thermostatConditionDTO.toModel();
assertEquals(thermostatCondition.getMode(), thermostatConditionDTO.getMode()); assertEquals(thermostatCondition.getMode(), thermostatConditionDTO.getMode());
assertEquals(thermostatCondition.getOperator(), thermostatConditionDTO.getOperator()); assertEquals(thermostatCondition.getOperator(), thermostatConditionDTO.getOperator());
assertEquals(thermostatCondition.getDeviceId(), thermostatConditionDTO.deviceId); assertEquals(thermostatCondition.getDeviceId(), thermostatConditionDTO.getDeviceId());
} }
} }