Turn LivenessState and ReadinessState into enums
Prior to this commit, `LivenessState` and `ReadinessState` were immutable classes. This was done in order to have additional behavior and information in those classes. Because the current implementation doesn't need this, this commit turns those classes into simple enums. Additional state and information can be added to the `*StateChangedEvent` classes. See gh-19593
This commit is contained in:
@@ -38,7 +38,7 @@ public class LivenessProbeHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
if (LivenessState.live().equals(this.applicationAvailabilityProvider.getLivenessState())) {
|
||||
if (LivenessState.LIVE.equals(this.applicationAvailabilityProvider.getLivenessState())) {
|
||||
builder.up();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ReadinessProbeHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
if (ReadinessState.ready().equals(this.applicationAvailabilityProvider.getReadinessState())) {
|
||||
if (ReadinessState.READY.equals(this.applicationAvailabilityProvider.getReadinessState())) {
|
||||
builder.up();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -46,13 +46,13 @@ class LivenessProbeHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void livenessIsLive() {
|
||||
when(this.stateProvider.getLivenessState()).thenReturn(LivenessState.live());
|
||||
when(this.stateProvider.getLivenessState()).thenReturn(LivenessState.LIVE);
|
||||
assertThat(this.healthIndicator.health().getStatus()).isEqualTo(Status.UP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void livenessIsBroken() {
|
||||
when(this.stateProvider.getLivenessState()).thenReturn(LivenessState.broken());
|
||||
when(this.stateProvider.getLivenessState()).thenReturn(LivenessState.BROKEN);
|
||||
assertThat(this.healthIndicator.health().getStatus()).isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ class ReadinessProbeHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void readinessIsReady() {
|
||||
when(this.stateProvider.getReadinessState()).thenReturn(ReadinessState.ready());
|
||||
when(this.stateProvider.getReadinessState()).thenReturn(ReadinessState.READY);
|
||||
assertThat(this.healthIndicator.health().getStatus()).isEqualTo(Status.UP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void readinessIsUnready() {
|
||||
when(this.stateProvider.getReadinessState()).thenReturn(ReadinessState.unready());
|
||||
when(this.stateProvider.getReadinessState()).thenReturn(ReadinessState.UNREADY);
|
||||
assertThat(this.healthIndicator.health().getStatus()).isEqualTo(Status.OUT_OF_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user