summaryrefslogtreecommitdiffstats
path: root/utils/src/test/java/org/onap
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 /utils/src/test/java/org/onap
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 'utils/src/test/java/org/onap')
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/coder/PropertyCoderTest.java7
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java3
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java3
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java3
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java9
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java5
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/resources/TextFileUtilsTest.java2
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/validation/VersionTest.java24
8 files changed, 25 insertions, 31 deletions
diff --git a/utils/src/test/java/org/onap/policy/common/utils/coder/PropertyCoderTest.java b/utils/src/test/java/org/onap/policy/common/utils/coder/PropertyCoderTest.java
index 83017e70..47453dfc 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/coder/PropertyCoderTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/coder/PropertyCoderTest.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.
@@ -23,13 +23,10 @@ package org.onap.policy.common.utils.coder;
import static org.junit.Assert.assertEquals;
import com.google.gson.annotations.SerializedName;
-
import java.io.Reader;
import java.io.StringReader;
import java.util.List;
-
import lombok.Getter;
-
import org.junit.Before;
import org.junit.Test;
@@ -102,4 +99,4 @@ public class PropertyCoderTest {
private String port;
private String pass;
}
-} \ No newline at end of file
+}
diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java
index 589d0924..b8730a65 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Common Utils
* ================================================================================
- * 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.
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import javax.persistence.EntityManager;
-
import org.junit.Before;
import org.junit.Test;
diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java
index ca2b7220..3981e2af 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Common Utils
* ================================================================================
- * 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.
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import javax.persistence.EntityManagerFactory;
-
import org.junit.Before;
import org.junit.Test;
diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java
index d764e9d0..3b6e4955 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Common Utils
* ================================================================================
- * 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.
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.persistence.EntityTransaction;
-
import org.junit.Before;
import org.junit.Test;
diff --git a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java
index a0b8353d..4ae72842 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-utils
* ================================================================================
- * 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.
@@ -22,6 +22,7 @@ package org.onap.policy.common.utils.network;
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.assertTrue;
@@ -67,7 +68,7 @@ public class NetworkUtilTest {
public void testAllocPort_testAllocPortString__testAllocPortInetSocketAddress() throws Exception {
// allocate wild-card port
int wildCardPort = NetworkUtil.allocPort();
- assertTrue(wildCardPort != 0);
+ assertNotEquals(0, wildCardPort);
// verify that we can listen on the port
try (ServerSocket wildSocket = new ServerSocket(wildCardPort)) {
@@ -78,10 +79,10 @@ public class NetworkUtilTest {
// allocate port using host name
int localPort = NetworkUtil.allocPort(LOCALHOST);
- assertTrue(localPort != 0);
+ assertNotEquals(0, localPort);
// the OS should have allocated a new port, even though the first has been closed
- assertTrue(localPort != wildCardPort);
+ assertNotEquals(wildCardPort, localPort);
try (ServerSocket localSocket = new ServerSocket()) {
localSocket.bind(new InetSocketAddress(LOCALHOST, localPort));
diff --git a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java
index af98e300..2e122187 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java
@@ -34,7 +34,6 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -234,10 +233,10 @@ public class ResourceUtilsTest {
assertNotNull(theString);
theString = ResourceUtils.getResourceAsString(tmpEmptyFile.getAbsolutePath());
- assertTrue(theString.equals(""));
+ assertEquals("", theString);
theString = ResourceUtils.getResourceAsString(tmpUsedFile.getAbsolutePath());
- assertTrue(theString.equals("Bluebirds fly over the rainbow"));
+ assertEquals("Bluebirds fly over the rainbow", theString);
theString = ResourceUtils.getResourceAsString(jarFileResource);
assertNotNull(theString);
diff --git a/utils/src/test/java/org/onap/policy/common/utils/resources/TextFileUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/resources/TextFileUtilsTest.java
index 0952b168..67cdab52 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/resources/TextFileUtilsTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/resources/TextFileUtilsTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * 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.
@@ -25,7 +26,6 @@ import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-
import org.junit.Test;
/**
diff --git a/utils/src/test/java/org/onap/policy/common/utils/validation/VersionTest.java b/utils/src/test/java/org/onap/policy/common/utils/validation/VersionTest.java
index 1a45f9e1..4673233e 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/validation/VersionTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/validation/VersionTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * 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");
@@ -22,7 +22,7 @@
package org.onap.policy.common.utils.validation;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -48,7 +48,7 @@ public class VersionTest {
public void testHashCode() {
int hash = vers.hashCode();
int hash2 = new Version(MAJOR, MINOR, PATCH + 1).hashCode();
- assertTrue(hash != hash2);
+ assertNotEquals(hash, hash2);
}
@Test
@@ -72,16 +72,16 @@ public class VersionTest {
@Test
public void testEquals() {
- assertFalse(vers.equals(null));
- assertFalse(vers.equals(new Object()));
+ assertNotEquals(vers, null);
+ assertNotEquals(vers, new Object());
- assertTrue(vers.equals(vers));
+ assertEquals(vers, vers);
- assertTrue(vers.equals(new Version(MAJOR, MINOR, PATCH)));
+ assertEquals(vers, new Version(MAJOR, MINOR, PATCH));
- assertFalse(vers.equals(new Version(MAJOR + 1, MINOR, PATCH)));
- assertFalse(vers.equals(new Version(MAJOR, MINOR + 1, PATCH)));
- assertFalse(vers.equals(new Version(MAJOR, MINOR, PATCH + 1)));
+ assertNotEquals(vers, new Version(MAJOR + 1, MINOR, PATCH));
+ assertNotEquals(vers, new Version(MAJOR, MINOR + 1, PATCH));
+ assertNotEquals(vers, new Version(MAJOR, MINOR, PATCH + 1));
}
@Test
@@ -89,7 +89,7 @@ public class VersionTest {
vers = new Version(101, 201, 301);
// equals case
- assertTrue(new Version(101, 201, 301).compareTo(vers) == 0);
+ assertEquals(0, new Version(101, 201, 301).compareTo(vers));
// major takes precedence
assertTrue(new Version(102, 200, 300).compareTo(vers) > 0);
@@ -139,4 +139,4 @@ public class VersionTest {
public void testVersion() {
assertEquals("0.0.0", new Version().toString());
}
-} \ No newline at end of file
+}