aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-21 12:19:44 -0400
committerJim Hahn <jrh3@att.com>2021-05-21 13:08:54 -0400
commit601a09fd07960d3aadcf972ba7c72dcea9976aef (patch)
tree35d368fc7d8c7dd40e1f76b852ad03bee8780e2e
parentc7d24b07377cb00ce4c0c531c6d3dff25e04dc12 (diff)
Enhance toString methods in factory classes
The factory classes in policy-endpoints have toString() methods that return "[]" for their list contents. Updated the code to provide a list of the keys rather than just an empty list. Also replaced some toString() methods with lombok. Also replace StringBuilder with concatenation in some cases. Issue-ID: POLICY-3298 Change-Id: I64fca21a4b009f7e09fcc482b5d156753fb7e680 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterValidationResult.java24
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java8
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java15
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/JacksonFieldAdapterFactoryTest.java15
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java9
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/JacksonMethodAdapterFactoryTest.java27
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/internal/DataAdapterFactory.java15
-rw-r--r--gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java9
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java17
-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
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java9
-rw-r--r--utils/pom.xml4
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java13
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java9
28 files changed, 89 insertions, 236 deletions
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterValidationResult.java
index b68c62e2..7e56230d 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterValidationResult.java
@@ -157,21 +157,13 @@ public class ParameterValidationResult implements ValidationResult {
return null;
}
- var validationResultBuilder = new StringBuilder();
-
- validationResultBuilder.append(initialIndentation);
- validationResultBuilder.append("field \"");
- validationResultBuilder.append(getName());
- validationResultBuilder.append("\" type \"");
- validationResultBuilder.append(field.getType().getName());
- validationResultBuilder.append("\" value \"");
- validationResultBuilder.append(parameterValue);
- validationResultBuilder.append("\" ");
- validationResultBuilder.append(getStatus());
- validationResultBuilder.append(", ");
- validationResultBuilder.append(message);
- validationResultBuilder.append('\n');
-
- return validationResultBuilder.toString();
+ return initialIndentation
+ + "field \"" + getName()
+ + "\" type \"" + field.getType().getName()
+ + "\" value \"" + parameterValue
+ + "\" " + getStatus()
+ + ", "
+ + message
+ + '\n';
}
}
diff --git a/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java b/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java
index c05a1e51..eee0c149 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.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.
@@ -196,6 +196,7 @@ public class GsonMessageBodyHandlerTest {
}
+ @ToString
public static class MyObject {
private int id;
@@ -206,11 +207,6 @@ public class GsonMessageBodyHandlerTest {
public MyObject(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "MyObject [id=" + id + "]";
- }
}
private static class MyMap {
diff --git a/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java b/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java
index 3d7c29d5..41933bc5 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.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.
@@ -31,6 +31,7 @@ import com.google.gson.JsonElement;
import java.lang.reflect.GenericArrayType;
import java.util.LinkedList;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -102,6 +103,7 @@ public class JacksonExclusionStrategyTest {
/**
* Used to verify that no fields are exposed.
*/
+ @ToString
public static class Data {
private int id;
public String text;
@@ -121,13 +123,9 @@ public class JacksonExclusionStrategyTest {
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
+ @ToString(callSuper = true)
public static class Derived extends Data {
protected String value;
@@ -138,11 +136,6 @@ public class JacksonExclusionStrategyTest {
public void setValue(String value) {
this.value = value;
}
-
- @Override
- public String toString() {
- return "Derived [value=" + value + ", " + super.toString() + "]";
- }
}
/**
diff --git a/gson/src/test/java/org/onap/policy/common/gson/JacksonFieldAdapterFactoryTest.java b/gson/src/test/java/org/onap/policy/common/gson/JacksonFieldAdapterFactoryTest.java
index bbeb1e26..dc62186b 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/JacksonFieldAdapterFactoryTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/JacksonFieldAdapterFactoryTest.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 com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.gson.annotation.GsonJsonProperty;
@@ -137,6 +138,7 @@ public class JacksonFieldAdapterFactoryTest {
return text.replaceFirst("@\\w+", "@");
}
+ @ToString
private static class Data {
@GsonJsonProperty("my-id")
private int id;
@@ -155,21 +157,12 @@ public class JacksonFieldAdapterFactoryTest {
public void setId(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
+ @ToString(callSuper = true)
private static class Derived extends Data {
// not serialized
private String unserialized;
-
- @Override
- public String toString() {
- return "Derived [unserialized=" + unserialized + ", toString()=" + super.toString() + "]";
- }
}
private static class DataList {
diff --git a/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java b/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java
index 18a6fc73..891c4d31 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.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.
@@ -33,6 +33,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.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
@@ -109,6 +110,7 @@ public class JacksonHandlerTest {
/**
* This class includes all policy-specific gson annotations.
*/
+ @ToString
public static class Data {
protected int id;
@@ -147,11 +149,6 @@ public class JacksonHandlerTest {
props.put(name, value);
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", value=" + value + ", props=" + props + "]";
- }
}
private static class MyMap {
diff --git a/gson/src/test/java/org/onap/policy/common/gson/JacksonMethodAdapterFactoryTest.java b/gson/src/test/java/org/onap/policy/common/gson/JacksonMethodAdapterFactoryTest.java
index 6377420d..7afb0e5a 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/JacksonMethodAdapterFactoryTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/JacksonMethodAdapterFactoryTest.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.
@@ -32,6 +32,7 @@ import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
@@ -117,6 +118,7 @@ public class JacksonMethodAdapterFactoryTest {
assertEquals("{'id':500,'nested':{'value':'bye bye'}}".replace('\'', '"'), result);
}
+ @ToString
protected static class Data {
private int id;
private String text;
@@ -142,13 +144,9 @@ public class JacksonMethodAdapterFactoryTest {
public void unused(String text) {
// do nothing
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
+ @ToString(callSuper = true)
protected static class Derived extends Data {
// overrides private field from Data
@@ -174,11 +172,6 @@ public class JacksonMethodAdapterFactoryTest {
map.put(key, value);
}
-
- @Override
- public String toString() {
- return "Derived [text=" + text + ", map=" + map + ", toString()=" + super.toString() + "]";
- }
}
/**
@@ -258,6 +251,7 @@ public class JacksonMethodAdapterFactoryTest {
/**
* Used to test serialization of non-static nested classes.
*/
+ @ToString
protected static class Container {
private int id;
private Nested nested;
@@ -283,12 +277,8 @@ public class JacksonMethodAdapterFactoryTest {
return nested;
}
- @Override
- public String toString() {
- return "Container [id=" + id + ", nested=" + nested + "]";
- }
-
+ @ToString
protected class Nested {
private String value;
@@ -299,11 +289,6 @@ public class JacksonMethodAdapterFactoryTest {
public String getValue() {
return value;
}
-
- @Override
- public String toString() {
- return "Nested [value=" + value + "]";
- }
}
}
}
diff --git a/gson/src/test/java/org/onap/policy/common/gson/internal/DataAdapterFactory.java b/gson/src/test/java/org/onap/policy/common/gson/internal/DataAdapterFactory.java
index 2799d8ba..d2cdf7f8 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/internal/DataAdapterFactory.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/internal/DataAdapterFactory.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.
@@ -35,6 +35,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
/**
* Factory used with test Data.
@@ -54,6 +55,7 @@ public class DataAdapterFactory implements TypeAdapterFactory {
/**
* Object handled by this factory.
*/
+ @ToString
public static class Data {
private int id;
@@ -72,16 +74,12 @@ public class DataAdapterFactory implements TypeAdapterFactory {
public void setId(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + "]";
- }
}
/**
* Object derived from Data.
*/
+ @ToString(callSuper = true)
public static class DerivedData extends Data {
private String text;
@@ -101,11 +99,6 @@ public class DataAdapterFactory implements TypeAdapterFactory {
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "DerivedData [text=" + text + ", toString()=" + super.toString() + "]";
- }
}
/**
diff --git a/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java b/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java
index 6be4e590..5e73d06e 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.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.
@@ -33,6 +33,7 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
@@ -138,6 +139,7 @@ public class JacksonTypeAdapterTest {
assertEquals("read text", data);
}
+ @ToString
private static class Data {
private String id;
private String value;
@@ -155,11 +157,6 @@ public class JacksonTypeAdapterTest {
this.id = id;
this.value = value;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", value=" + value + "]";
- }
}
private abstract static class NamedSer implements Serializer {
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
index fb1df8c7..b1d7d5b4 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -287,16 +287,9 @@ public class StateManagementTest extends IntegrityMonitorTestBase {
return null;
}
- final StringBuilder b = new StringBuilder();
-
- b.append(sm.getAdminState());
- b.append(',');
- b.append(sm.getOpState());
- b.append(',');
- b.append(sm.getAvailStatus());
- b.append(',');
- b.append(sm.getStandbyStatus());
-
- return b.toString();
+ return sm.getAdminState()
+ + ',' + sm.getOpState()
+ + ',' + sm.getAvailStatus()
+ + ',' + sm.getStandbyStatus();
}
}
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 {
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java
index f16764c9..907b7789 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.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.
@@ -34,6 +34,7 @@ import com.google.gson.JsonParseException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import lombok.ToString;
import org.apache.commons.jexl3.JexlException;
import org.junit.Before;
import org.junit.Test;
@@ -225,6 +226,7 @@ public class GsonTestUtilsTest {
assertEquals("[300,{'objE':true,'objEStr':'obj-e-string'},false]".replace('\'', '"'), jsonEl.toString());
}
+ @ToString
public static class Data {
private int id;
private String text;
@@ -244,10 +246,5 @@ public class GsonTestUtilsTest {
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
}
diff --git a/utils/pom.xml b/utils/pom.xml
index 75173a2a..03cc766a 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -122,5 +122,9 @@
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
index 6039e083..7cd09fa8 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
@@ -28,6 +28,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import org.apache.commons.io.IOUtils;
/**
* The Class TextFileUtils is class that provides useful functions for handling text files. Functions to read and write
@@ -36,7 +37,6 @@ import java.nio.file.Files;
* @author Liam Fallon (liam.fallon@est.tech)
*/
public abstract class TextFileUtils {
- private static final int READER_CHAR_BUFFER_SIZE_4096 = 4096;
private TextFileUtils() {
// This class cannot be initialized
@@ -100,15 +100,6 @@ public abstract class TextFileUtils {
* @throws IOException on errors reading text from the file
*/
public static String getReaderAsString(final Reader textReader) throws IOException {
- final var builder = new StringBuilder();
- int charsRead = -1;
- final var chars = new char[READER_CHAR_BUFFER_SIZE_4096];
- do {
- charsRead = textReader.read(chars);
- if (charsRead > 0) {
- builder.append(chars, 0, charsRead);
- }
- } while (charsRead > 0);
- return builder.toString();
+ return IOUtils.toString(textReader);
}
}
diff --git a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java
index a468f0b4..33c7331e 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * 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.
@@ -52,6 +52,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
@@ -358,13 +359,9 @@ public class StandardCoderTest {
}
+ @ToString
private static class MyObject {
private String abc;
-
- @Override
- public String toString() {
- return "MyObject [abc=" + abc + "]";
- }
}
public static class MyMap {