Search in sources :

Example 91 with Asset

use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.

the class SycnRealTimeDataJobTest method testGenerateRealTimeData.

@Test
public void testGenerateRealTimeData() {
    Asset asset = createAsset();
    asset.setId("5x4ff46982db22e1b040e0f2");
    HashMap<AdvanceSettingType, String> advanceSettingMap = new HashMap<AdvanceSettingType, String>();
    advanceSettingMap.put(AdvanceSettingType.DateFormat, NlyteDataService.DateFormat);
    advanceSettingMap.put(AdvanceSettingType.TimeZone, "GMT");
    RealTimeData data = nlyteDataService.generateRealTimeData(asset, nlyteAPIClient, advanceSettingMap);
    TestCase.assertEquals("5x4ff46982db22e1b040e0f2", data.getAssetID());
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) HashMap(java.util.HashMap) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) AdvanceSettingType(com.vmware.flowgate.common.model.FacilitySoftwareConfig.AdvanceSettingType) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 92 with Asset

use of com.vmware.flowgate.common.model.Asset 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 93 with Asset

use of com.vmware.flowgate.common.model.Asset 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 94 with Asset

use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.

the class SycnRealTimeDataJobTest method testGenerateNewAsset.

@Test
public void testGenerateNewAsset() {
    List<NlyteAsset> nlyteAssets = getNlyteAsset();
    HashMap<Integer, LocationGroup> locationMap = getLocationMap();
    HashMap<Integer, Material> materialMap = new HashMap<Integer, Material>();
    Material material = new Material();
    material.setMaterialID(6251);
    material.setManufacturerID(14);
    material.setMaterialName("Cisco 1721 Modular Access Router");
    material.setMaterialType(AssetCategory.Server);
    material.setMaterialSubtype(AssetSubCategory.Blade);
    materialMap.put(6251, material);
    HashMap<Integer, Manufacturer> manufacturerMap = new HashMap<Integer, Manufacturer>();
    Manufacturer manufacturer = new Manufacturer();
    manufacturer.setManufacturerID(14);
    manufacturer.setDetail("Cisco");
    manufacturerMap.put(14, manufacturer);
    Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType("l9i8728d55368540fcba1692", AssetCategory.Server)).thenReturn(new ArrayList<Asset>());
    HashMap<Long, String> chassisMountedAssetNumberAndChassisIDMap = new HashMap<Long, String>();
    chassisMountedAssetNumberAndChassisIDMap.put(197L, "asdqe945kjsdf09uw45ms");
    List<Asset> assets = nlyteDataService.generateAssets("l9i8728d55368540fcba1692", nlyteAssets, locationMap, manufacturerMap, materialMap, AssetCategory.Server, chassisMountedAssetNumberAndChassisIDMap);
    for (Asset asset : assets) {
        if ("sin2-blrqeops-esxstress024".equals(asset.getAssetName())) {
            TestCase.assertEquals(197, asset.getAssetNumber());
            TestCase.assertEquals("SG-07-04", asset.getRoom());
            TestCase.assertEquals("Cisco 1721 Modular Access Router", asset.getModel());
            TestCase.assertEquals("Cisco", asset.getManufacturer());
            TestCase.assertEquals("asdqe945kjsdf09uw45ms", asset.getParent().getParentId());
        }
    }
}
Also used : HashMap(java.util.HashMap) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Material(com.vmware.flowgate.nlyteworker.model.Material) 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 95 with Asset

use of com.vmware.flowgate.common.model.Asset 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());
}
Also used : HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) ArrayList(java.util.ArrayList) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) 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)

Aggregations

Asset (com.vmware.flowgate.common.model.Asset)173 Test (org.junit.Test)96 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)90 HashMap (java.util.HashMap)86 ArrayList (java.util.ArrayList)82 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)36 NlyteAsset (com.vmware.flowgate.nlyteworker.model.NlyteAsset)35 Map (java.util.Map)34 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)31 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)23 IOException (java.io.IOException)23 ServerMapping (com.vmware.flowgate.common.model.ServerMapping)22 MetricData (com.vmware.flowgate.common.model.MetricData)16 HandleAssetUtil (com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil)16 HashSet (java.util.HashSet)15 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)13 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)13 List (java.util.List)12 MvcResult (org.springframework.test.web.servlet.MvcResult)12 TypeReference (com.fasterxml.jackson.core.type.TypeReference)10