use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method testGetSensorRealTimeData.
@Test
public void testGetSensorRealTimeData() {
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");
SensorReading sensorReading = new SensorReading();
sensorReading.setReadingTime("2019/02/14 04:31:14 +0200");
sensorReading.setValue(30.0);
sensorReading.setUom("%");
sensor.setReading(sensorReading);
Mockito.when(this.powerIQAPIClient.getSensorById("6566")).thenReturn(sensor);
Set<String> assetIds = new HashSet<String>();
assetIds.add("123o89qw4jjasd0");
List<Asset> assets = new ArrayList<Asset>();
assets.add(asset);
List<RealTimeData> realTimeDatas = powerIQService.getSensorRealTimeData(createFacility(), assets);
for (RealTimeData realtimeData : realTimeDatas) {
TestCase.assertEquals("123o89qw4jjasd0", realtimeData.getAssetID());
TestCase.assertEquals(1550111474000l, realtimeData.getTime());
if ("123o89qw4jjasd0".equals(realtimeData.getAssetID())) {
TestCase.assertEquals("%", realtimeData.getValues().get(0).getUnit());
}
}
}
use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method testAggregatorSensorIdAndSourceForPdu1.
@Test
public void testAggregatorSensorIdAndSourceForPdu1() {
Asset pdu = createAsset1();
HashMap<String, String> justificationfields = new HashMap<String, String>();
justificationfields.put(AssetSubCategory.Humidity.toString(), "509" + FlowgateConstant.SEPARATOR + "l9i8728d55368540fcba1692");
pdu.setJustificationfields(justificationfields);
Sensor sensor = new Sensor();
sensor.setId(509);
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()));
}
use of com.vmware.flowgate.poweriqworker.model.Sensor in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method testSaveSensorAssetsToFlowgate.
@Test
public void testSaveSensorAssetsToFlowgate() {
Map<String, Asset> exsitingSensorAssets = new HashMap<>();
Asset asset1 = createAsset();
asset1.setId("18672301765107L");
Asset asset2 = createAsset();
asset2.setId("BOQBNBHQOQJAOJQY");
exsitingSensorAssets.put(asset1.getId(), asset1);
exsitingSensorAssets.put(asset2.getId(), asset2);
String assetSource = "UGVINQVNQIGQGQIDNKD";
LocationInfo location = new LocationInfo();
Sensor sensor1 = createSensor();
sensor1.setId(18672301765107L);
sensor1.setName("sensor-1");
sensor1.setType("TemperatureSensor");
Sensor sensor2 = createSensor();
sensor2.setId(81675117203607L);
sensor2.setName("sensor-2");
sensor2.setType("HumiditySensor");
Sensor sensor3 = createSensor();
sensor3.setId(61675386203607L);
sensor3.setName("sensor-3");
sensor3.setType("TemperatureSensor");
Sensor sensor4 = createSensor();
sensor4.setId(38661675203607L);
sensor4.setName("sensor-4");
sensor4.setType("AirFlowSensor");
Mockito.doReturn(new ArrayList<>()).when(wormholeAPIClient).getAllAssetsBySourceAndType(Mockito.anyString(), Mockito.any());
Mockito.doReturn(new ArrayList<>(Arrays.asList(sensor1, sensor2, sensor3, sensor4))).when(powerIQAPIClient).getSensors(100, 0);
Mockito.doReturn(null).when(powerIQAPIClient).getSensors(100, 1);
Mockito.doReturn(new ResponseEntity<Void>(HttpStatus.OK)).when(wormholeAPIClient).saveAssets(Mockito.any(Asset.class));
Mockito.doReturn("32c1d6dacf248a23553edbc6bbc922cd").when(powerIQService).getAssetIdByResponseEntity(Mockito.any(ResponseEntity.class));
powerIQService.saveSensorAssetsToFlowgate(exsitingSensorAssets, powerIQAPIClient, assetSource, location);
}
Aggregations