@Test
	void eurekaClientInitializesClientAsynchronously() {
		when(eurekaInstanceConfigBean.isAsyncClientInitialization()).thenReturn(true);
		EurekaServiceRegistry registry = new EurekaServiceRegistry(eurekaInstanceConfigBean);

		final AtomicBoolean applicationsFetched = new AtomicBoolean();

		CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
		when(eurekaClient.getApplications()).thenAnswer((answer) -> {
			applicationsFetched.set(true);
			return answer;
		});

		ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);

		when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));

		EurekaRegistration registration = EurekaRegistration
			.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())))
			.with(eurekaClient)
			.with(applicationInfoManager)
			.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
			.with(new SimpleObjectProvider<>(null))
			.build();

		registry.register(registration);

		await().atMost(Duration.ofSeconds(5)).pollInterval(Duration.ofMillis(500)).until(applicationsFetched::get);

		verify(eurekaClient).getApplications();
		assertThat(applicationsFetched).isTrue();
	}
@author Spencer Gibb
@author Tim Ysewyn
@author Robert Bleyl
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistryTests.java