Tests
This commit is contained in:
parent
48942ee8c2
commit
ef2247e38a
2 changed files with 17 additions and 0 deletions
|
@ -14,6 +14,7 @@ public class SwitchableStateTests {
|
|||
@BeforeEach
|
||||
public void createSwitchableState() {
|
||||
switchableState = new SwitchableState();
|
||||
switchableState.setDevice(new RegularLight());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -22,5 +23,10 @@ public class SwitchableStateTests {
|
|||
switchableState.setOn(true);
|
||||
|
||||
assertTrue(switchableState.isOn());
|
||||
|
||||
switchableState.apply();
|
||||
assertTrue(((Switchable) switchableState.getDevice()).isOn());
|
||||
|
||||
assertTrue(switchableState.copy().isOn());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User;
|
|||
import ch.usi.inf.sa4.sanmarinoes.smarthut.socket.SensorSocketEndpoint;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -63,4 +64,14 @@ public class ThermostatServiceTests {
|
|||
when(thermostatRepository.findAllByUsername("user")).thenReturn(List.of(t));
|
||||
assertThat(thermostatService.findAll("user")).containsExactly(t);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindById() {
|
||||
final Thermostat t = new Thermostat();
|
||||
when(thermostatRepository.findByIdAndUsername(2L, "user")).thenReturn(Optional.empty());
|
||||
when(thermostatRepository.findByIdAndUsername(1L, "user")).thenReturn(Optional.of(t));
|
||||
doNothing().when(thermostatPopulationService).populateMeasuredTemperature(t);
|
||||
assertThat(thermostatService.findById(2L, "user")).isEmpty();
|
||||
assertThat(thermostatService.findById(1L, "user")).isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue