use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testHandleChassisSolts2.
@Test
public void testHandleChassisSolts2() {
Asset asset = createAsset();
List<ChassisSlot> chassisSolts = new ArrayList<ChassisSlot>();
ChassisSlot slot = new ChassisSlot();
slot.setChassisAssetID(105);
slot.setColumnPosition(1);
slot.setRowPosition(1);
slot.setMountingSide("Front");
slot.setSlotName("1");
slot.setId(78);
chassisSolts.add(slot);
ChassisSlot slot2 = new ChassisSlot();
slot2.setChassisAssetID(105);
slot2.setColumnPosition(1);
slot2.setRowPosition(2);
slot2.setMountingSide("Back");
slot2.setSlotName("2");
slot2.setId(79);
chassisSolts.add(slot2);
List<ChassisMountedAssetMap> cmAssets = new ArrayList<ChassisMountedAssetMap>();
ChassisMountedAssetMap cmAsset = new ChassisMountedAssetMap();
cmAsset.setMountedAssetID(197);
cmAsset.setMountingSide("Front");
cmAsset.setSlotName("1");
cmAssets.add(cmAsset);
ChassisMountedAssetMap cmAsset2 = new ChassisMountedAssetMap();
cmAsset2.setMountedAssetID(198);
cmAsset2.setMountingSide("Back");
cmAsset2.setSlotName("2");
cmAssets.add(cmAsset2);
NlyteAsset nlyteAsset = getNlyteAsset().get(0);
nlyteAsset.setChassisSlots(chassisSolts);
nlyteAsset.setChassisMountedAssetMaps(cmAssets);
HandleAssetUtil util = new HandleAssetUtil();
util.handleChassisSolts(asset, nlyteAsset);
String chassisInfo = asset.getJustificationfields().get(FlowgateConstant.CHASSIS);
ObjectMapper mapper = new ObjectMapper();
try {
Map<String, String> chassisInfoMap = mapper.readValue(chassisInfo, new TypeReference<Map<String, String>>() {
});
List<FlowgateChassisSlot> slots = mapper.readValue(chassisInfoMap.get(FlowgateConstant.CHASSISSLOTS), new TypeReference<List<FlowgateChassisSlot>>() {
});
for (FlowgateChassisSlot chassisslot : slots) {
if (chassisslot.getSlotName().equals("1")) {
TestCase.assertEquals("Front", chassisslot.getMountingSide());
TestCase.assertEquals(Integer.valueOf(197), chassisslot.getMountedAssetNumber());
} else if (chassisslot.getSlotName().equals("2")) {
TestCase.assertEquals("Back", chassisslot.getMountingSide());
TestCase.assertEquals(Integer.valueOf(198), chassisslot.getMountedAssetNumber());
} else {
TestCase.fail();
}
}
} catch (JsonProcessingException e) {
TestCase.fail(e.getMessage());
}
}
use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testChassisSlotsIsChanged5.
@Test
public void testChassisSlotsIsChanged5() {
List<FlowgateChassisSlot> oldFlowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
FlowgateChassisSlot slot = createFlowgateChassisSlot();
oldFlowgateChassisSlots.add(slot);
List<FlowgateChassisSlot> newFlowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
FlowgateChassisSlot slot1 = createFlowgateChassisSlot();
slot1.setColumnPosition(2);
newFlowgateChassisSlots.add(slot1);
HandleAssetUtil util = new HandleAssetUtil();
TestCase.assertEquals(true, util.chassisSlotsIsChanged(oldFlowgateChassisSlots, newFlowgateChassisSlots));
}
use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testSupplementChassisInfo1.
@Test
public void testSupplementChassisInfo1() {
Asset asset = createAsset();
HashMap<String, String> justficationMap = new HashMap<String, String>();
Map<String, String> chassisInfoMap = new HashMap<String, String>();
ObjectMapper mapper = new ObjectMapper();
try {
chassisInfoMap.put(FlowgateConstant.CHASSIS_AIR_FLOW_TYPE, "frontToBack");
String chassisInfo = mapper.writeValueAsString(chassisInfoMap);
justficationMap.put(FlowgateConstant.CHASSIS, chassisInfo);
asset.setJustificationfields(justficationMap);
HandleAssetUtil util = new HandleAssetUtil();
util.supplementChassisInfo(asset, FlowgateConstant.CHASSIS_AIR_FLOW_TYPE, "backToFront");
justficationMap = asset.getJustificationfields();
chassisInfo = justficationMap.get(FlowgateConstant.CHASSIS);
chassisInfoMap = mapper.readValue(chassisInfo, new TypeReference<Map<String, String>>() {
});
TestCase.assertEquals("backToFront", chassisInfoMap.get(FlowgateConstant.CHASSIS_AIR_FLOW_TYPE));
} catch (Exception e) {
TestCase.fail(e.getMessage());
}
}
use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testGetAssetsFromNlytePdu.
@Test
public void testGetAssetsFromNlytePdu() {
String nlyteSource = "3cf0f5daff8e448da449ac88d5aa9428";
List<NlyteAsset> nlyteAssets = getNlyteAsset();
HashMap<Integer, LocationGroup> locationMap = getLocationMap();
HashMap<Integer, Material> materialMap = getMaterialMap();
Material material = new Material();
material.setMaterialID(6251);
material.setManufacturerID(14);
material.setMaterialName("Cisco 1721 Modular Access Router");
material.setMaterialType(AssetCategory.Server);
materialMap.put(6251, material);
HashMap<Integer, Manufacturer> manufacturerMap = getManufacturerMap();
Manufacturer manufacturer = new Manufacturer();
manufacturer.setManufacturerID(14);
manufacturer.setDetail("Cisco");
manufacturerMap.put(14, manufacturer);
HashMap<Long, String> chassisMountedAssetNumberAndChassisIdMap = null;
HandleAssetUtil util = new HandleAssetUtil();
List<Asset> assets = util.getAssetsFromNlyte(nlyteSource, nlyteAssets, locationMap, materialMap, manufacturerMap, chassisMountedAssetNumberAndChassisIdMap);
}
use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testChassisSlotsIsChanged6.
@Test
public void testChassisSlotsIsChanged6() {
List<FlowgateChassisSlot> oldFlowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
FlowgateChassisSlot slot = createFlowgateChassisSlot();
oldFlowgateChassisSlots.add(slot);
List<FlowgateChassisSlot> newFlowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
FlowgateChassisSlot slot1 = createFlowgateChassisSlot();
slot1.setRowPosition(2);
newFlowgateChassisSlots.add(slot1);
HandleAssetUtil util = new HandleAssetUtil();
TestCase.assertEquals(true, util.chassisSlotsIsChanged(oldFlowgateChassisSlots, newFlowgateChassisSlots));
}
Aggregations