### Question:
ApmServerConfigurationSource extends AbstractConfigurationSource implements LifecycleListener { @Nullable String fetchConfig(final ConfigurationRegistry configurationRegistry) { if (!configurationRegistry.getConfig(CoreConfiguration.class).isCentralConfigEnabled()) { logger.debug("Remote configuration is disabled"); return null; } try { return apmServerClient.execute("/config/v1/agents", new ApmServerClient.ConnectionHandler<String>() { @Override public String withConnection(HttpURLConnection connection) throws IOException { return tryFetchConfig(configurationRegistry, connection); } }); } catch (Exception e) { logger.error(e.getMessage()); return null; } } ApmServerConfigurationSource(PayloadSerializer payloadSerializer, MetaData metaData, ApmServerClient apmServerClient);   ApmServerConfigurationSource(PayloadSerializer payloadSerializer, MetaData metaData, ApmServerClient apmServerClient, Logger logger); @Override void reload(); @Override void init(ElasticApmTracer tracer); @Override void start(final ElasticApmTracer tracer); @Override String getValue(String key); @Override String getName(); @Override void pause(); @Override void resume(); @Override void stop();  }### Answer:
@Test public void testNotFound() { mockApmServer.stubFor(post(urlEqualTo("/config/v1/agents")).willReturn(notFound())); assertThat(configurationSource.fetchConfig(config)).isNull(); verify(mockLogger, times(1)).debug(contains("This APM Server does not support central configuration")); }
@Test public void testApmServerCantReachKibana() { mockApmServer.stubFor(post(urlEqualTo("/config/v1/agents")).willReturn(serviceUnavailable())); assertThat(configurationSource.fetchConfig(config)).isNull(); verify(mockLogger, times(1)).error(contains("Remote configuration is not available")); }
@Test public void testApmServerError() { mockApmServer.stubFor(post(urlEqualTo("/config/v1/agents")).willReturn(serverError())); assertThat(configurationSource.fetchConfig(config)).isNull(); verify(mockLogger, times(1)).error(contains("Unexpected status 500 while fetching configuration")); }
@Test public void testApmServerCentralConfigDisabled() { mockApmServer.stubFor(post(urlEqualTo("/config/v1/agents")).willReturn(WireMock.forbidden())); assertThat(configurationSource.fetchConfig(config)).isNull(); verify(mockLogger).debug(contains("Central configuration is disabled")); }