DefaultObjectNameMapper implements ObjectNameMapper { @Override public ObjectName createObjectName(String domain, Monitor<?> monitor) { ObjectNameBuilder objNameBuilder = ObjectNameBuilder.forDomain(domain); objNameBuilder.addProperty("name", monitor.getConfig().getName()); objNameBuilder.addProperties(monitor.getConfig().getTags()); return objNameBuilder.build(); }  @Override ObjectName createObjectName(String domain, Monitor<?> monitor);  }
@Test public void testStandardMapping() { MonitorConfig config = MonitorConfig.builder("testName").withTag("foo", "bar").build(); ObjectName name = DEFAULT_MAPPER.createObjectName(TEST_DOMAIN, new BasicCounter(config)); assertEquals(name.getDomain(), TEST_DOMAIN); assertEquals(name.getKeyPropertyListString(), String.format("name=testName,foo=bar,%s=COUNTER", DataSourceType.KEY)); }
@Test public void testMultipleTags() throws MalformedObjectNameException { BasicCounter counter = new BasicCounter( MonitorConfig.builder("testName") .withTag("bbb", "foo") .withTag("aaa", "bar") .withTag("zzz", "test") .build()); ObjectName name = DEFAULT_MAPPER.createObjectName(TEST_DOMAIN, counter); assertEquals(name.getDomain(), TEST_DOMAIN); assertEquals(name.getKeyPropertyListString(), String.format("name=testName,aaa=bar,bbb=foo,%s=COUNTER,zzz=test", DataSourceType.KEY)); }