use of fish.payara.microprofile.metrics.impl.TimerImpl in project Payara by payara.
the class MetricRegistryImplTest method registerByMetadataAllowsToRegisterMetricsOfSameNameWithDifferentTagsButSameType.
@Test
public void registerByMetadataAllowsToRegisterMetricsOfSameNameWithDifferentTagsButSameType() {
String name = nextName();
Tag ab = new Tag("a", "b");
Tag ac = new Tag("a", "c");
MetricID metricAb = new MetricID(name, ab);
MetricID metricAc = new MetricID(name, ac);
registry.register(withName(name), new TimerImpl(), ab);
registry.register(withName(name), new TimerImpl(), ac);
assertEquals(2, registry.getTimers().size());
Map<MetricID, Metric> metrics = registry.getMetrics((metricID, metric) -> metricID.getName().equals(name));
assertEquals(2, metrics.size());
assertTrue(metrics.containsKey(metricAb));
assertTrue(metrics.containsKey(metricAc));
assertEquals(new TreeSet<>(asList(metricAb, metricAc)), registry.getMetricIDs());
assertEquals(new TreeSet<>(asList(name)), registry.getNames());
assertEquals(1, registry.getTimers((id, metric) -> id.equals(metricAc)).size());
}