### Question:
MicrometerMetrics extends AbstractMetrics { @Override public Histogram histogram(String name) { return new MicrometerHistogram( metricRegistry.summary( getConfigurationProperties().getMetricNamingStrategy().getMetricName(name), poolNameTag() ) ); } MicrometerMetrics(ConfigurationProperties configurationProperties,
                             MeterRegistry metricRegistry);  MicrometerMetrics(ConfigurationProperties configurationProperties); @Override Histogram histogram(String name); @Override Timer timer(String name); @Override void start(); @Override void stop(); static final MetricsFactory FACTORY; }### Answer:
@Test public void testHistogram() { when(configurationProperties.getMetricNamingStrategy()).thenReturn(new DefaultNamingStrategy()); MicrometerMetrics micrometerMetrics = new MicrometerMetrics(configurationProperties); assertSame(configurationProperties, micrometerMetrics.getConfigurationProperties()); Histogram histogram = micrometerMetrics.histogram("histo"); assertNotNull(histogram); }
@Test public void testHistogramDefaultNamingStrategy() { when(configurationProperties.getMetricNamingStrategy()).thenReturn(new DefaultNamingStrategy()); MicrometerMetrics micrometerMetrics = new MicrometerMetrics(configurationProperties, metricRegistry); Histogram histogram = micrometerMetrics.histogram("histo"); assertNotNull(histogram); verify(metricRegistry).summary(nameCaptor.capture(), tagCaptor.capture()); assertEquals("histo", nameCaptor.getValue()); assertFalse(tagCaptor.getValue().iterator().hasNext()); }
@Test public void testHistogramUniquenameNamingStrategy() { when(configurationProperties.getUniqueName()).thenReturn("uniqueName"); when(configurationProperties.getMetricNamingStrategy()).thenReturn(new UniqueNamingStrategy()); MicrometerMetrics micrometerMetrics = new MicrometerMetrics(configurationProperties, metricRegistry); Histogram histogram = micrometerMetrics.histogram("histo"); assertNotNull(histogram); verify(metricRegistry).summary(nameCaptor.capture(), tagCaptor.capture()); assertEquals("flexypool_histo", nameCaptor.getValue()); Iterator<Tag> tags = tagCaptor.getValue().iterator(); assertTrue(tags.hasNext()); Tag tag = tags.next(); assertEquals("poolname", tag.getKey()); assertEquals("uniqueName", tag.getValue()); assertFalse(tags.hasNext()); }