aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-24 20:51:53 +0000
committerGerrit Code Review <gerrit@onap.org>2021-05-24 20:51:53 +0000
commit41d130dd1bc967f8163ab2304ed4067254034151 (patch)
tree0f735b08dfff1f8004106a240d4ae1b875c7179e /policy-endpoints
parent57410a85a607f71d4094dae9d9e57dabb7b0b33a (diff)
parent601a09fd07960d3aadcf972ba7c72dcea9976aef (diff)
Merge "Enhance toString methods in factory classes"
Diffstat (limited to 'policy-endpoints')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSinkFactory.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSinkFactory.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java6
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java6
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java31
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java21
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java20
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java9
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java9
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java9
15 files changed, 38 insertions, 113 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSinkFactory.java
index 9d38aac6..dfdadd1a 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSinkFactory.java
@@ -190,7 +190,7 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
@Override
public String toString() {
- return "IndexedDmaapTopicSinkFactory []";
+ return "IndexedDmaapTopicSinkFactory " + dmaapTopicWriters.keySet();
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
index b63fe037..66960b15 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
@@ -208,7 +208,7 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
@Override
public String toString() {
- return "IndexedDmaapTopicSourceFactory []";
+ return "IndexedDmaapTopicSourceFactory " + dmaapTopicSources.keySet();
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSinkFactory.java
index 17446a94..b04fc078 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSinkFactory.java
@@ -196,7 +196,7 @@ class IndexedUebTopicSinkFactory implements UebTopicSinkFactory {
@Override
public String toString() {
- return "IndexedUebTopicSinkFactory []";
+ return "IndexedUebTopicSinkFactory " + uebTopicSinks.keySet();
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
index edaf4736..09500978 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
@@ -211,6 +211,6 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
@Override
public String toString() {
- return "IndexedUebTopicSourceFactory []";
+ return "IndexedUebTopicSourceFactory " + uebTopicSources.keySet();
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java
index ea22af86..f905bd7d 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java
@@ -74,10 +74,8 @@ public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSi
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("InlineUebTopicSink [getTopicCommInfrastructure()=").append(getTopicCommInfrastructure())
- .append(", toString()=").append(super.toString()).append("]");
- return builder.toString();
+ return "InlineUebTopicSink [getTopicCommInfrastructure()=" + getTopicCommInfrastructure() + ", toString()="
+ + super.toString() + "]";
}
@Override
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
index 1c3d89d2..09ce5261 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
@@ -128,12 +128,10 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("SingleThreadedDmaapTopicSource [userName=").append(userName).append(", password=")
- .append((password == null || password.isEmpty()) ? "-" : password.length())
- .append(", getTopicCommInfrastructure()=").append(getTopicCommInfrastructure()).append(", toString()=")
- .append(super.toString()).append("]");
- return builder.toString();
+ return "SingleThreadedDmaapTopicSource [userName=" + userName
+ + ", password=" + (password == null || password.isEmpty() ? "-" : password.length())
+ + ", getTopicCommInfrastructure()=" + getTopicCommInfrastructure()
+ + ", toString()=" + super.toString() + "]";
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java
index 496c38f5..d8703c42 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java
@@ -66,10 +66,8 @@ public class SingleThreadedUebTopicSource extends SingleThreadedBusTopicSource i
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("SingleThreadedUebTopicSource [getTopicCommInfrastructure()=")
- .append(getTopicCommInfrastructure()).append(", toString()=").append(super.toString()).append("]");
- return builder.toString();
+ return "SingleThreadedUebTopicSource [getTopicCommInfrastructure()=" + getTopicCommInfrastructure()
+ + ", toString()=" + super.toString() + "]";
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
index b83bf297..709b1487 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
@@ -38,6 +38,7 @@ import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
@@ -51,6 +52,7 @@ import org.slf4j.LoggerFactory;
/**
* Http Client implementation using a Jersey Client.
*/
+@ToString
public class JerseyClient implements HttpClient {
private static final Pattern COMMA_PAT = Pattern.compile(",");
@@ -310,35 +312,6 @@ public class JerseyClient implements HttpClient {
return baseUrl;
}
- @Override
- public String toString() {
- var builder = new StringBuilder();
- builder.append("JerseyClient [name=");
- builder.append(name);
- builder.append(", https=");
- builder.append(https);
- builder.append(", selfSignedCerts=");
- builder.append(selfSignedCerts);
- builder.append(", hostname=");
- builder.append(hostname);
- builder.append(", port=");
- builder.append(port);
- builder.append(", basePath=");
- builder.append(basePath);
- builder.append(", userName=");
- builder.append(userName);
- builder.append(", password=");
- builder.append(password);
- builder.append(", client=");
- builder.append(client);
- builder.append(", baseUrl=");
- builder.append(baseUrl);
- builder.append(", alive=");
- builder.append(alive);
- builder.append("]");
- return builder.toString();
- }
-
private Builder getBuilder(String path, Map<String, Object> headers) {
var builder = getWebTarget().path(path).request();
for (Entry<String, Object> header : headers.entrySet()) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java
index 32588101..70d45112 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java
@@ -21,8 +21,11 @@
package org.onap.policy.common.endpoints.http.server;
+import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+import java.util.stream.Collectors;
+import lombok.ToString;
import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -34,6 +37,7 @@ import org.onap.policy.common.utils.services.ServiceManagerContainer;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
+@ToString
public class RestServer extends ServiceManagerContainer {
/**
@@ -111,17 +115,7 @@ public class RestServer extends ServiceManagerContainer {
* @return the provider class names
*/
private String getProviderClassNames(Class<?>[] jaxrsProviders) {
- var names = new StringBuilder();
-
- for (Class<?> prov : jaxrsProviders) {
- if (names.length() > 0) {
- names.append(',');
- }
-
- names.append(prov.getName());
- }
-
- return names.toString();
+ return String.join(",", Arrays.stream(jaxrsProviders).map(Class::getName).collect(Collectors.toList()));
}
private String getValue(final String value) {
@@ -131,11 +125,6 @@ public class RestServer extends ServiceManagerContainer {
return value;
}
- @Override
- public String toString() {
- return "RestServer [servers=" + servers + "]";
- }
-
/**
* Factory used to access objects.
*/
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
index afa37a65..467fd864 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
@@ -258,9 +258,9 @@ public class JettyJerseyServer extends JettyServletServer {
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("JettyJerseyServer [Jerseyservlets=").append(servlets).append(", swaggerId=").append(swaggerId)
- .append(", toString()=").append(super.toString()).append("]");
- return builder.toString();
+ return "JettyJerseyServer [Jerseyservlets=" + servlets
+ + ", swaggerId=" + swaggerId
+ + ", toString()=" + super.toString()
+ + "]";
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
index 48dc8119..4afe2c04 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
@@ -24,6 +24,7 @@ package org.onap.policy.common.endpoints.http.server.internal;
import java.util.EnumSet;
import javax.servlet.DispatcherType;
+import lombok.ToString;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
@@ -50,6 +51,7 @@ import org.slf4j.LoggerFactory;
/**
* Http Server implementation using Embedded Jetty.
*/
+@ToString
public abstract class JettyServletServer implements HttpServletServer, Runnable {
/**
@@ -120,6 +122,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
/**
* Start condition.
*/
+ @ToString.Exclude
protected Object startCondition = new Object();
/**
@@ -521,15 +524,4 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
throw new UnsupportedOperationException("addServletResource()" + NOT_SUPPORTED);
}
- @Override
- public String toString() {
- var builder = new StringBuilder();
- builder.append("JettyServer [name=").append(name).append(", host=").append(host).append(", port=").append(port)
- .append(", user=").append(user).append(", password=").append(password != null).append(", contextPath=")
- .append(contextPath).append(", jettyServer=").append(jettyServer).append(", context=")
- .append(this.context).append(", connector=").append(connector).append(", jettyThread=")
- .append(jettyThread).append("]");
- return builder.toString();
- }
-
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java
index 2caa9221..c214c91f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java
@@ -21,11 +21,14 @@
package org.onap.policy.common.endpoints.report;
+import lombok.ToString;
+
/**
* Class to represent health check report of a service.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
+@ToString
public class HealthCheckReport {
private String name;
@@ -123,21 +126,4 @@ public class HealthCheckReport {
public void setMessage(final String message) {
this.message = message;
}
-
- @Override
- public String toString() {
- final var 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();
- }
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java
index 2a3e244d..2748fadd 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.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.
@@ -21,12 +21,14 @@
package org.onap.policy.common.endpoints.http.server.test;
import com.google.gson.annotations.SerializedName;
+import lombok.ToString;
import org.onap.policy.common.gson.annotation.GsonJsonProperty;
/**
* "ECHO" request and response supporting serialization and de-serialization via
* both jackson and gson.
*/
+@ToString
public class RestEchoReqResp {
@GsonJsonProperty("reqId")
@SerializedName("reqId")
@@ -51,9 +53,4 @@ public class RestEchoReqResp {
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "RestEchoReqResp [requestId=" + requestId + ", text=" + text + "]";
- }
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java
index 7ca131ec..8d65bbd6 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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.
@@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.MediaType;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.YamlJacksonHandler;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
@@ -106,6 +107,7 @@ public class YamlJacksonHandlerTest {
/**
* This class includes all policy-specific gson annotations.
*/
+ @ToString
public static class Data {
protected int id;
@@ -144,11 +146,6 @@ public class YamlJacksonHandlerTest {
props.put(name, value);
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", value=" + value + ", props=" + props + "]";
- }
}
private static class MyMap {
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java
index 4f2eb316..c0927aa9 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.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.
@@ -33,6 +33,7 @@ import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.core.MediaType;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
@@ -212,6 +213,7 @@ public class YamlMessageBodyHandlerTest {
}
}
+ @ToString
public static class MyObject {
private int id;
@@ -222,11 +224,6 @@ public class YamlMessageBodyHandlerTest {
public MyObject(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "MyObject [id=" + id + "]";
- }
}
private static class MyMap {