From 71302933e6d82b25cae85f8774c7a925ebf5acd8 Mon Sep 17 00:00:00 2001 From: omenem Date: Wed, 27 May 2020 18:20:00 +0200 Subject: [PATCH 1/3] fix --- .../sa4/sanmarinoes/smarthut/controller/SensorController.java | 4 ++-- .../inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java index a014e79..c58d68f 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java @@ -64,8 +64,8 @@ public class SensorController { @PutMapping("/{id}/simulation") public Sensor updateSimulation( @PathVariable("id") Long sensorId, - @RequestParam("error") BigDecimal error, - @RequestParam("typical") BigDecimal typical, + @RequestBody BigDecimal error, + @RequestBody BigDecimal typical, final Principal principal) throws NotFoundException { return sensorService.updateSimulationFromSensor( diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java index f5558c7..59a089a 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java @@ -20,10 +20,6 @@ public class SensorSaveRequest { @NotNull private BigDecimal value; - private BigDecimal error; - - private BigDecimal typical; - /** * The room this device belongs in, as a foreign key id. To use when updating and inserting from * a REST call. From 66b22064b41fefb6fad5fdb7550efdd69d337519 Mon Sep 17 00:00:00 2001 From: omenem Date: Wed, 27 May 2020 18:24:45 +0200 Subject: [PATCH 2/3] fix --- .../sanmarinoes/smarthut/dto/SensorSaveRequestTests.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequestTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequestTests.java index 2ca98e8..6c99297 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequestTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequestTests.java @@ -30,13 +30,7 @@ public class SensorSaveRequestTests { @DisplayName("test constructor") public void testConstructorNotEmpty() { SensorSaveRequest newSaveRequest = - new SensorSaveRequest( - Sensor.SensorType.HUMIDITY, - new BigDecimal(12), - BigDecimal.ZERO, - BigDecimal.ZERO, - 12L, - "name"); + new SensorSaveRequest(Sensor.SensorType.HUMIDITY, new BigDecimal(12), 12L, "name"); assertNotNull(newSaveRequest.getSensor()); assertNotNull(newSaveRequest.getName()); assertNotNull(newSaveRequest.getRoomId()); From 50d7c77177b0ac6c8e7508e40ad33e2e98f15927 Mon Sep 17 00:00:00 2001 From: omenem Date: Wed, 27 May 2020 18:28:21 +0200 Subject: [PATCH 3/3] fix --- .../smarthut/controller/SensorControllerTests.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorControllerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorControllerTests.java index c56537e..756a3b6 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorControllerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorControllerTests.java @@ -69,12 +69,7 @@ public class SensorControllerTests { final SensorSaveRequest toSend = new SensorSaveRequest( - Sensor.SensorType.TEMPERATURE, - BigDecimal.ZERO, - BigDecimal.ZERO, - BigDecimal.ZERO, - 42L, - "Test sensor"); + Sensor.SensorType.TEMPERATURE, BigDecimal.ZERO, 42L, "Test sensor"); final Sensor created = sensorController.create(toSend, mockPrincipal); checkSensorAgainstRequest(created, toSend);