代码如下:
@Test
public void testMonitorInfo(){
Connection connection = alarmService.conn("121.40.157.200", "deploy", "deploy");
Map<Alarm.AlarmType,Object> map = alarmService.minitorResult(connection);
Double cpuInfo =(Double)map.get(Alarm.AlarmType.CPU);
System.out.println("cpuInfo:"+cpuInfo);
Double memInfo =(Double)map.get(Alarm.AlarmType.MEM);
System.out.println("memInfo:"+memInfo);
Map<String,Double> disInfo = (Map<String,Double>)map.get(Alarm.AlarmType.DISK);
System.out.println("disInfo:" + disInfo);
Assert.assertEquals(1,1);
}
报警告
E:\BriAir\src\test\java\com\hp\briair\AlarmServiceTest.java:43: 警告: [unchecked] 未经检查的转换
Map<String,Double> disInfo = (Map<String,Double>)map.get(Alarm.AlarmType.DISK);
^
需要: Map<String,Double>
找到: Object
1 个警告
从警告代码来看map已经用泛型约束了(Map<String,Double>)map,请问是什么原因导致该警告?
德玛西亚99
相关分类