Sensor
This commit is contained in:
parent
1aab50c9f8
commit
3e2eb231a0
2 changed files with 21 additions and 2 deletions
|
@ -44,8 +44,6 @@ public class SensorController {
|
|||
newSensor.setName(s.getName());
|
||||
newSensor.setRoomId(s.getRoomId());
|
||||
newSensor.setValue(s.getValue());
|
||||
// newSensor.setError(s.getError());
|
||||
// newSensor.setTypical(s.getTypical());
|
||||
|
||||
return deviceService.saveAsOwner(newSensor, principal.getName());
|
||||
}
|
||||
|
|
|
@ -108,4 +108,25 @@ public class SensorControllerTests {
|
|||
assertThat(sensorController.updateValue(1L, BigDecimal.valueOf(30), mockPrincipal))
|
||||
.isSameAs(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSimulation() throws NotFoundException {
|
||||
final Sensor s = new Sensor();
|
||||
when(sensorRepository.findByIdAndUsername(1L, "user")).thenReturn(Optional.of(s));
|
||||
when(sensorRepository.findByIdAndUsername(2L, "user")).thenReturn(Optional.empty());
|
||||
when(sensorService.updateSimulationFromSensor(
|
||||
s, BigDecimal.valueOf(30), BigDecimal.valueOf(10)))
|
||||
.thenAnswer(
|
||||
i -> {
|
||||
s.setError(i.getArgument(1));
|
||||
s.setTypical(i.getArgument(2));
|
||||
return s;
|
||||
});
|
||||
assertThatThrownBy(() -> sensorController.updateValue(2L, BigDecimal.ZERO, mockPrincipal))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
assertThat(
|
||||
sensorController.updateSimulation(
|
||||
1L, BigDecimal.valueOf(30), BigDecimal.valueOf(10), mockPrincipal))
|
||||
.isSameAs(s);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue