### Question:
DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public List<DebugCounterInfo> getCounterHierarchy(String moduleName, String counterHierarchy) { RetCtrInfo rci = getCounterId(moduleName, counterHierarchy); if (!rci.allLevelsFound) { String missing = rci.levels[rci.foundUptoLevel]; log.error("Cannot fetch counter - counter not found {}", missing); return Collections.emptyList(); } ArrayList<DebugCounterInfo> dcilist = new ArrayList<DebugCounterInfo>(); DebugCounterInfo dc = allCounters[rci.ctrIds[rci.foundUptoLevel-1]]; dcilist.add(dc); ArrayList<Integer> belowIds = getHierarchyBelow(moduleName, rci); for (int index : belowIds) { dcilist.add(allCounters[index]); } return dcilist; }  @Override IDebugCounter registerCounter(String moduleName, String counterHierarchy,
                           String counterDescription, CounterType counterType,
                           String... metaData); @Override void flushCounters(); @Override void resetCounterHierarchy(String moduleName, String counterHierarchy); @Override void resetAllCounters(); @Override void resetAllModuleCounters(String moduleName); @Override void enableCtrOnDemand(String moduleName, String counterHierarchy); @Override void disableCtrOnDemand(String moduleName, String counterHierarchy); @Override List<DebugCounterInfo> getCounterHierarchy(String moduleName,
                                                     String counterHierarchy); @Override List<DebugCounterInfo> getAllCounterValues(); @Override List<DebugCounterInfo> getModuleCounterValues(String moduleName); @Override boolean containsModuleCounterHierarchy(String moduleName,
                                                 String counterHierarchy); @Override boolean containsModuleName(String moduleName); @Override List<String> getModuleList(); @Override List<String> getModuleCounterList(String moduleName); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context);  }### Answer:
@Test public void testBasicCounterGet() { testCounterHierarchy(); dclist = dc.getCounterHierarchy("switch", "02"); verifyCounters(dclist, 2L); dclist = dc.getCounterHierarchy("linkd", "tunnel"); verifyCounters(dclist, 3L); dclist = dc.getCounterHierarchy("switch", "01/pktin/err"); verifyCounters(dclist, 105L); dclist = dc.getCounterHierarchy("switch", "01/pktin/drops"); verifyCounters(dclist, 100L); }
@Test public void testMetadata() { testCounterHierarchy(); dclist = dc.getCounterHierarchy("switch", "01/pktin/err"); for (DebugCounterInfo dc : dclist) { assertTrue(dc.cinfo.metaData[0].equals("error")); assertTrue(dc.cinfo.metaData[1].equals("snmp")); log.info("metadata: {}", Arrays.toString(dc.cinfo.getMetaData())); } verifyCounters(dclist, 105L); dclist = dc.getCounterHierarchy("switch", "02"); for (DebugCounterInfo dc : dclist) { assertTrue(dc.cinfo.getMetaData().length == 0); log.info("metadata: {}", Arrays.toString(dc.cinfo.getMetaData())); } }