Remove code deprecated in Spring Boot 2.2
Closes gh-22034
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompositeHealthIndicator}
|
||||
*
|
||||
* @author Tyler J. Frederick
|
||||
* @author Phillip Webb
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
@Deprecated
|
||||
class CompositeHealthIndicatorTests {
|
||||
|
||||
private HealthAggregator healthAggregator;
|
||||
|
||||
@Mock
|
||||
private HealthIndicator one;
|
||||
|
||||
@Mock
|
||||
private HealthIndicator two;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
given(this.one.health()).willReturn(new Health.Builder().unknown().withDetail("1", "1").build());
|
||||
given(this.two.health()).willReturn(new Health.Builder().unknown().withDetail("2", "2").build());
|
||||
|
||||
this.healthAggregator = new OrderedHealthAggregator();
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWithIndicators() {
|
||||
Map<String, HealthIndicator> indicators = new HashMap<>();
|
||||
indicators.put("one", this.one);
|
||||
indicators.put("two", this.two);
|
||||
CompositeHealthIndicator composite = new CompositeHealthIndicator(this.healthAggregator, indicators);
|
||||
Health result = composite.health();
|
||||
assertThat(result.getDetails()).hasSize(2);
|
||||
assertThat(result.getDetails()).containsEntry("one",
|
||||
new Health.Builder().unknown().withDetail("1", "1").build());
|
||||
assertThat(result.getDetails()).containsEntry("two",
|
||||
new Health.Builder().unknown().withDetail("2", "2").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerialization() throws Exception {
|
||||
Map<String, HealthIndicator> indicators = new LinkedHashMap<>();
|
||||
indicators.put("db1", this.one);
|
||||
indicators.put("db2", this.two);
|
||||
CompositeHealthIndicator innerComposite = new CompositeHealthIndicator(this.healthAggregator, indicators);
|
||||
CompositeHealthIndicator composite = new CompositeHealthIndicator(this.healthAggregator,
|
||||
Collections.singletonMap("db", innerComposite));
|
||||
Health result = composite.health();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
assertThat(mapper.writeValueAsString(result))
|
||||
.isEqualTo("{\"status\":\"UNKNOWN\",\"details\":{\"db\":{\"status\":\"UNKNOWN\""
|
||||
+ ",\"details\":{\"db1\":{\"status\":\"UNKNOWN\",\"details\""
|
||||
+ ":{\"1\":\"1\"}},\"db2\":{\"status\":\"UNKNOWN\",\"details\":{\"2\":\"2\"}}}}}}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompositeReactiveHealthIndicator}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class CompositeReactiveHealthIndicatorTests {
|
||||
|
||||
private static final Health UNKNOWN_HEALTH = Health.unknown().withDetail("detail", "value").build();
|
||||
|
||||
private static final Health HEALTHY = Health.up().build();
|
||||
|
||||
private OrderedHealthAggregator healthAggregator = new OrderedHealthAggregator();
|
||||
|
||||
@Test
|
||||
void singleIndicator() {
|
||||
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(this.healthAggregator,
|
||||
new DefaultReactiveHealthIndicatorRegistry(Collections.singletonMap("test", () -> Mono.just(HEALTHY))));
|
||||
StepVerifier.create(indicator.health()).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(h.getDetails()).containsOnlyKeys("test");
|
||||
assertThat(h.getDetails().get("test")).isEqualTo(HEALTHY);
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
void longHealth() {
|
||||
Map<String, ReactiveHealthIndicator> indicators = new HashMap<>();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
indicators.put("test" + i, new TimeoutHealth(10000, Status.UP));
|
||||
}
|
||||
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(this.healthAggregator,
|
||||
new DefaultReactiveHealthIndicatorRegistry(indicators));
|
||||
StepVerifier.withVirtualTime(indicator::health).expectSubscription().thenAwait(Duration.ofMillis(10000))
|
||||
.consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(h.getDetails()).hasSize(50);
|
||||
}).verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void timeoutReachedUsesFallback() {
|
||||
Map<String, ReactiveHealthIndicator> indicators = new HashMap<>();
|
||||
indicators.put("slow", new TimeoutHealth(10000, Status.UP));
|
||||
indicators.put("fast", new TimeoutHealth(250, Status.UP));
|
||||
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(this.healthAggregator,
|
||||
new DefaultReactiveHealthIndicatorRegistry(indicators)).timeoutStrategy(1000, UNKNOWN_HEALTH);
|
||||
StepVerifier.create(indicator.health()).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(h.getDetails()).containsOnlyKeys("slow", "fast");
|
||||
assertThat(h.getDetails().get("slow")).isEqualTo(UNKNOWN_HEALTH);
|
||||
assertThat(h.getDetails().get("fast")).isEqualTo(HEALTHY);
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
void timeoutNotReached() {
|
||||
Map<String, ReactiveHealthIndicator> indicators = new HashMap<>();
|
||||
indicators.put("slow", new TimeoutHealth(10000, Status.UP));
|
||||
indicators.put("fast", new TimeoutHealth(10, Status.UP));
|
||||
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(this.healthAggregator,
|
||||
new DefaultReactiveHealthIndicatorRegistry(indicators)).timeoutStrategy(20000, null);
|
||||
StepVerifier.withVirtualTime(indicator::health).expectSubscription().thenAwait(Duration.ofMillis(10000))
|
||||
.consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(h.getDetails()).containsOnlyKeys("slow", "fast");
|
||||
assertThat(h.getDetails().get("slow")).isEqualTo(HEALTHY);
|
||||
assertThat(h.getDetails().get("fast")).isEqualTo(HEALTHY);
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
static class TimeoutHealth implements ReactiveHealthIndicator {
|
||||
|
||||
private final long timeout;
|
||||
|
||||
private final Status status;
|
||||
|
||||
TimeoutHealth(long timeout, Status status) {
|
||||
this.timeout = timeout;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Health> health() {
|
||||
return Mono.delay(Duration.ofMillis(this.timeout)).map((l) -> Health.status(this.status).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultHealthIndicatorRegistry}.
|
||||
*
|
||||
* @author Vedran Pavic
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class DefaultHealthIndicatorRegistryTests {
|
||||
|
||||
private HealthIndicator one = mock(HealthIndicator.class);
|
||||
|
||||
private HealthIndicator two = mock(HealthIndicator.class);
|
||||
|
||||
private DefaultHealthIndicatorRegistry registry;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
given(this.one.health()).willReturn(new Health.Builder().unknown().withDetail("1", "1").build());
|
||||
given(this.two.health()).willReturn(new Health.Builder().unknown().withDetail("2", "2").build());
|
||||
this.registry = new DefaultHealthIndicatorRegistry();
|
||||
}
|
||||
|
||||
@Test
|
||||
void register() {
|
||||
this.registry.register("one", this.one);
|
||||
this.registry.register("two", this.two);
|
||||
assertThat(this.registry.getAll()).hasSize(2);
|
||||
assertThat(this.registry.get("one")).isSameAs(this.one);
|
||||
assertThat(this.registry.get("two")).isSameAs(this.two);
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerAlreadyUsedName() {
|
||||
this.registry.register("one", this.one);
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.registry.register("one", this.two))
|
||||
.withMessageContaining("HealthIndicator with name 'one' already registered");
|
||||
}
|
||||
|
||||
@Test
|
||||
void unregister() {
|
||||
this.registry.register("one", this.one);
|
||||
this.registry.register("two", this.two);
|
||||
assertThat(this.registry.getAll()).hasSize(2);
|
||||
HealthIndicator two = this.registry.unregister("two");
|
||||
assertThat(two).isSameAs(this.two);
|
||||
assertThat(this.registry.getAll()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unregisterUnknown() {
|
||||
this.registry.register("one", this.one);
|
||||
assertThat(this.registry.getAll()).hasSize(1);
|
||||
HealthIndicator two = this.registry.unregister("two");
|
||||
assertThat(two).isNull();
|
||||
assertThat(this.registry.getAll()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllIsASnapshot() {
|
||||
this.registry.register("one", this.one);
|
||||
Map<String, HealthIndicator> snapshot = this.registry.getAll();
|
||||
assertThat(snapshot).containsOnlyKeys("one");
|
||||
this.registry.register("two", this.two);
|
||||
assertThat(snapshot).containsOnlyKeys("one");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllIsImmutable() {
|
||||
this.registry.register("one", this.one);
|
||||
Map<String, HealthIndicator> snapshot = this.registry.getAll();
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(snapshot::clear);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultReactiveHealthIndicatorRegistry}.
|
||||
*
|
||||
* @author Vedran Pavic
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class DefaultReactiveHealthIndicatorRegistryTests {
|
||||
|
||||
private ReactiveHealthIndicator one = mock(ReactiveHealthIndicator.class);
|
||||
|
||||
private ReactiveHealthIndicator two = mock(ReactiveHealthIndicator.class);
|
||||
|
||||
private DefaultReactiveHealthIndicatorRegistry registry;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
given(this.one.health()).willReturn(Mono.just(new Health.Builder().unknown().withDetail("1", "1").build()));
|
||||
given(this.two.health()).willReturn(Mono.just(new Health.Builder().unknown().withDetail("2", "2").build()));
|
||||
this.registry = new DefaultReactiveHealthIndicatorRegistry();
|
||||
}
|
||||
|
||||
@Test
|
||||
void register() {
|
||||
this.registry.register("one", this.one);
|
||||
this.registry.register("two", this.two);
|
||||
assertThat(this.registry.getAll()).hasSize(2);
|
||||
assertThat(this.registry.get("one")).isSameAs(this.one);
|
||||
assertThat(this.registry.get("two")).isSameAs(this.two);
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerAlreadyUsedName() {
|
||||
this.registry.register("one", this.one);
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.registry.register("one", this.two))
|
||||
.withMessageContaining("HealthIndicator with name 'one' already registered");
|
||||
}
|
||||
|
||||
@Test
|
||||
void unregister() {
|
||||
this.registry.register("one", this.one);
|
||||
this.registry.register("two", this.two);
|
||||
assertThat(this.registry.getAll()).hasSize(2);
|
||||
ReactiveHealthIndicator two = this.registry.unregister("two");
|
||||
assertThat(two).isSameAs(this.two);
|
||||
assertThat(this.registry.getAll()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unregisterUnknown() {
|
||||
this.registry.register("one", this.one);
|
||||
assertThat(this.registry.getAll()).hasSize(1);
|
||||
ReactiveHealthIndicator two = this.registry.unregister("two");
|
||||
assertThat(two).isNull();
|
||||
assertThat(this.registry.getAll()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllIsASnapshot() {
|
||||
this.registry.register("one", this.one);
|
||||
Map<String, ReactiveHealthIndicator> snapshot = this.registry.getAll();
|
||||
assertThat(snapshot).containsOnlyKeys("one");
|
||||
this.registry.register("two", this.two);
|
||||
assertThat(snapshot).containsOnlyKeys("one");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllIsImmutable() {
|
||||
this.registry.register("one", this.one);
|
||||
Map<String, ReactiveHealthIndicator> snapshot = this.registry.getAll();
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(snapshot::clear);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class HealthIndicatorReactiveAdapterTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link OrderedHealthAggregator}.
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
@Deprecated
|
||||
class OrderedHealthAggregatorTests {
|
||||
|
||||
private OrderedHealthAggregator healthAggregator;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
this.healthAggregator = new OrderedHealthAggregator();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultOrder() {
|
||||
Map<String, Health> healths = new HashMap<>();
|
||||
healths.put("h1", new Health.Builder().status(Status.DOWN).build());
|
||||
healths.put("h2", new Health.Builder().status(Status.UP).build());
|
||||
healths.put("h3", new Health.Builder().status(Status.UNKNOWN).build());
|
||||
healths.put("h4", new Health.Builder().status(Status.OUT_OF_SERVICE).build());
|
||||
assertThat(this.healthAggregator.aggregate(healths).getStatus()).isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void customOrder() {
|
||||
this.healthAggregator.setStatusOrder(Status.UNKNOWN, Status.UP, Status.OUT_OF_SERVICE, Status.DOWN);
|
||||
Map<String, Health> healths = new HashMap<>();
|
||||
healths.put("h1", new Health.Builder().status(Status.DOWN).build());
|
||||
healths.put("h2", new Health.Builder().status(Status.UP).build());
|
||||
healths.put("h3", new Health.Builder().status(Status.UNKNOWN).build());
|
||||
healths.put("h4", new Health.Builder().status(Status.OUT_OF_SERVICE).build());
|
||||
assertThat(this.healthAggregator.aggregate(healths).getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultOrderWithCustomStatus() {
|
||||
Map<String, Health> healths = new HashMap<>();
|
||||
healths.put("h1", new Health.Builder().status(Status.DOWN).build());
|
||||
healths.put("h2", new Health.Builder().status(Status.UP).build());
|
||||
healths.put("h3", new Health.Builder().status(Status.UNKNOWN).build());
|
||||
healths.put("h4", new Health.Builder().status(Status.OUT_OF_SERVICE).build());
|
||||
healths.put("h5", new Health.Builder().status(new Status("CUSTOM")).build());
|
||||
assertThat(this.healthAggregator.aggregate(healths).getStatus()).isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void customOrderWithCustomStatus() {
|
||||
this.healthAggregator.setStatusOrder(Arrays.asList("DOWN", "OUT_OF_SERVICE", "UP", "UNKNOWN", "CUSTOM"));
|
||||
Map<String, Health> healths = new HashMap<>();
|
||||
healths.put("h1", new Health.Builder().status(Status.DOWN).build());
|
||||
healths.put("h2", new Health.Builder().status(Status.UP).build());
|
||||
healths.put("h3", new Health.Builder().status(Status.UNKNOWN).build());
|
||||
healths.put("h4", new Health.Builder().status(Status.OUT_OF_SERVICE).build());
|
||||
healths.put("h5", new Health.Builder().status(new Status("CUSTOM")).build());
|
||||
assertThat(this.healthAggregator.aggregate(healths).getStatus()).isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,7 +39,6 @@ class ReactiveHealthContributorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void adaptWhenHealthIndicatorReturnsHealthIndicatorReactiveAdapter() {
|
||||
HealthIndicator indicator = () -> Health.outOfService().build();
|
||||
ReactiveHealthContributor adapted = ReactiveHealthContributor.adapt(indicator);
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ReactiveHealthIndicatorRegistryFactory}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class ReactiveHealthIndicatorRegistryFactoryTests {
|
||||
|
||||
private static final Health UP = new Health.Builder().status(Status.UP).build();
|
||||
|
||||
private static final Health DOWN = new Health.Builder().status(Status.DOWN).build();
|
||||
|
||||
private final ReactiveHealthIndicatorRegistryFactory factory = new ReactiveHealthIndicatorRegistryFactory();
|
||||
|
||||
@Test
|
||||
void defaultHealthIndicatorNameFactory() {
|
||||
ReactiveHealthIndicatorRegistry registry = this.factory.createReactiveHealthIndicatorRegistry(
|
||||
Collections.singletonMap("myHealthIndicator", () -> Mono.just(UP)), null);
|
||||
assertThat(registry.getAll()).containsOnlyKeys("my");
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthIndicatorIsAdapted() {
|
||||
ReactiveHealthIndicatorRegistry registry = this.factory.createReactiveHealthIndicatorRegistry(
|
||||
Collections.singletonMap("test", () -> Mono.just(UP)), Collections.singletonMap("regular", () -> DOWN));
|
||||
assertThat(registry.getAll()).containsOnlyKeys("test", "regular");
|
||||
StepVerifier.create(registry.get("regular").health()).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(h.getDetails()).isEmpty();
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user