summaryrefslogtreecommitdiffstats
path: root/utils-test/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-07-21 09:41:01 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-09-21 14:29:31 +0100
commit349b4ae7179173f9261d9a432094cb55dc433820 (patch)
tree4c13de684e11e7945ae52e178fd7d685601fff01 /utils-test/src
parentb902de16baecd36652db1208093030cedde813bb (diff)
Java 17 Upgrade
Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'utils-test/src')
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java8
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java4
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java1
3 files changed, 5 insertions, 8 deletions
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<Entry<String, JsonElement>> sortedSet = new ArrayList<>(jsonObj.entrySet());
- Collections.sort(sortedSet, (left, right) -> left.getKey().compareTo(right.getKey()));
+ sortedSet.sort(Entry.comparingByKey());
for (Entry<String, JsonElement> 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;