Search in sources :

Example 11 with HandleAssetUtil

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());
    }
}
Also used : NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) ArrayList(java.util.ArrayList) ChassisMountedAssetMap(com.vmware.flowgate.nlyteworker.model.ChassisMountedAssetMap) FlowgateChassisSlot(com.vmware.flowgate.common.model.FlowgateChassisSlot) HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ChassisMountedAssetMap(com.vmware.flowgate.nlyteworker.model.ChassisMountedAssetMap) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FlowgateChassisSlot(com.vmware.flowgate.common.model.FlowgateChassisSlot) ChassisSlot(com.vmware.flowgate.nlyteworker.model.ChassisSlot) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 12 with HandleAssetUtil

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));
}
Also used : FlowgateChassisSlot(com.vmware.flowgate.common.model.FlowgateChassisSlot) HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) ArrayList(java.util.ArrayList) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 13 with HandleAssetUtil

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());
    }
}
Also used : HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) HashMap(java.util.HashMap) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 14 with HandleAssetUtil

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);
}
Also used : NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Material(com.vmware.flowgate.nlyteworker.model.Material) HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) Manufacturer(com.vmware.flowgate.nlyteworker.model.Manufacturer) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) LocationGroup(com.vmware.flowgate.nlyteworker.model.LocationGroup) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 15 with HandleAssetUtil

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));
}
Also used : FlowgateChassisSlot(com.vmware.flowgate.common.model.FlowgateChassisSlot) HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) ArrayList(java.util.ArrayList) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

HandleAssetUtil (com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil)26 Test (org.junit.Test)21 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 NlyteAsset (com.vmware.flowgate.nlyteworker.model.NlyteAsset)18 ArrayList (java.util.ArrayList)17 Asset (com.vmware.flowgate.common.model.Asset)16 FlowgateChassisSlot (com.vmware.flowgate.common.model.FlowgateChassisSlot)13 HashMap (java.util.HashMap)12 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 ChassisMountedAssetMap (com.vmware.flowgate.nlyteworker.model.ChassisMountedAssetMap)6 List (java.util.List)6 Map (java.util.Map)6 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)6 Tenant (com.vmware.flowgate.common.model.Tenant)5 ChassisSlot (com.vmware.flowgate.nlyteworker.model.ChassisSlot)3 LocationGroup (com.vmware.flowgate.nlyteworker.model.LocationGroup)3 Manufacturer (com.vmware.flowgate.nlyteworker.model.Manufacturer)3 Material (com.vmware.flowgate.nlyteworker.model.Material)3 IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)2