org.springframework.boot.actuate.health.ReactiveHealthIndicator Java Examples

The following examples show how to use org.springframework.boot.actuate.health.ReactiveHealthIndicator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
@Test
void shouldReturnKnownContributor() {
	ReactiveDiscoveryHealthIndicator indicator = mock(
			ReactiveDiscoveryHealthIndicator.class);
	Health health = Health.up().build();
	when(indicator.getName()).thenReturn("known");
	when(indicator.health()).thenReturn(Mono.just(health));

	ReactiveDiscoveryCompositeHealthContributor healthContributor = new ReactiveDiscoveryCompositeHealthContributor(
			singletonList(indicator));

	assertThat(healthContributor.getContributor("known")).isNotNull();
	Iterator<NamedContributor<ReactiveHealthContributor>> iterator = healthContributor
			.iterator();
	assertThat(iterator.hasNext()).isTrue();
	NamedContributor<ReactiveHealthContributor> contributor = iterator.next();
	assertThat(contributor).isNotNull();
	assertThat(contributor.getName()).isEqualTo("known");
	assertThat(contributor.getContributor()).isNotNull();
	assertThat(contributor.getContributor())
			.isInstanceOf(ReactiveHealthIndicator.class);
	ReactiveHealthIndicator healthIndicator = (ReactiveHealthIndicator) contributor
			.getContributor();
	StepVerifier.create(healthIndicator.getHealth(true)).expectNext(health)
			.expectComplete().verify();
}
 
Example #2
Source Project: spring-cloud-commons   Author: spring-cloud   File: ReactiveDiscoveryCompositeHealthContributor.java    License: Apache License 2.0 4 votes vote down vote up
private ReactiveHealthIndicator asHealthIndicator(
		ReactiveDiscoveryHealthIndicator indicator) {
	return (indicator != null) ? indicator::health : null;
}