use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingControllerTest method sensorSettingDeleteExample.
@Test
public void sensorSettingDeleteExample() throws Exception {
SensorSetting sensorsetting = createSensorSetting();
sensorSettingRepository.save(sensorsetting);
this.mockMvc.perform(delete("/v1/sensors/setting/{Id}", sensorsetting.getId())).andExpect(status().isOk()).andDo(document("sensorSetting-delete-example", pathParameters(parameterWithName("Id").description("The id of sensorSetting,generated by flowgate."))));
}
use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingControllerTest method createSensorSetting.
SensorSetting createSensorSetting() {
SensorSetting example = new SensorSetting();
example.setId(UUID.randomUUID().toString());
example.setType(MetricName.SERVER_BACK_TEMPREATURE);
example.setMaxNum(35);
example.setMinNum(5);
example.setMaxValue("maxValue");
example.setMinValue("minValue");
return example;
}
use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingController method updateSensorSetting.
// Update
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/setting", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateSensorSetting(@RequestBody SensorSetting sensorSetting) {
Optional<SensorSetting> oldSensorSettingOptional = repository.findById(sensorSetting.getId());
if (!oldSensorSettingOptional.isPresent()) {
throw WormholeRequestException.NotFound("SensorSetting", "id", sensorSetting.getId());
}
SensorSetting old = oldSensorSettingOptional.get();
try {
BaseDocumentUtil.applyChanges(old, sensorSetting);
} catch (Exception e) {
throw new WormholeRequestException("Failed to update the Sensor setting.", e);
}
repository.save(old);
}
Aggregations