From 349b4ae7179173f9261d9a432094cb55dc433820 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Fri, 21 Jul 2023 09:41:01 +0100 Subject: Java 17 Upgrade Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares --- utils-test/pom.xml | 52 +++++----------------- .../policy/common/utils/gson/GsonTestUtils.java | 8 +--- .../common/utils/security/SelfSignedKeyStore.java | 4 +- .../common/utils/gson/GsonTestUtilsTest.java | 1 + 4 files changed, 15 insertions(+), 50 deletions(-) (limited to 'utils-test') diff --git a/utils-test/pom.xml b/utils-test/pom.xml index 8cdcf1cd..acca1d7f 100644 --- a/utils-test/pom.xml +++ b/utils-test/pom.xml @@ -25,7 +25,7 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT utils-test @@ -34,8 +34,7 @@ 2.0.4 - - + true @@ -43,56 +42,20 @@ org.bouncycastle bcpkix-fips - 1.0.5 - - - com.google.re2j - re2j + 1.0.7 org.apache.commons commons-jexl3 3.1 - - org.projectlombok - lombok - provided - - - junit - junit - provided - - - org.assertj - assertj-core - test - - - ch.qos.logback - logback-classic - org.onap.policy.common utils ${project.version} - - org.onap.policy.common - gson - ${project.version} - - - org.mockito - mockito-core - test - - - org.springframework - spring-test - test - + + org.awaitility awaitility @@ -103,5 +66,10 @@ openpojo compile + + junit + junit + compile + diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java index 161e7c5c..4aedf872 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java @@ -31,10 +31,8 @@ import com.google.re2j.Pattern; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map.Entry; import lombok.AccessLevel; @@ -100,7 +98,6 @@ public class GsonTestUtils { * * @param object the object to be encoded * @param expected the expected value - * @throws Exception if the file cannot be read */ public void compareGson(Object object, Class expected) { compareGson(object, new File(expected.getSimpleName() + ".json")); @@ -113,7 +110,6 @@ public class GsonTestUtils { * * @param object the object to be encoded * @param expected the expected value - * @throws Exception if the file cannot be read */ public void compareGson(Object object, File expected) { // file is not required to have a full path - find it via getResource() @@ -173,7 +169,7 @@ public class GsonTestUtils { * @throws IOException if an error occurs */ protected String readFile(File file) throws IOException { - return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + return Files.readString(file.toPath()); } @@ -269,7 +265,7 @@ public class GsonTestUtils { // sort the keys before copying to the new object List> sortedSet = new ArrayList<>(jsonObj.entrySet()); - Collections.sort(sortedSet, (left, right) -> left.getKey().compareTo(right.getKey())); + sortedSet.sort(Entry.comparingByKey()); for (Entry ent : sortedSet) { JsonElement val = ent.getValue(); diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java b/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java index 647ff1ba..0787872c 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java @@ -56,6 +56,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * Keystore, containing a self-signed certificate, valid for one day (see the argument to * the "-valid" flag below). For use in junit tests. */ +@Getter public class SelfSignedKeyStore { public static final String KEYSTORE_PASSWORD = "Pol1cy_0nap"; public static final String PRIVATE_KEY_PASSWORD = KEYSTORE_PASSWORD; @@ -67,7 +68,6 @@ public class SelfSignedKeyStore { */ private static final String KEYSTORE_SAN = "keystore_san.txt"; - @Getter private final String keystoreName; @@ -115,7 +115,7 @@ public class SelfSignedKeyStore { var sanArray = sanString.replace("DNS:", "").replace("\r", "").split("\n"); GeneralName[] nameArray = Arrays.stream(sanArray).map(name -> new GeneralName(GeneralName.dNSName, name)) - .collect(Collectors.toList()).toArray(new GeneralName[0]); + .toList().toArray(new GeneralName[0]); final var names = new GeneralNames(nameArray); try (var ostr = new FileOutputStream(keystoreFile)) { 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 907b7789..9de586d6 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 @@ -34,6 +34,7 @@ import com.google.gson.JsonParseException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import lombok.Getter; import lombok.ToString; import org.apache.commons.jexl3.JexlException; import org.junit.Before; -- cgit 1.2.3-korg