diff options
Diffstat (limited to 'feature-healthcheck/src')
4 files changed, 25 insertions, 123 deletions
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java index b7297998..de00df88 100644 --- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java +++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-healthcheck * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,9 @@ package org.onap.policy.drools.healthcheck; import java.util.ArrayList; import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import org.onap.policy.common.capabilities.Startable; /** @@ -32,6 +35,9 @@ public interface HealthCheck extends Startable { /** * Healthcheck Report. */ + @Getter + @Setter + @ToString public static class Report { /** * Named Entity in the report. @@ -57,98 +63,17 @@ public interface HealthCheck extends Startable { * Message from remote entity. */ private String message; - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Report [name="); - builder.append(getName()); - builder.append(", url="); - builder.append(getUrl()); - builder.append(", healthy="); - builder.append(isHealthy()); - builder.append(", code="); - builder.append(getCode()); - builder.append(", message="); - builder.append(getMessage()); - builder.append("]"); - return builder.toString(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public boolean isHealthy() { - return healthy; - } - - public void setHealthy(boolean healthy) { - this.healthy = healthy; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } } /** * Report aggregation. */ + @Getter + @Setter + @ToString public static class Reports { private boolean healthy; private List<Report> details = new ArrayList<>(); - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Reports [healthy="); - builder.append(isHealthy()); - builder.append(", details="); - builder.append(getDetails()); - builder.append("]"); - return builder.toString(); - } - - public boolean isHealthy() { - return healthy; - } - - public void setHealthy(boolean healthy) { - this.healthy = healthy; - } - - public List<Report> getDetails() { - return details; - } - - public void setDetails(List<Report> details) { - this.details = details; - } } /** diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java index 70b241dd..e32d7c10 100644 --- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java +++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckConstants.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-healthcheck * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,16 @@ package org.onap.policy.drools.healthcheck; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; -public class HealthCheckConstants { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class HealthCheckConstants { /** * Healthcheck Monitor. */ @Getter private static final HealthCheck manager = new HealthCheckManager(); - - private HealthCheckConstants() { - // do nothing - } } diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java index 38af2d87..418fe8eb 100644 --- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java +++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckManager.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; import javax.ws.rs.core.Response; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.ToString; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientFactory; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; @@ -40,6 +43,8 @@ import org.slf4j.LoggerFactory; /** * Healthcheck Monitor. */ +@Getter +@ToString public class HealthCheckManager implements HealthCheck { /** @@ -60,6 +65,8 @@ public class HealthCheckManager implements HealthCheck { /** * Healthcheck configuration. */ + @Getter(AccessLevel.NONE) + @ToString.Exclude protected Properties healthCheckProperties = null; /** @@ -171,24 +178,6 @@ public class HealthCheckManager implements HealthCheck { } /** - * Get servers. - * - * @return list of attached Http Servers - */ - public List<HttpServletServer> getServers() { - return this.servers; - } - - /** - * Get clients. - * - * @return list of attached Http Clients - */ - public List<HttpClient> getClients() { - return this.clients; - } - - /** * Gets the body from the response. * * @param response response from which to get the body @@ -220,17 +209,6 @@ public class HealthCheckManager implements HealthCheck { } } - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("HealthCheckMonitor [servers="); - builder.append(servers); - builder.append(", clients="); - builder.append(clients); - builder.append("]"); - return builder.toString(); - } - // the following methods may be overridden by junit tests protected PolicyEngine getEngineManager() { diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java index 4215aa8c..7040f6d3 100644 --- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java +++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -306,7 +306,7 @@ public class HealthCheckTest { @Test public void testHealthCheckMonitor_ToString() { - assertTrue(monitor.toString().startsWith("HealthCheckMonitor [")); + assertTrue(monitor.toString().startsWith("HealthCheckManager(")); } @Test |