@Test
public void shouldHandleMBeanInstanceNotFoundBeforeAndAfterLoggingDelay() throws Exception {

    // given
    GaugeConfig gaugeConfig = ImmutableGaugeConfig.builder()
            .mbeanObjectName("xyz:aaa=bbb")
            .addMbeanAttributes(ImmutableMBeanAttribute.of("ccc", false))
            .addMbeanAttributes(ImmutableMBeanAttribute.of("ddd", false))
            .build();
    when(clock.currentTimeMillis()).thenReturn(0L).thenReturn(30000L).thenReturn(60000L);
    when(lazyPlatformMBeanServer.getAttribute(any(ObjectName.class), anyString(),
            anyMBeanServerList())).thenThrow(InstanceNotFoundException.class);
    // when
    collectGaugeValues(gaugeConfig);
    collectGaugeValues(gaugeConfig);
    collectGaugeValues(gaugeConfig);
    collectGaugeValues(gaugeConfig);
    collectGaugeValues(gaugeConfig);
    // then
    verify(logger, times(5)).debug(nullable(String.class), any(Exception.class));
    verify(logger)
            .warn("mbean not {}: {} (waited {} seconds after jvm startup before logging this"
                    + " warning to allow time for mbean registration - this wait time can be"
                    + " changed under Configuration > Advanced)", "found", "xyz:aaa=bbb", 60);
}