### Question:
GatherResource { public static Map<String,Double> calcRemainRate(Map<String,Long> remain,Map<String,Long> total){ Map<String,Double> doubleMap = new HashMap<>(); if(remain == null || remain.isEmpty() || total == null || total.isEmpty()){ return doubleMap; } String mount = null; long totalSize = 0L; long remainSize = 0L; double rate = 0.0; for(Map.Entry<String,Long> entry : total.entrySet()){ mount = entry.getKey(); totalSize = entry.getValue(); if(totalSize == 0){ continue; } remainSize = remain.get(mount); rate = (double)remainSize/totalSize; doubleMap.put(mount,rate); } return doubleMap; }  static StateMetaServerModel gatherResource(String dataDir, String ip,Collection<String> mountPoints); static BaseMetaServerModel gatherBase(String serverId, String dataDir,Collection<String> mountPoints); static List<StatServerModel> calcState(Queue<StateMetaServerModel> queue, int pollSize); static StatServerModel calcStatServerModel(final List<StatServerModel> arrays, List<String> snList, long inverTime, String dataPath); static BaseMetaServerModel collectBaseMetaServer(final Collection<BaseMetaServerModel> source); static ResourceModel calcResourceValue(final BaseMetaServerModel cluster, final StatServerModel stat,String serverId,String ip); static Map<String,Double> calcRemainRate(Map<String,Long> remain,Map<String,Long> total); static Map<String,String> matchSnToPatition(Collection<String> snList, Collection<String> mountPoints, String dataDir);  }### Answer:
@Test @SuppressWarnings("all") public void testcalcRemain(){ Map<String,Long> map = new HashMap<>(); Map<String,Long> dmap = new HashMap<>(); String key = "a"; map.put(key,1L); dmap.put(key,2L); System.out.println(GatherResource.calcRemainRate(map,dmap)); }
@Test @SuppressWarnings("all") public void testcalcRemainError01(){ Map<String,Long> map = new HashMap<>(); Map<String,Long> dmap = new HashMap<>(); String key = "a"; map.put(key,1L); dmap.put(key,0L); System.out.println(GatherResource.calcRemainRate(map,dmap)); }
@Test @SuppressWarnings("all") public void testcalcRemainError02(){ Map<String,Long> map = new HashMap<>(); Map<String,Long> dmap = new HashMap<>(); String key = "a"; map.put(key,1L); System.out.println(GatherResource.calcRemainRate(map,dmap)); }