aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-06-17 08:37:15 -0400
committerJim Hahn <jrh3@att.com>2020-06-17 11:45:16 -0400
commit611f63a4bb71d677cf2665b1794e91148ba42a51 (patch)
treec6f82e5ffcd10712e0279c40bf8e59ed49f2332e /policy-endpoints/src/test
parent3bd6679bd7d8f67b4827a610c25ed9671b74d89c (diff)
Cleanup various sonar issues in policy-common
Addressed the following issues: - unused imports - unused method parameters - use assertEquals, assertSame instead of assertTrue - provide the parametrized type for this generic Also fixed some checkstyle issues: - removed blank lines between "import" groups Issue-ID: POLICY-2650 Change-Id: I004bb650ac10c49ccd0fc405f6959896fec39f9b Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java20
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java10
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java14
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java2
8 files changed, 29 insertions, 31 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
index a661b063..e47b2665 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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,7 +31,6 @@ import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
-
import org.junit.After;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java
index b5c9e614..7a819e0d 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -25,6 +25,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX;
@@ -82,7 +84,7 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact
assertNotNull(item2);
assertEquals(item.getTopic(), item.getEffectiveTopic());
assertNotEquals(item2.getTopic(), item2.getEffectiveTopic());
- assertTrue(item != item2);
+ assertNotSame(item, item2);
// duplicate topics, but since they aren't managed, they should be different
T item3 = buildTopic(makeBuilder().managed(false).build());
@@ -91,9 +93,9 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact
assertNotNull(item4);
assertEquals(MY_TOPIC, item4.getTopic());
assertEquals(TOPIC2, item4.getEffectiveTopic());
- assertTrue(item != item3);
- assertTrue(item != item4);
- assertTrue(item3 != item4);
+ assertNotSame(item, item3);
+ assertNotSame(item, item4);
+ assertNotSame(item3, item4);
// two managed topics
T item5 = buildTopic(makeBuilder().build());
@@ -102,8 +104,8 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact
assertNotNull(item6);
// re-build same managed topics - should get exact same objects
- assertTrue(item5 == buildTopic(makeBuilder().topic(MY_TOPIC).build()));
- assertTrue(item6 == buildTopic(makeBuilder().topic(TOPIC2).build()));
+ assertSame(item5, buildTopic(makeBuilder().topic(MY_TOPIC).build()));
+ assertSame(item6, buildTopic(makeBuilder().topic(TOPIC2).build()));
}
/**
@@ -135,11 +137,11 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact
T item2 = buildTopic(servers, TOPIC2);
assertNotNull(item2);
- assertTrue(item1 != item2);
+ assertNotSame(item1, item2);
// duplicate - should be the same, as these topics are managed
T item3 = buildTopic(servers, TOPIC2);
- assertTrue(item2 == item3);
+ assertSame(item2, item3);
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java
index 0974a041..6cdb628a 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Collections;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java
index d8a16428..9795fd30 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
@@ -126,9 +128,9 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas
int index = 0;
T item = lst.get(index++);
- assertTrue(item != lst.get(index++));
- assertTrue(item == lst.get(index++));
- assertTrue(item == lst.get(index++));
+ assertNotSame(item, lst.get(index++));
+ assertSame(item, lst.get(index++));
+ assertSame(item, lst.get(index++));
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index cbe5a5a5..2ff1d56b 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.gson.Gson;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -401,13 +401,13 @@ public class HttpServerTest {
assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port2).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
- assertTrue(HELLO.equals(response));
+ assertEquals(HELLO, response);
response = http(portUrl + SWAGGER_JSON);
- assertTrue(response != null);
+ assertNotNull(response);
response = http(LOCALHOST_PREFIX + port2 + JUNIT_ECHO_HELLO);
- assertTrue(HELLO.equals(response));
+ assertEquals(HELLO, response);
assertThatThrownBy(() -> http(LOCALHOST_PREFIX + port2 + SWAGGER_JSON)).isInstanceOf(IOException.class);
@@ -429,7 +429,7 @@ public class HttpServerTest {
assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
- assertTrue(HELLO.equals(response));
+ assertEquals(HELLO, response);
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
@@ -451,7 +451,7 @@ public class HttpServerTest {
assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
- assertTrue(HELLO.equals(response));
+ assertEquals(HELLO, response);
HttpServletServerFactoryInstance.getServerFactory().destroy();
assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
@@ -472,7 +472,7 @@ public class HttpServerTest {
assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
- assertTrue(HELLO.equals(response));
+ assertEquals(HELLO, response);
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java
index 8c4eea5a..cd922eba 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyJacksonProvider.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,10 +28,8 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-
import lombok.AccessLevel;
import lombok.Setter;
-
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
index 6ada15c5..cafab42f 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019-2020 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,10 @@
package org.onap.policy.common.endpoints.http.server.test;
import java.util.List;
-
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java
index ebab616a..36970d74 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 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.
@@ -27,7 +28,6 @@ import com.openpojo.validation.rule.impl.GetterMustExistRule;
import com.openpojo.validation.rule.impl.SetterMustExistRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-
import org.junit.Test;
import org.onap.policy.common.utils.test.ToStringTester;