more tests
This commit is contained in:
parent
3f568c77d3
commit
198be1f668
3 changed files with 200 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut;
|
||||
|
||||
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;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@DisplayName("ThermostatCondition Tests")
|
||||
public class ThermostatConditionTests {
|
||||
|
||||
private ThermostatCondition thermostatCondition;
|
||||
|
||||
@BeforeEach
|
||||
public void createThermostatCondtion() {
|
||||
this.thermostatCondition = new ThermostatCondition();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set mode")
|
||||
public void getAndSetMode() {
|
||||
thermostatCondition.setMode(Thermostat.Mode.IDLE);
|
||||
|
||||
assertEquals(Thermostat.Mode.IDLE, thermostatCondition.getMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set operator")
|
||||
public void getAndSeOperator() {
|
||||
thermostatCondition.setOperator(Operator.EQUAL);
|
||||
|
||||
assertEquals(Operator.EQUAL, thermostatCondition.getOperator());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set operator")
|
||||
public void triggered() {
|
||||
thermostatCondition.setMode(Thermostat.Mode.IDLE);
|
||||
thermostatCondition.setOperator(Operator.EQUAL);
|
||||
Thermostat t = new Thermostat();
|
||||
t.setMode(Mode.IDLE);
|
||||
thermostatCondition.setDevice(t);
|
||||
|
||||
assertTrue(thermostatCondition.triggered());
|
||||
|
||||
thermostatCondition.setOperator(Operator.NOTEQUAL);
|
||||
assertFalse(thermostatCondition.triggered());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
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;
|
||||
|
||||
@DisplayName("Trigger Tests")
|
||||
public class TriggerTests {
|
||||
|
||||
private BooleanTrigger booleanTrigger;
|
||||
|
||||
@BeforeEach
|
||||
public void createBooleanTrigger() {
|
||||
booleanTrigger = new BooleanTrigger();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get Kind")
|
||||
public void getKind() {
|
||||
assertEquals("booleanTrigger", booleanTrigger.getKind());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set id")
|
||||
public void getAndSetId() {
|
||||
booleanTrigger.setId(20);
|
||||
assertEquals(20, booleanTrigger.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set device")
|
||||
public void getAndSetDevice() {
|
||||
RegularLight r = new RegularLight();
|
||||
booleanTrigger.setDevice(r);
|
||||
assertEquals(r, booleanTrigger.getDevice());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set device id")
|
||||
public void getAndSetDeviceId() {
|
||||
booleanTrigger.setDeviceId(20L);
|
||||
assertEquals(20, booleanTrigger.getDeviceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set automation")
|
||||
public void getAndSetAutomation() {
|
||||
Automation r = new Automation();
|
||||
booleanTrigger.setAutomation(r);
|
||||
assertEquals(r, booleanTrigger.getAutomation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set automation id")
|
||||
public void getAndSetAutomationId() {
|
||||
booleanTrigger.setAutomationId(20L);
|
||||
assertEquals(20, booleanTrigger.getAutomationId());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut;
|
||||
|
||||
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;
|
||||
|
||||
@DisplayName(" USer Tests")
|
||||
public class UserTests {
|
||||
|
||||
private User user;
|
||||
|
||||
@BeforeEach
|
||||
public void createUser() {
|
||||
user = new User();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set id")
|
||||
public void getAndSetId() {
|
||||
user.setId(20l);
|
||||
|
||||
assertEquals(20, user.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set id")
|
||||
public void getAndSetName() {
|
||||
user.setName("Paolo Bitta");
|
||||
|
||||
assertEquals("Paolo Bitta", user.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set id")
|
||||
public void getAndSetUsername() {
|
||||
user.setUsername("PaulB");
|
||||
|
||||
assertEquals("PaulB", user.getUsername());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set email")
|
||||
public void getAndSetEmail() {
|
||||
user.setEmail("paolo.bitta@gmail.com");
|
||||
|
||||
assertEquals("paolo.bitta@gmail.com", user.getEmail());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set password")
|
||||
public void getAndSetPassword() {
|
||||
user.setPassword("cameraCaffe");
|
||||
|
||||
assertEquals("cameraCaffe", user.getPassword());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set enabled")
|
||||
public void getAndSetEnabled() {
|
||||
user.setEnabled(true);
|
||||
|
||||
assertTrue(user.getEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("get and set Cameraenabled")
|
||||
public void getAndSeCameraEnabled() {
|
||||
user.setCameraEnabled(true);
|
||||
|
||||
assertTrue(user.isCameraEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals")
|
||||
public void eq() {
|
||||
assertFalse(user.equals(null));
|
||||
|
||||
assertTrue(user.equals(user));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue