use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingControllerTest method udapteAnSensorSetting.
@Test
public void udapteAnSensorSetting() throws JsonProcessingException, Exception {
SensorSetting sensorsetting = createSensorSetting();
sensorSettingRepository.save(sensorsetting);
sensorsetting.setMaxNum(25);
this.mockMvc.perform(put("/v1/sensors/setting").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(sensorsetting))).andExpect(status().isOk()).andDo(document("sensorSetting-update-example", requestFields(fieldWithPath("id").description("ID of the sensorSetting, created by flowgate"), fieldWithPath("type").description("The sensor type."), fieldWithPath("minNum").description("Value type is double"), fieldWithPath("maxNum").description("Value type is double"), fieldWithPath("minValue").description("Value type is string"), fieldWithPath("maxValue").description("Value type is string"))));
sensorSettingRepository.deleteById(sensorsetting.getId());
}
use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingControllerTest method sensorQuerySettingByIDExample.
@Test
public void sensorQuerySettingByIDExample() throws Exception {
SensorSetting sensorsetting = createSensorSetting();
sensorSettingRepository.save(sensorsetting);
this.mockMvc.perform(get("/v1/sensors/setting/" + sensorsetting.getId()).content("{\"id\":\"" + sensorsetting.getId() + "\"}")).andExpect(status().isOk()).andDo(document("sensorSetting-querySetting-example", responseFields(fieldWithPath("id").description("ID of the sensorSetting, created by flowgate"), fieldWithPath("type").description("The sensor type."), fieldWithPath("minNum").description("Value type is double"), fieldWithPath("maxNum").description("Value type is double"), fieldWithPath("minValue").description("Value type is string"), fieldWithPath("maxValue").description("Value type is string"))));
sensorSettingRepository.deleteById(sensorsetting.getId());
}
use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingControllerTest method createAnSensorSetting.
@Test
public void createAnSensorSetting() throws JsonProcessingException, Exception {
SensorSetting sensorsetting = createSensorSetting();
this.mockMvc.perform(post("/v1/sensors/setting").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(sensorsetting))).andExpect(status().isCreated()).andDo(document("sensorSetting-create-example", requestFields(fieldWithPath("id").description("ID of the sensorSetting, created by flowgate"), fieldWithPath("type").description("The sensor type."), fieldWithPath("minNum").description("Value type is double"), fieldWithPath("maxNum").description("Value type is double"), fieldWithPath("minValue").description("Value type is string"), fieldWithPath("maxValue").description("Value type is string"))));
sensorSettingRepository.deleteById(sensorsetting.getId());
}
use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class SensorSettingControllerTest method sensorSettingQueryByPageExample.
@Test
public void sensorSettingQueryByPageExample() throws Exception {
SensorSetting sensorsetting = createSensorSetting();
sensorSettingRepository.save(sensorsetting);
int pageNumber = 1;
int pageSize = 5;
this.mockMvc.perform(get("/v1/sensors/setting/page/" + pageNumber + "/pagesize/" + pageSize + "").content("{\"pageNumber\":1,\"pageSize\":5}")).andExpect(status().isOk()).andExpect(jsonPath("$.content[0].maxNum").value(sensorsetting.getMaxNum())).andExpect(jsonPath("$..content.length()").value(1)).andExpect(jsonPath("last", is(true))).andExpect(jsonPath("number", is(0))).andExpect(jsonPath("size", is(5))).andExpect(jsonPath("first", is(true))).andDo(document("sensorSetting-queryByPage-example", requestFields(fieldWithPath("pageNumber").description("get datas for this page number."), fieldWithPath("pageSize").description("The number of data displayed per page."))));
sensorSettingRepository.deleteById(sensorsetting.getId());
}
use of com.vmware.flowgate.common.model.SensorSetting in project flowgate by vmware.
the class AlertClient method checkPredefinedSymptoms.
private Map<String, SymptomDefinition> checkPredefinedSymptoms() {
Map<String, SymptomDefinition> existSymptoms = getPredefinedSymptoms();
if (existSymptoms.size() < predefinedSymptomNames.size()) {
Set<String> missingSymptoms = new HashSet<String>(predefinedSymptomNames);
missingSymptoms.removeAll(existSymptoms.keySet());
createPredefinedSymptoms(missingSymptoms, existSymptoms);
} else {
// check whether we need to update the threshold of the symptoms
List<SensorSetting> sensorSettings = new ArrayList<SensorSetting>();
SensorSetting backTempSetting = new SensorSetting();
backTempSetting.setMaxNum(35);
backTempSetting.setType(MetricName.SERVER_BACK_TEMPREATURE);
sensorSettings.add(backTempSetting);
SensorSetting frontTempSetting = new SensorSetting();
frontTempSetting.setMaxNum(35);
frontTempSetting.setType(MetricName.SERVER_FRONT_TEMPERATURE);
sensorSettings.add(frontTempSetting);
SensorSetting backHumiditySetting = new SensorSetting();
backHumiditySetting.setMaxNum(75);
backHumiditySetting.setType(MetricName.SERVER_BACK_HUMIDITY);
sensorSettings.add(backHumiditySetting);
SensorSetting frontHumiditySetting = new SensorSetting();
frontHumiditySetting.setMaxNum(75);
frontHumiditySetting.setType(MetricName.SERVER_FRONT_HUMIDITY);
sensorSettings.add(frontHumiditySetting);
SensorSetting currentLoadSetting = new SensorSetting();
currentLoadSetting.setMaxNum(67);
currentLoadSetting.setType(MetricName.PDU_CURRENT_LOAD);
sensorSettings.add(currentLoadSetting);
Map<String, SensorSetting> symptomCondtionValues = getSymptomCondtionValues(sensorSettings);
SymptomDefinitionsClient sd = getClient().symptomDefinitionsClient();
for (SymptomDefinition symptom : existSymptoms.values()) {
HTCondition condition = (HTCondition) symptom.getState().getCondition();
SensorSetting sensorSetting = symptomCondtionValues.get(symptom.getName());
if (sensorSetting != null) {
if (!condition.getValue().equals((String.valueOf(sensorSetting.getMaxNum())))) {
condition.setValue(String.valueOf(sensorSetting.getMaxNum()));
sd.updateSymptomDefinition(symptom);
}
}
}
}
return existSymptoms;
}
Aggregations