diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatConditionSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatConditionSaveRequest.java index 8c56f2d..c45b482 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatConditionSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatConditionSaveRequest.java @@ -1,13 +1,12 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; 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 javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class ThermostatConditionSaveRequest { - @NotNull private long id; @NotNull private Long deviceId; @@ -17,40 +16,4 @@ public class ThermostatConditionSaveRequest { @NotNull private ThermostatCondition.Operator operator; @NotNull private Thermostat.Mode mode; - - public long getId() { - return id; - } - - public Long getDeviceId() { - return deviceId; - } - - public void setDeviceId(Long deviceId) { - this.deviceId = deviceId; - } - - public Long getAutomationId() { - return automationId; - } - - public void setAutomationId(Long automationId) { - this.automationId = automationId; - } - - public Operator getOperator() { - return operator; - } - - public void setOperator(Operator operator) { - this.operator = operator; - } - - public Mode getMode() { - return mode; - } - - public void setMode(Mode mode) { - this.mode = mode; - } } diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ExceptionTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ExceptionTests.java new file mode 100644 index 0000000..07ff076 --- /dev/null +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ExceptionTests.java @@ -0,0 +1,72 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.error.*; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Exception tests") +public class ExceptionTests { + @Test + public void testBadData() { + try { + throw new BadDataException("message"); + } catch (BadDataException e) { + assertEquals(e.getMessage(), "message"); + } + } + + @Test + public void testDuplicateRegistration() { + try { + throw new DuplicateRegistrationException(); + } catch (DuplicateRegistrationException e) { + assertEquals(e.getMessage(), "Email or username already belonging to another user"); + } + } + + @Test + public void testDuplicateState() { + try { + throw new DuplicateStateException(); + } catch (DuplicateStateException e) { + assertEquals( + e.getMessage(), + "Cannot create state since it has already been created for this scene and this device"); + } + } + + @Test + public void testEmailTokenNotFound() { + try { + throw new EmailTokenNotFoundException(); + } catch (EmailTokenNotFoundException e) { + assertEquals(e.getMessage(), "Email verification token not found in DB"); + } + } + + @Test + public void testNotFound() { + try { + throw new NotFoundException(); + } catch (NotFoundException e) { + assertEquals(e.getMessage(), "Not found"); + } + + try { + throw new NotFoundException("message"); + } catch (NotFoundException e) { + assertEquals(e.getMessage(), "message not found"); + } + } + + @Test + public void testUserNotFound() { + try { + throw new UserNotFoundException(); + } catch (UserNotFoundException e) { + assertEquals(e.getMessage(), "No user found with given email"); + } + } +}