### Question:
MicrometerMetrics extends AbstractMetrics { @Override public Timer timer(String name) { return new MicrometerTimer( metricRegistry.timer( 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 testTimer() { when(configurationProperties.getMetricNamingStrategy()).thenReturn(new DefaultNamingStrategy()); MicrometerMetrics micrometerMetrics = new MicrometerMetrics(configurationProperties); Timer timer = micrometerMetrics.timer("timer"); assertNotNull(timer); }
@Test public void testTimerDefaultNamingStrategy() { when(configurationProperties.getMetricNamingStrategy()).thenReturn(new DefaultNamingStrategy()); MicrometerMetrics micrometerMetrics = new MicrometerMetrics(configurationProperties, metricRegistry); Timer timer = micrometerMetrics.timer("timer"); assertNotNull(timer); verify(metricRegistry).timer(nameCaptor.capture(), tagCaptor.capture()); assertEquals("timer", nameCaptor.getValue()); assertFalse(tagCaptor.getValue().iterator().hasNext()); }
@Test public void testTimerUniquenameNamingStrategy() { when(configurationProperties.getUniqueName()).thenReturn("uniqueName"); when(configurationProperties.getMetricNamingStrategy()).thenReturn(new UniqueNamingStrategy()); MicrometerMetrics micrometerMetrics = new MicrometerMetrics(configurationProperties, metricRegistry); Timer timer = micrometerMetrics.timer("timer"); assertNotNull(timer); verify(metricRegistry).timer(nameCaptor.capture(), tagCaptor.capture()); assertEquals("flexypool_timer", 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()); }