use of com.vmware.flowgate.common.model.TranslateContext in project flowgate by vmware.
the class TranslateFunctionServiceTest method testExceptionConvertServerPeakUsedPowerMinimumUsedPowerPeakTemperature.
@Test
public void testExceptionConvertServerPeakUsedPowerMinimumUsedPowerPeakTemperature() {
String assetId = "752c0c7637104a39a4242031cd48785e";
long startTime = System.currentTimeMillis();
long endTime = startTime + 30000;
ValueUnit valueUnit = new ValueUnit();
valueUnit.setTime(endTime);
valueUnit.setKey(MetricName.SERVER_PEAK_USED_POWER);
valueUnit.setUnit(ValueUnit.MetricUnit.kW.toString());
valueUnit.setValueNum(0.07);
String displayName = MetricName.SERVER_PEAK_USED_POWER;
Function<TranslateContext, MetricData> function = TranslateFunctionService.serverFormulaKeyAndFunction.get(MetricName.SERVER_PEAK_USED_POWER);
Map<String, ValueUnit> valueUnitMap = new HashMap<>();
valueUnitMap.put(assetId, valueUnit);
TranslateContext translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
MetricData metricData = function.apply(translateContext);
TestCase.assertNull(metricData);
valueUnit.setExtraidentifier(String.valueOf(startTime));
translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
metricData = function.apply(translateContext);
TestCase.assertNull(metricData);
}
use of com.vmware.flowgate.common.model.TranslateContext in project flowgate by vmware.
the class TranslateFunctionServiceTest method testConvertByExtraIdentifier.
@Test
public void testConvertByExtraIdentifier() {
String assetId = "752c0c7637104a39a4242031cd48785e";
long currentTimeMillis = System.currentTimeMillis();
ValueUnit valueUnit = new ValueUnit();
valueUnit.setKey(MetricName.PDU_ACTIVE_POWER);
valueUnit.setUnit(ValueUnit.MetricUnit.kW.toString());
valueUnit.setExtraidentifier("OUTLET:7");
valueUnit.setValueNum(0.2);
valueUnit.setTime(currentTimeMillis);
String displayName = MetricName.PDU_XLET_ACTIVE_POWER;
Function<TranslateContext, MetricData> function = TranslateFunctionService.pduFormulaKeyAndFunction.get(MetricName.PDU_XLET_ACTIVE_POWER);
Map<String, ValueUnit> valueUnitMap = new HashMap<>();
valueUnitMap.put(assetId, valueUnit);
TranslateContext translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
MetricData metricData = function.apply(translateContext);
TestCase.assertEquals(String.format(displayName, valueUnit.getExtraidentifier()), metricData.getMetricName());
TestCase.assertEquals(valueUnit.getTime(), metricData.getTimeStamp());
TestCase.assertEquals(valueUnit.getValueNum(), metricData.getValueNum());
TestCase.assertEquals(valueUnit.getUnit(), metricData.getUnit());
}
use of com.vmware.flowgate.common.model.TranslateContext in project flowgate by vmware.
the class TranslateFunctionServiceTest method testConvertPduCurrentVoltageFreeCapacityByExtraIdentifier.
@Test
public void testConvertPduCurrentVoltageFreeCapacityByExtraIdentifier() {
String assetId = "752c0c7637104a39a4242031cd48785e";
long currentTimeMillis = System.currentTimeMillis();
ValueUnit valueUnit = new ValueUnit();
valueUnit.setKey(MetricName.PDU_CURRENT);
valueUnit.setUnit(ValueUnit.MetricUnit.A.toString());
valueUnit.setExtraidentifier("INLET:1|L1");
valueUnit.setValueNum(6);
valueUnit.setTime(currentTimeMillis);
String displayName = MetricName.PDU_INLET_XPOLE_CURRENT;
Function<TranslateContext, MetricData> function = TranslateFunctionService.pduFormulaKeyAndFunction.get(MetricName.PDU_INLET_XPOLE_CURRENT);
Map<String, ValueUnit> valueUnitMap = new HashMap<>();
valueUnitMap.put(assetId, valueUnit);
TranslateContext translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
MetricData metricData = function.apply(translateContext);
TestCase.assertEquals("INLET:1|L1|Current", metricData.getMetricName());
TestCase.assertEquals(valueUnit.getTime(), metricData.getTimeStamp());
TestCase.assertEquals(valueUnit.getValueNum(), metricData.getValueNum());
TestCase.assertEquals(valueUnit.getUnit(), metricData.getUnit());
}
Aggregations