### Question:
LogMetricsHandler extends Handler { @Override public void publish(LogRecord record) { if (isLoggable(record)) { Entry<Integer, LongAdder> counter = logCounters.floorEntry(record.getLevel().intValue()); if (counter != null) { counter.getValue().increment(); } else { logCounters.get(Level.TRACE.intValue()).increment(); } } } LogMetricsHandler(NavigableMap<Integer, LongAdder> logCounters); @Override void publish(LogRecord record); @Override void flush(); @Override void close();  }### Answer:
@Test public void equivalentLevelsShouldBeMerged() { handler.publish(new LogRecord(Level.DEBUG, "test")); handler.publish(new LogRecord(Level.FINE, "test")); assertEquals(2, counters.get(Level.DEBUG.intValue()).sum()); }
@Test public void shouldFilterRecords() { handler.setLevel(Level.INFO); handler.publish(new LogRecord(Level.DEBUG, "test")); assertEquals(0, counters.get(Level.DEBUG.intValue()).sum()); }
@Test public void nonStandardLevelShouldBeCountedWithLowerStandardLevel() { handler.publish(new LogRecord(new CustomLevel("IMPORTANT", 950), "test")); assertEquals(1, counters.get(Level.WARN.intValue()).sum()); }
@Test public void anythingBelowTraceShouldBeCountedAsTrace() { handler.publish(new LogRecord(Level.FINEST, "test")); assertEquals(1, counters.get(Level.TRACE.intValue()).sum()); }