// Path: spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryService.java
// public class CloudFoundryService {
// 
// 	private final CloudFoundryOperations cloudFoundryOperations;
// 
// 	public CloudFoundryService(CloudFoundryOperations cloudFoundryOperations) {
// 		this.cloudFoundryOperations = cloudFoundryOperations;
// 	}
// 
// 	public Flux<Tuple2<ApplicationDetail, InstanceDetail>> getApplicationInstances(String serviceId) {
// 		GetApplicationRequest applicationRequest = GetApplicationRequest.builder().name(serviceId).build();
// 		return this.cloudFoundryOperations.applications().get(applicationRequest).flatMapMany(applicationDetail -> {
// 			Flux<InstanceDetail> ids = Flux.fromStream(applicationDetail.getInstanceDetails().stream())
// 					.filter(id -> id.getState().equalsIgnoreCase("RUNNING"));
// 			Flux<ApplicationDetail> generate = Flux.generate(sink -> sink.next(applicationDetail));
// 			return generate.zipWith(ids);
// 		});
// 	}
// 
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator;
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
import org.springframework.context.annotation.Bean;
				});
	}

	@Test
	public void worksWithoutWebflux() {
		contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.reactive")).run(context -> {
			assertThat(context).doesNotHaveBean(CloudFoundryReactiveHeartbeatSender.class);
			assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class);
			assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class);
		});
	}

	@Test
	public void worksWithoutActuator() {
		contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.boot.actuate")).run(context -> {
			assertThat(context).hasSingleBean(CloudFoundryReactiveHeartbeatSender.class);
			assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class);
			assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class);
		});
	}

	@TestConfiguration
	static class MockedCloudFoundryConfiguration {

		@Bean
		public CloudFoundryOperations mockedOperations() {
			return mock(CloudFoundryOperations.class);
		}

		@Bean
// Path: spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryService.java
// public class CloudFoundryService {
// 
// 	private final CloudFoundryOperations cloudFoundryOperations;
// 
// 	public CloudFoundryService(CloudFoundryOperations cloudFoundryOperations) {
// 		this.cloudFoundryOperations = cloudFoundryOperations;
// 	}
// 
// 	public Flux<Tuple2<ApplicationDetail, InstanceDetail>> getApplicationInstances(String serviceId) {
// 		GetApplicationRequest applicationRequest = GetApplicationRequest.builder().name(serviceId).build();
// 		return this.cloudFoundryOperations.applications().get(applicationRequest).flatMapMany(applicationDetail -> {
// 			Flux<InstanceDetail> ids = Flux.fromStream(applicationDetail.getInstanceDetails().stream())
// 					.filter(id -> id.getState().equalsIgnoreCase("RUNNING"));
// 			Flux<ApplicationDetail> generate = Flux.generate(sink -> sink.next(applicationDetail));
// 			return generate.zipWith(ids);
// 		});
// 	}
// 
// }


// Path: spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/reactive/CloudFoundryReactiveDiscoveryClientConfigurationTests.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator;
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
import org.springframework.context.annotation.Bean;

				});
	}

	@Test
	public void worksWithoutWebflux() {
		contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.reactive")).run(context -> {
			assertThat(context).doesNotHaveBean(CloudFoundryReactiveHeartbeatSender.class);
			assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class);
			assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class);
		});
	}

	@Test
	public void worksWithoutActuator() {
		contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.boot.actuate")).run(context -> {
			assertThat(context).hasSingleBean(CloudFoundryReactiveHeartbeatSender.class);
			assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class);
			assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class);
		});
	}

	@TestConfiguration
	static class MockedCloudFoundryConfiguration {

		@Bean
		public CloudFoundryOperations mockedOperations() {
			return mock(CloudFoundryOperations.class);
		}

		@Bean
		public CloudFoundryService mockedService() {