use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testSavePduAssetAndUpdatePduUsageFormula.
@Test
public void testSavePduAssetAndUpdatePduUsageFormula() {
List<Asset> assets = new ArrayList<>();
Asset asset = createAsset();
asset.setCategory(AssetCategory.PDU);
asset.setId(null);
assets.add(asset);
Mockito.doReturn(new ResponseEntity<Void>(HttpStatus.OK)).when(wormholeAPIClient).saveAssets(Mockito.any(Asset.class));
Mockito.doReturn("23551d6dacf2432c8a3edbc6bbc922cd").when(nlyteDataService).getAssetIdByResponseEntity(Mockito.any(ResponseEntity.class));
nlyteDataService.savePduAssetAndUpdatePduUsageFormula(assets);
}
use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testGenerateNewAsset1.
@Test
public void testGenerateNewAsset1() {
List<NlyteAsset> nlyteAssets = getNlyteAsset();
HashMap<Integer, LocationGroup> locationMap = getLocationMap();
HashMap<Integer, Material> materialMap = getMaterialMap();
HashMap<Integer, Manufacturer> manufacturerMap = getManufacturerMap();
List<Asset> assetsFromFlowgate = new ArrayList<Asset>();
Asset preAsset = new Asset();
preAsset.setAssetNumber(197);
preAsset.setAssetSource("l9i8728d55368540fcba1692");
assetsFromFlowgate.add(preAsset);
Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType("l9i8728d55368540fcba1692", AssetCategory.Server)).thenReturn(assetsFromFlowgate);
HashMap<Integer, String> cabinetIdAndNameMap = new HashMap<Integer, String>();
cabinetIdAndNameMap.put(562, "cbName");
nlyteAssets = nlyteDataService.supplementCabinetName(cabinetIdAndNameMap, nlyteAssets);
List<Asset> assets = nlyteDataService.generateAssets("l9i8728d55368540fcba1692", nlyteAssets, locationMap, manufacturerMap, materialMap, AssetCategory.Server, new HashMap<Long, String>());
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("cbName", asset.getCabinetName());
}
}
}
use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SycnRealTimeDataJobTest method testGetAssetIdfromformular1.
@Test
public void testGetAssetIdfromformular1() {
List<Asset> assets = new ArrayList<Asset>();
Asset asset = createAsset();
assets.add(asset);
Set<String> assetIds = nlyteDataService.getAssetIdfromformular(assets);
TestCase.assertEquals(0, assetIds.size());
}
use of com.vmware.flowgate.common.model.Asset 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");
}
}
}
use of com.vmware.flowgate.common.model.Asset in project flowgate by vmware.
the class SycnRealTimeDataJobTest method createAsset.
Asset createAsset() {
Asset asset = new Asset();
asset.setAssetName("pek-wor-server-02");
asset.setAssetNumber(12345);
asset.setAssetSource("l9i8728d55368540fcba1692");
asset.setCategory(AssetCategory.Server);
asset.setModel("Dell 750");
asset.setManufacturer("Dell");
return asset;
}
Aggregations