Search in sources :

Example 1 with Sensor

use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.

the class SyncSensorMetaDataJobTest method testGetSensorRealTimeData1.

@Test
public void testGetSensorRealTimeData1() {
    HashMap<String, String> justificationfields = generateExtraInfo("6566");
    Asset asset = createAsset();
    asset.setId("123o89qw4jjasd0");
    asset.setJustificationfields(justificationfields);
    Sensor sensor = createSensor();
    sensor.setId(6566);
    sensor.setName("HumiditySensor");
    sensor.setSerialNumber("8999");
    sensor.setType("HumiditySensor");
    Mockito.when(this.powerIQAPIClient.getSensorById("6566")).thenReturn(sensor);
    List<Asset> assets = new ArrayList<Asset>();
    assets.add(asset);
    List<RealTimeData> realTimeDatas = powerIQService.getSensorRealTimeData(createFacility(), assets);
    TestCase.assertEquals(0, realTimeDatas.size());
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) ArrayList(java.util.ArrayList) Asset(com.vmware.flowgate.common.model.Asset) Sensor(com.vmware.flowgate.poweriqworker.model.Sensor) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Sensor

use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.

the class SyncSensorMetaDataJobTest method createSensor.

Sensor createSensor() {
    Sensor sensor = new Sensor();
    Parent parent = new Parent();
    parent.setId(2);
    parent.setType("rack");
    sensor.setParent(parent);
    return sensor;
}
Also used : Parent(com.vmware.flowgate.poweriqworker.model.Parent) Sensor(com.vmware.flowgate.poweriqworker.model.Sensor)

Example 3 with Sensor

use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.

the class SyncSensorMetaDataJobTest method testGetSensorRealTimeData2.

@Test
public void testGetSensorRealTimeData2() {
    HashMap<String, String> justificationfields = generateExtraInfo("6566");
    Asset asset = createAsset();
    asset.setId("123o89qw4jjasd0");
    asset.setJustificationfields(justificationfields);
    HashMap<String, String> justificationfields1 = generateExtraInfo("6567");
    Asset asset1 = createAsset();
    asset1.setId("123o89qw4jjasd1");
    asset1.setJustificationfields(justificationfields1);
    Sensor sensor = createSensor();
    SensorReading sensorReading = createReading();
    sensorReading.setUom("%");
    sensor.setId(6566);
    sensor.setName("HumiditySensor");
    sensor.setSerialNumber("8999");
    sensor.setType("HumiditySensor");
    sensor.setReading(sensorReading);
    Mockito.when(this.powerIQAPIClient.getSensorById("6566")).thenReturn(sensor);
    Sensor sensor1 = createSensor();
    SensorReading sensorReading1 = createReading();
    sensorReading1.setUom("F");
    sensor1.setId(6567);
    sensor1.setName("TemperatureSensor");
    sensor1.setSerialNumber("9000");
    sensor1.setType("TemperatureSensor");
    sensor1.setReading(sensorReading1);
    Mockito.when(this.powerIQAPIClient.getSensorById("6567")).thenReturn(sensor1);
    Set<String> assetIds = new HashSet<String>();
    assetIds.add("123o89qw4jjasd0");
    assetIds.add("123o89qw4jjasd1");
    List<Asset> assets = new ArrayList<Asset>();
    assets.add(asset);
    assets.add(asset1);
    List<RealTimeData> realTimeDatas = powerIQService.getSensorRealTimeData(createFacility(), assets);
    for (RealTimeData realtimedata : realTimeDatas) {
        if ("123o89qw4jjasd0".equals(realtimedata.getAssetID())) {
            TestCase.assertEquals((double) 100, realtimedata.getValues().get(0).getValueNum());
        } else {
            TestCase.assertEquals((double) (100 - 32) * 5 / 9, realtimedata.getValues().get(0).getValueNum());
        }
    }
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) SensorReading(com.vmware.flowgate.poweriqworker.model.SensorReading) ArrayList(java.util.ArrayList) Asset(com.vmware.flowgate.common.model.Asset) Sensor(com.vmware.flowgate.poweriqworker.model.Sensor) HashSet(java.util.HashSet) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with Sensor

use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.

the class SyncSensorMetaDataJobTest method getSensors.

List<Sensor> getSensors() {
    List<Sensor> sensors = new ArrayList<Sensor>();
    Sensor sensor = createSensor();
    sensor.setId(6566);
    sensor.setName("HumiditySensor");
    sensor.setSerialNumber("8999");
    sensor.setType("HumiditySensor");
    sensors.add(sensor);
    Sensor sensor1 = createSensor();
    sensor1.setId(7878);
    sensor1.setSerialNumber("5487");
    sensor1.setName("TemperatureSensor01");
    sensor1.setType("TemperatureSensor");
    sensor1.setPduId(2L);
    sensors.add(sensor1);
    return sensors;
}
Also used : ArrayList(java.util.ArrayList) Sensor(com.vmware.flowgate.poweriqworker.model.Sensor)

Example 5 with Sensor

use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.

the class SyncSensorMetaDataJobTest method testAggregatorSensorIdAndSourceForPdu3.

@Test
public void testAggregatorSensorIdAndSourceForPdu3() {
    Asset pdu = createAsset1();
    HashMap<String, String> justificationfields = new HashMap<String, String>();
    justificationfields.put(AssetSubCategory.Temperature.toString(), "509_l9i8728d55368540fcba1692");
    pdu.setJustificationfields(justificationfields);
    Sensor sensor = new Sensor();
    sensor.setId(606);
    sensor.setType(PowerIQService.HumiditySensor);
    String source = "l9i8728d55368540fcba1692";
    pdu = powerIQService.aggregatorSensorIdAndSourceForPdu(pdu, sensor, source);
    TestCase.assertEquals(sensor.getId() + FlowgateConstant.SEPARATOR + source, pdu.getJustificationfields().get(AssetSubCategory.Humidity.toString()));
}
Also used : HashMap(java.util.HashMap) Asset(com.vmware.flowgate.common.model.Asset) Sensor(com.vmware.flowgate.poweriqworker.model.Sensor) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Sensor (com.vmware.flowgate.poweriqworker.model.Sensor)13 Asset (com.vmware.flowgate.common.model.Asset)10 Test (org.junit.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)4 SensorReading (com.vmware.flowgate.poweriqworker.model.SensorReading)3 PowerIQAPIClient (com.vmware.flowgate.poweriqworker.client.PowerIQAPIClient)2 Parent (com.vmware.flowgate.poweriqworker.model.Parent)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 WormholeException (com.vmware.flowgate.common.exception.WormholeException)1 AdvanceSettingType (com.vmware.flowgate.common.model.FacilitySoftwareConfig.AdvanceSettingType)1 IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)1 ValueUnit (com.vmware.flowgate.common.model.ValueUnit)1 MetricUnit (com.vmware.flowgate.common.model.ValueUnit.MetricUnit)1 LocationInfo (com.vmware.flowgate.poweriqworker.model.LocationInfo)1 SensorResult (com.vmware.flowgate.poweriqworker.model.SensorResult)1