Added Tests
This commit is contained in:
+4
@@ -21,6 +21,10 @@ public class CustomStatusCodeMapper implements HttpCodeStatusMapper {
|
||||
return 500;
|
||||
}
|
||||
|
||||
if (status.getCode().equals("WARNING")) {
|
||||
return 500;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.baeldung.health;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -9,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Component
|
||||
@ConditionalOnEnabledHealthIndicator("random")
|
||||
public class RandomHealthIndicator implements HealthIndicator {
|
||||
|
||||
@Override
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.health;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class WarningHealthIndicator implements HealthIndicator {
|
||||
|
||||
@Override
|
||||
public Health health() {
|
||||
return Health.status("WARNING").build();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
management.health.probes.enabled=true
|
||||
management.endpoint.health.show-details=always
|
||||
management.health.random.enabled=false
|
||||
management.endpoint.health.status.http-mapping.down=500
|
||||
management.endpoint.health.status.http-mapping.out_of_service=503
|
||||
management.endpoint.health.status.http-mapping.out_of_service=503
|
||||
management.endpoint.health.status.http-mapping.warning=500
|
||||
Reference in New Issue
Block a user