Search in sources :

Example 6 with Asset

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

the class SyncWiremapDataJobTest method createPdu.

Asset createPdu() {
    Asset asset = new Asset();
    asset.setAssetName("ams5-k03-b-pdu");
    asset.setAssetNumber(328076);
    asset.setAssetSource("5c74da749662e398e01f665f");
    asset.setCategory(AssetCategory.PDU);
    return asset;
}
Also used : Asset(com.vmware.flowgate.common.model.Asset)

Example 7 with Asset

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

the class SyncWiremapDataJobTest method generatorWiremapDataTest1.

@Test
public void generatorWiremapDataTest1() {
    Asset assetFromflowgate = createServer();
    EndDevice net1 = new EndDevice();
    net1.setEndDeviceAssetId("5c8749469662e32e2470d654");
    net1.setEndDeviceName("w4-pek2");
    net1.setEndPort("onboard-1");
    net1.setStartPort("03");
    EndDevice net2 = new EndDevice();
    net2.setEndDeviceAssetId("5c778c598ecf859960e2be30");
    net2.setEndDeviceName("sin2-build-rdev1");
    net2.setEndPort("onboard-1");
    net2.setStartPort("01");
    HashSet<String> nets = new HashSet<String>();
    HashMap<String, String> fileds = new HashMap<String, String>();
    nets.add(net1.toString());
    nets.add(net2.toString());
    fileds.put(FlowgateConstant.NETWORK_PORT_FOR_SERVER, String.join(FlowgateConstant.SPILIT_FLAG, nets));
    assetFromflowgate.setJustificationfields(fileds);
    Map<String, String> network = new HashMap<String, String>();
    network.put("sin2-build-rdev1", "5c778c598ecf859960e2be30");
    Map<String, String> pdu = new HashMap<String, String>();
    pdu.put("w3r17c05-pdu4", "wertbhukloiup5996q23df530");
    List<EndDevice> devices = getDevices();
    Asset asset = labsdbService.generatorWiremapData(assetFromflowgate, pdu, devices, network);
    List<String> networks = asset.getSwitches();
    TestCase.assertEquals("5c778c598ecf859960e2be30", networks.get(0));
    String networkdevices = asset.getJustificationfields().get(FlowgateConstant.NETWORK_PORT_FOR_SERVER);
    String expectValue = String.join(FlowgateConstant.SPILIT_FLAG, nets);
    TestCase.assertEquals(expectValue, networkdevices);
}
Also used : EndDevice(com.vmware.flowgate.labsdb.common.EndDevice) HashMap(java.util.HashMap) Asset(com.vmware.flowgate.common.model.Asset) HashSet(java.util.HashSet) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with Asset

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

the class SyncWiremapDataJobTest method filterServersTest4.

// PduMappingStatus and NetworkMappingStatus is not null
@Test
public void filterServersTest4() {
    List<Asset> servers = new ArrayList<Asset>();
    Asset asset1 = new Asset();
    asset1.setId("5c778c598ecf859960e2c2a0");
    asset1.setAssetName("w1-lil-c-016");
    asset1.setAssetNumber(33503);
    asset1.setAssetSource("5c74da749662e398e01f665f");
    asset1.setCategory(AssetCategory.Server);
    asset1.setModel("Dell");
    asset1.setManufacturer("Dell");
    AssetStatus assetstatus = new AssetStatus();
    assetstatus.setStatus(AssetStatus.Status.Active);
    assetstatus.setPduMapping(PduMapping.MAPPEDBYLABSDB);
    assetstatus.setNetworkMapping(NetworkMapping.MAPPEDBYLABSDB);
    asset1.setStatus(assetstatus);
    Asset asset = new Asset();
    asset.setId("5c778c598ecf859960e2d395");
    asset.setAssetName("w1-eeqa-fas3250-01");
    asset.setAssetNumber(53135);
    asset.setAssetSource("5c74da749662e398e01f665f");
    asset.setCategory(AssetCategory.Server);
    asset.setModel("NetApp");
    asset.setManufacturer("NetApp");
    AssetStatus status = new AssetStatus();
    status.setStatus(AssetStatus.Status.Active);
    asset.setStatus(status);
    servers.add(asset);
    servers.add(asset1);
    List<Asset> assetResult = labsdbService.filterServers(servers);
    TestCase.assertEquals(1, assetResult.size());
    for (Asset asset2 : assetResult) {
        if (asset2.getAssetName().equals("w1-eeqa-fas3250-01")) {
            TestCase.assertEquals("5c778c598ecf859960e2d395", asset2.getId());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Asset(com.vmware.flowgate.common.model.Asset) AssetStatus(com.vmware.flowgate.common.AssetStatus) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Asset

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

the class SyncWiremapDataJobTest method createNetWork.

Asset createNetWork() {
    Asset asset = new Asset();
    asset.setAssetName("w1s04-edge-x450-1");
    asset.setAssetNumber(6443);
    asset.setAssetSource("5c74da749662e398e01f665f");
    asset.setCategory(AssetCategory.Networks);
    asset.setModel("Extreme Networks");
    asset.setManufacturer("Extreme Networks Summit X450a-48t");
    return asset;
}
Also used : Asset(com.vmware.flowgate.common.model.Asset)

Example 10 with Asset

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

the class SyncWiremapDataJobTest method createServer.

Asset createServer() {
    Asset asset = new Asset();
    asset.setId("5c778c598ecf859960e2d395");
    asset.setAssetName("w1-eeqa-fas3250-01");
    asset.setAssetNumber(53135);
    asset.setAssetSource("5c74da749662e398e01f665f");
    asset.setCategory(AssetCategory.Server);
    asset.setModel("NetApp");
    asset.setManufacturer("NetApp");
    return asset;
}
Also used : Asset(com.vmware.flowgate.common.model.Asset)

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