Search in sources :

Example 16 with HandleAssetUtil

use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.

the class SycnRealTimeDataJobTest method testCompareValueIsNotEqual.

@Test
public void testCompareValueIsNotEqual() {
    String value1 = null;
    String value2 = null;
    HandleAssetUtil util = new HandleAssetUtil();
    TestCase.assertEquals(false, util.valueIsChanged(value1, value2));
}
Also used : HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 17 with HandleAssetUtil

use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil 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)

Example 18 with HandleAssetUtil

use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.

the class SycnRealTimeDataJobTest method testChassisSlotsIsChanged3.

@Test
public void testChassisSlotsIsChanged3() {
    List<FlowgateChassisSlot> oldFlowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
    FlowgateChassisSlot slot = createFlowgateChassisSlot();
    oldFlowgateChassisSlots.add(slot);
    List<FlowgateChassisSlot> newFlowgateChassisSlots = new ArrayList<FlowgateChassisSlot>();
    FlowgateChassisSlot slot1 = createFlowgateChassisSlot();
    slot1.setMountingSide("front");
    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 19 with HandleAssetUtil

use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.

the class SycnRealTimeDataJobTest method testHandleAssets4.

@Test
public void testHandleAssets4() {
    List<Asset> toUpdateAssets = new ArrayList<Asset>();
    Map<Long, Asset> exsitingaAssetMap = new HashMap<Long, Asset>();
    Asset asset = createAsset();
    asset.setAssetNumber(127);
    asset.setTag("tag1");
    toUpdateAssets.add(asset);
    Asset asset2 = createAsset();
    asset2.setAssetNumber(128);
    asset2.setTag("tag2");
    asset2.setCabinetName("cabinet1");
    Tenant tenant = new Tenant();
    tenant.setOwner("admin");
    tenant.setTenant("tenant");
    tenant.setTenantManager("manager");
    asset2.setTenant(tenant);
    asset2.setRoom("room1");
    asset2.setRow("r2");
    asset2.setCol("c2");
    asset2.setMountingSide(MountingSide.Front);
    asset2.setCategory(AssetCategory.Networks);
    Parent parent = new Parent();
    parent.setParentId("ouqwenkja72hoas9034a");
    parent.setType("Chassis");
    asset2.setParent(parent);
    toUpdateAssets.add(asset2);
    Asset oldAsset1 = createAsset();
    oldAsset1.setAssetNumber(127);
    oldAsset1.setTag("oldtag1");
    exsitingaAssetMap.put(oldAsset1.getAssetNumber(), oldAsset1);
    Asset oldAsset2 = createAsset();
    oldAsset2.setAssetNumber(128);
    oldAsset2.setTag("oldtag2");
    exsitingaAssetMap.put(oldAsset2.getAssetNumber(), oldAsset2);
    HandleAssetUtil util = new HandleAssetUtil();
    List<Asset> assets = util.handleAssets(toUpdateAssets, exsitingaAssetMap);
    for (Asset assetTosave : assets) {
        if (assetTosave.getAssetNumber() == 128) {
            TestCase.assertEquals(asset2.getTag(), assetTosave.getTag());
            TestCase.assertEquals(asset2.getRoom(), assetTosave.getRoom());
            TestCase.assertEquals(asset2.getRow(), assetTosave.getRow());
            TestCase.assertEquals(asset2.getCol(), assetTosave.getCol());
            TestCase.assertEquals(asset2.getMountingSide(), assetTosave.getMountingSide());
            TestCase.assertEquals(asset2.getTenant().getOwner(), assetTosave.getTenant().getOwner());
            HashMap<String, String> justfications = assetTosave.getJustificationfields();
            TestCase.assertEquals("ouqwenkja72hoas9034a", assetTosave.getParent().getParentId());
        } else if (assetTosave.getAssetNumber() == 127) {
            TestCase.assertEquals(asset.getTag(), assetTosave.getTag());
        } else {
            TestCase.fail("Invalid assetNumber");
        }
    }
}
Also used : Tenant(com.vmware.flowgate.common.model.Tenant) HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) HashMap(java.util.HashMap) Parent(com.vmware.flowgate.common.model.Parent) ArrayList(java.util.ArrayList) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 20 with HandleAssetUtil

use of com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil in project flowgate by vmware.

the class SycnRealTimeDataJobTest method testHandleAssetsNew.

@Test
public void testHandleAssetsNew() {
    List<Asset> toUpdateAssets = new ArrayList<Asset>();
    Map<Long, Asset> exsitingaAssetMap = new HashMap<Long, Asset>();
    Asset asset = createAsset();
    asset.setAssetNumber(127);
    asset.setTag("tag1");
    asset.setCapacity(8);
    asset.setFreeCapacity(2);
    toUpdateAssets.add(asset);
    HandleAssetUtil util = new HandleAssetUtil();
    List<Asset> assets = util.handleAssets(toUpdateAssets, exsitingaAssetMap);
}
Also used : HandleAssetUtil(com.vmware.flowgate.nlyteworker.scheduler.job.common.HandleAssetUtil) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NlyteAsset(com.vmware.flowgate.nlyteworker.model.NlyteAsset) Asset(com.vmware.flowgate.common.model.Asset) 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