summaryrefslogtreecommitdiffstats
path: root/utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src')
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java1
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java17
-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
10 files changed, 33 insertions, 41 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java b/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java
index 58e2baf5..2acc67ac 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java
@@ -33,7 +33,6 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java b/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java
index bbd30220..7c5c9cbb 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* utils
* ================================================================================
- * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,18 +24,18 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.ServiceLoader;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class is a template for building a sorted list of service instances,
- * which are discovered and created using 'ServiceLoader'.
+ * which are discovered and created using 'ServiceLoader'.
*/
public class OrderedServiceImpl<T extends OrderedService> {
// logger
- private static Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class);
+ private static Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class);
// sorted list of instances implementing the service
private List<T> implementers = null;
@@ -44,8 +44,7 @@ public class OrderedServiceImpl<T extends OrderedService> {
private ServiceLoader<T> serviceLoader = null;
// use this to ensure that we only use one unique instance of each class
- @SuppressWarnings("rawtypes")
- private static HashMap<Class,OrderedService> classToSingleton = new HashMap<>();
+ private static Map<Class<?>,OrderedService> classToSingleton = new HashMap<>();
/**
* Constructor - create the 'ServiceLoader' instance.
@@ -60,7 +59,7 @@ public class OrderedServiceImpl<T extends OrderedService> {
/**
* Get List of implementers.
- *
+ *
* @return the sorted list of services implementing interface 'T' discovered
* by 'ServiceLoader'.
*/
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
+}