use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SyncRealTimeDataJobTest method createAsset.
Asset createAsset() {
Asset asset = new Asset();
asset.setAssetName("pek-wor-pdu-02");
asset.setAssetNumber(12345);
asset.setAssetSource("l9i8728d55368540fcba1692");
asset.setCategory(AssetCategory.PDU);
asset.setModel("Dell 750");
asset.setManufacturer("Dell");
return asset;
}
use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SyncRealTimeDataJobTest method testGetMatchedPdus1.
@Test
public void testGetMatchedPdus1() {
Pdu pdu = createPdu();
pdu.setName("pek-wor-pdu");
Asset asset = createAsset();
List<Asset> assets = new ArrayList<Asset>();
assets.add(asset);
Map<String, Pdu> filterCondition = new HashMap<String, Pdu>();
filterCondition.put(pdu.getName(), pdu);
Map<String, Pdu> map = powerIQService.getMatchedPdus(filterCondition, assets);
TestCase.assertEquals(true, map.isEmpty());
}
use of com.vmware.flowgate.common.model.Asset 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());
}
use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method testUpdateServer.
@Test
public void testUpdateServer() throws JsonProcessingException {
List<Asset> assets = new ArrayList<Asset>();
Asset server = createAsset();
server.setAssetName("pek-wor-server");
server.setCategory(AssetCategory.Server);
Map<String, String> formulars = new HashMap<>();
Map<String, String> sensorLocationAndId = new HashMap<String, String>();
sensorLocationAndId.put("Rack01", "256");
sensorLocationAndId.put("Rack02", "128");
Map<String, Map<String, String>> sensorInfo = new HashMap<String, Map<String, String>>();
sensorInfo.put("FRONT", sensorLocationAndId);
formulars.put(FlowgateConstant.SENSOR, mapper.writeValueAsString(sensorInfo));
server.setMetricsformulars(formulars);
assets.add(server);
List<Asset> servers = powerIQService.updateServer(assets, "128");
TestCase.assertEquals(assets.size(), servers.size());
Asset updatedServer = servers.get(0);
Map<String, String> formulars1 = updatedServer.getMetricsformulars();
Map<String, Map<String, String>> sensorInfo1 = formatSensorFormulas(formulars1.get(FlowgateConstant.SENSOR));
Map<String, String> sensorLocationAndId1 = sensorInfo1.get("FRONT");
TestCase.assertEquals(1, sensorLocationAndId1.size());
TestCase.assertEquals("256", sensorLocationAndId1.entrySet().iterator().next().getValue());
}
use of com.vmware.flowgate.common.model.Asset 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());
}
}
}
Aggregations