use of com.vmware.flowgate.common.model.Parent in project flowgate by vmware.
the class SyncPduAssetJobTest method testUpdatePduMetricformular.
@Test
public void testUpdatePduMetricformular() throws JsonProcessingException {
List<Asset> assets = new ArrayList<>();
Asset asset = createAsset();
asset.setCabinetUnitPosition(1);
asset.setId("po09imkhdplbvf540fwusy67n");
asset.setCategory(AssetCategory.Sensors);
asset.setSubCategory(AssetSubCategory.Humidity);
Parent parent = new Parent();
parent.setParentId("125");
parent.setType("PDU");
asset.setParent(parent);
assets.add(asset);
Asset temp = createAsset();
temp.setCabinetUnitPosition(2);
temp.setId("qwerxfbsd75sda23plbswgfwusyasn");
temp.setCategory(AssetCategory.Sensors);
temp.setSubCategory(AssetSubCategory.Temperature);
Parent parent1 = new Parent();
parent1.setParentId("125");
parent1.setType("PDU");
temp.setParent(parent);
assets.add(temp);
Map<String, Asset> pduIdAndAssetMap = new HashMap<String, Asset>();
Asset pduAsset = createAsset();
pduIdAndAssetMap.put("125", pduAsset);
Set<Asset> pduNeedTosave = powerIQService.updatePduMetricformular(assets, pduIdAndAssetMap);
TestCase.assertEquals(1, pduNeedTosave.size());
Asset pdu = pduNeedTosave.iterator().next();
TestCase.assertEquals(pduAsset.getAssetName(), pdu.getAssetName());
try {
Map<String, String> formulars = pdu.getMetricsformulars();
Map<String, Map<String, String>> sensorFormulars = mapper.readValue(formulars.get(FlowgateConstant.SENSOR), new TypeReference<Map<String, Map<String, String>>>() {
});
Map<String, String> humidityLocationAndIdMap = sensorFormulars.get(MetricName.PDU_HUMIDITY);
TestCase.assertEquals("po09imkhdplbvf540fwusy67n", humidityLocationAndIdMap.get(FlowgateConstant.RACK_UNIT_PREFIX + "1"));
Map<String, String> tempLocationAndIdMap = sensorFormulars.get(MetricName.PDU_TEMPERATURE);
TestCase.assertEquals("qwerxfbsd75sda23plbswgfwusyasn", tempLocationAndIdMap.get(FlowgateConstant.RACK_UNIT_PREFIX + "2"));
} catch (Exception e) {
TestCase.fail();
}
}
use of com.vmware.flowgate.common.model.Parent in project flowgate by vmware.
the class AssetControllerTest method createAnAssetExample.
@Test
public void createAnAssetExample() throws JsonProcessingException, Exception {
Asset asset = createAsset();
this.mockMvc.perform(post("/v1/assets").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(asset))).andExpect(status().isCreated()).andExpect(header().string("Location", notNullValue())).andDo(document("assets-create-example", requestFields(fieldWithPath("id").description("ID of the asset, created by flowgate"), fieldWithPath("assetNumber").description("A unique number that can identify an asset from third part DCIM/CMDB systems.").type(long.class), fieldWithPath("assetName").description("The name of the asset in the third part DCIM/CMDB systems. Usually it will be a unique identifier of an asset"), fieldWithPath("assetSource").description("From which third part systems does this asset comes from. It will refer to a source collection which contains all the thirdpart systems"), fieldWithPath("category").description("The category of the asset. Can only be one of :Server, PDU, Cabinet, Networks, Sensors, UPS").type(AssetCategory.class), fieldWithPath("subCategory").description("The subcategory of the asset. Only apply to some systems.").type(AssetSubCategory.class).optional(), fieldWithPath("manufacturer").description("The manufacture name"), fieldWithPath("model").description("The model of the asset"), fieldWithPath("serialnumber").description("The SN number of the asset, this number can be used to identify an asset. But only some systems have this number.").optional(), fieldWithPath("tag").description("Some system will use tag to identify an asset. It can be either an number or a string.").type(String.class).optional(), fieldWithPath("assetAddress").description("The access address of the asset").type(AssetAddress.class).optional(), fieldWithPath("region").description("The location region of the asset").optional(), fieldWithPath("country").description("The location country of the asset").optional(), fieldWithPath("city").description("The location city of the asset").optional(), fieldWithPath("building").description("The location building of the asset").optional(), fieldWithPath("floor").description("The location floor of the asset").optional(), fieldWithPath("room").description("The location room of the asset"), fieldWithPath("row").description("The location row of the asset").optional(), fieldWithPath("col").description("The location col of the asset").optional(), fieldWithPath("extraLocation").description("Extra location information. Only valid for some system.").optional(), fieldWithPath("cabinetName").description("The cabinet name where this asset is located. If the asset is cabinet then this filed is empty.").optional(), fieldWithPath("cabinetUnitPosition").description("The cabinet unit number").type(int.class).optional(), fieldWithPath("mountingSide").description("The cabinet unit number").type(MountingSide.class).optional(), fieldWithPath("cabinetAssetNumber").description("The asset number of the cabinet. Will be used to search more detail information about the cabinet.").type(long.class).optional(), fieldWithPath("assetRealtimeDataSpec").description("Only valid for sensor type of asset.").type(AssetRealtimeDataSpec.class).optional(), subsectionWithPath("justificationfields").ignored(), subsectionWithPath("metricsformulars").ignored(), fieldWithPath("lastupdate").ignored(), fieldWithPath("created").ignored(), fieldWithPath("capacity").description("The capacity of asset.").type(int.class).optional(), fieldWithPath("freeCapacity").description("The free capacity of asset.").type(int.class).optional(), subsectionWithPath("parent").description("The parent of asset,it will be null unless the asset's category is Sensors").type(Parent.class).optional(), fieldWithPath("pdus").description("Possible PDUs that this server connected with"), fieldWithPath("switches").description("Physical switchs that this host connected with"), fieldWithPath("tenant").description("Tenant information for the asset").type(Tenant.class).optional(), subsectionWithPath("status").description("This is a collection of states, including the state of the asset, " + "the state of the pdu mapping, and the state of the switch mapping.")))).andReturn().getResponse().getHeader("Location");
assetRepository.deleteById(asset.getId());
}
Aggregations