Search in sources :

Example 6 with SensorSetting

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."))));
}
Also used : SensorSetting(com.vmware.flowgate.common.model.SensorSetting) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with SensorSetting

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;
}
Also used : SensorSetting(com.vmware.flowgate.common.model.SensorSetting)

Example 8 with SensorSetting

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);
}
Also used : WormholeRequestException(com.vmware.flowgate.exception.WormholeRequestException) SensorSetting(com.vmware.flowgate.common.model.SensorSetting) WormholeRequestException(com.vmware.flowgate.exception.WormholeRequestException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SensorSetting (com.vmware.flowgate.common.model.SensorSetting)8 Test (org.junit.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 WormholeRequestException (com.vmware.flowgate.exception.WormholeRequestException)1 SymptomDefinitionsClient (com.vmware.ops.api.client.controllers.SymptomDefinitionsClient)1 HTCondition (com.vmware.ops.api.model.symptomdefinition.HTCondition)1 SymptomDefinition (com.vmware.ops.api.model.symptomdefinition.SymptomDefinition)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1