### Question:
UsageMetricsHandler implements StartEndHandler { public NormalizerStats getStats(int ignored, List<String> cycles) { return new NormalizerStats(roots, maxDepth, synonyms, ignored, countByOrigin, countByRank, cycles); } UsageMetricsHandler(UsageDao dao); @Override void start(Node n); @Override void end(Node n); NormalizerStats getStats(int ignored, List<String> cycles);  }### Answer:
@Test public void testClassificationHandler() { initDb(); try (Transaction tx = beginTx()) { Node n = addNode(Rank.KINGDOM, "Animalia", null); n.addLabel(Labels.ROOT); n = addNode(Rank.KINGDOM, "Plantae", null); n.addLabel(Labels.ROOT); n = addNode(Rank.PHYLUM, "Pinophyta", n); n = addNode(Rank.CLASS, "Pinalaea", n); n = addNode(Rank.ORDER, "Pinales", n); addNode(Rank.FAMILY, "Araucariaceae", n); n = addNode(Rank.FAMILY, "Pinaceae", n); n = addNode(Rank.SUBFAMILY, "Abiedea", n); addNode(Rank.GENUS, "Pinus", n); n = addNode(Rank.GENUS, "Abies", n); addNode(Rank.SPECIES, "Abies Alpina DC.", n); addNode(Rank.SPECIES, "Abies balkan L.", n); n =addNode(Rank.SPECIES, "Abies alba Mill.", n); addNode(Rank.SUBSPECIES, "Abies alba Mill. subsp. alba", n); addNode(Rank.SUBSPECIES, "Abies alba subsp. alpina Mill.", n); tx.success(); } UsageMetricsHandler handler = new UsageMetricsHandler(dao); TreeWalker.walkAcceptedTree(dao.getNeo(), handler); NormalizerStats stats = handler.getStats(1, Lists.<String>newArrayList()); System.out.println(stats); assertEquals(2, stats.getRoots()); assertEquals(0, stats.getSynonyms()); assertEquals(1, stats.getIgnored()); assertEquals(2, stats.getCountByRank(Rank.KINGDOM)); assertEquals(1, stats.getCountByRank(Rank.PHYLUM)); assertEquals(1, stats.getCountByRank(Rank.CLASS)); assertEquals(1, stats.getCountByRank(Rank.ORDER)); assertEquals(2, stats.getCountByRank(Rank.FAMILY)); assertEquals(1, stats.getCountByRank(Rank.SUBFAMILY)); assertEquals(2, stats.getCountByRank(Rank.GENUS)); assertEquals(3, stats.getCountByRank(Rank.SPECIES)); assertEquals(2, stats.getCountByRank(Rank.SUBSPECIES)); assertEquals(9, stats.getDepth()); LinneanClassificationKeys cl = new NameUsage(); try (Transaction tx = beginTx()) { cl.setKingdomKey(1); assertUsage(1, Rank.KINGDOM, cl); cl.setPhylumKey(2); assertUsage(2, Rank.PHYLUM, cl); cl.setClassKey(3); assertUsage(3, Rank.CLASS, cl); cl.setOrderKey(4); cl.setFamilyKey(6); assertUsage(6, Rank.FAMILY, cl); cl.setGenusKey(9); assertUsage(9, Rank.GENUS, cl); cl.setSpeciesKey(12); assertUsage(12, Rank.SPECIES, cl); assertUsage(13, Rank.SUBSPECIES, cl); assertUsage(14, Rank.SUBSPECIES, cl); } }