use of com.vmware.flowgate.nlyteworker.model.ChassisSlot in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testHandleChassisSolts1.
@Test
public void testHandleChassisSolts1() {
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);
NlyteAsset nlyteAsset = getNlyteAsset().get(0);
nlyteAsset.setChassisSlots(chassisSolts);
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());
} else if (chassisslot.getSlotName().equals("2")) {
TestCase.assertEquals("Back", chassisslot.getMountingSide());
} else {
TestCase.fail();
}
}
} catch (JsonProcessingException e) {
TestCase.fail(e.getMessage());
}
}
use of com.vmware.flowgate.nlyteworker.model.ChassisSlot in project flowgate by vmware.
the class HandleAssetUtil method handleChassisSolts.
public void handleChassisSolts(Asset asset, NlyteAsset nlyteAsset) {
List<ChassisSlot> chassisSolts = nlyteAsset.getChassisSlots();
List<ChassisMountedAssetMap> chassisMountedAssets = nlyteAsset.getChassisMountedAssetMaps();
List<FlowgateChassisSlot> flowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
int usedSolts = 0;
if (chassisSolts == null || chassisSolts.isEmpty()) {
if (chassisMountedAssets == null || chassisMountedAssets.isEmpty()) {
return;
}
usedSolts = chassisMountedAssets.size();
for (ChassisMountedAssetMap caMap : chassisMountedAssets) {
FlowgateChassisSlot solt = new FlowgateChassisSlot();
solt.setColumnPosition(caMap.getColumnPosition());
solt.setMountingSide(caMap.getMountingSide());
solt.setRowPosition(caMap.getRowPosition());
solt.setSlotName(caMap.getSlotName());
solt.setMountedAssetNumber(caMap.getMountedAssetID());
flowgateChassisSlots.add(solt);
}
} else {
HashMap<String, Integer> soltsAndmountedAssetNumberMap = new HashMap<String, Integer>();
if (chassisMountedAssets != null && !chassisMountedAssets.isEmpty()) {
usedSolts = chassisMountedAssets.size();
for (ChassisMountedAssetMap caMap : chassisMountedAssets) {
soltsAndmountedAssetNumberMap.put(caMap.getMountingSide() + caMap.getSlotName(), caMap.getMountedAssetID());
}
}
for (ChassisSlot chassisSolt : chassisSolts) {
FlowgateChassisSlot solt = new FlowgateChassisSlot();
solt.setColumnPosition(chassisSolt.getColumnPosition());
solt.setMountingSide(chassisSolt.getMountingSide());
solt.setRowPosition(chassisSolt.getRowPosition());
solt.setSlotName(chassisSolt.getSlotName());
solt.setMountedAssetNumber(soltsAndmountedAssetNumberMap.get(solt.getMountingSide() + solt.getSlotName()));
flowgateChassisSlots.add(solt);
}
}
asset.setFreeCapacity(asset.getCapacity() - usedSolts);
try {
String chassisSoltsInfo = mapper.writeValueAsString(flowgateChassisSlots);
supplementChassisInfo(asset, FlowgateConstant.CHASSISSLOTS, chassisSoltsInfo);
} catch (JsonProcessingException e) {
logger.error("Failed to get info of chassisSolts.");
}
}
use of com.vmware.flowgate.nlyteworker.model.ChassisSlot 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.model.ChassisSlot in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testHandleChassisSolts.
@Test
public void testHandleChassisSolts() {
Asset asset = createAsset();
List<ChassisSlot> chassisSolts = new ArrayList<ChassisSlot>();
NlyteAsset nlyteAsset = getNlyteAsset().get(0);
HandleAssetUtil util = new HandleAssetUtil();
util.handleChassisSolts(asset, nlyteAsset);
TestCase.assertEquals(true, asset.getJustificationfields().isEmpty());
}
Aggregations