Monitors { private static MonitorConfig newObjectConfig(Class<?> c, String id, TagList tags) { final MonitorConfig.Builder builder = MonitorConfig.builder(id); final String className = className(c); if (!className.isEmpty()) { builder.withTag("class", className); } if (tags != null) { builder.withTags(tags); } return builder.build(); } private  Monitors(); static Timer newTimer(String name); static Timer newTimer(String name, TaggingContext context); static Timer newTimer(String name, TimeUnit unit); static Timer newTimer(String name, TimeUnit unit, TaggingContext context); static Counter newCounter(String name); static Counter newCounter(String name, TaggingContext context); static CompositeMonitor<?> newObjectMonitor(Object obj); static CompositeMonitor<?> newObjectMonitor(String id, Object obj); static CompositeMonitor<?> newThreadPoolMonitor(String id, ThreadPoolExecutor pool); static CompositeMonitor<?> newCacheMonitor(String id, Cache<?, ?> cache); static void registerObject(Object obj); static void unregisterObject(Object obj); static void unregisterObject(String id, Object obj); static void registerObject(String id, Object obj); static boolean isObjectRegistered(Object obj); static boolean isObjectRegistered(String id, Object obj);  }
@Test public void testNewObjectConfig() throws Exception { ClassWithMonitors obj = new ClassWithMonitors() { }; List<Monitor<?>> monitors = Monitors.newObjectMonitor(obj).getMonitors(); for (Monitor m : monitors) { assertEquals(m.getConfig().getTags().getValue("class"), "MonitorsTest", String.format("%s should have class MonitorsTest", m.getConfig().getName())); } assertEquals(monitors.size(), 8); }