summaryrefslogtreecommitdiffstats
path: root/utils-test
diff options
context:
space:
mode:
Diffstat (limited to 'utils-test')
-rw-r--r--utils-test/pom.xml52
-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
4 files changed, 15 insertions, 50 deletions
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 @@
<parent>
<groupId>org.onap.policy.common</groupId>
<artifactId>common-modules</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>utils-test</artifactId>
@@ -34,8 +34,7 @@
<properties>
<powermock.version>2.0.4</powermock.version>
-
- <!-- this whole module is test code -->
+ <!-- this whole module is testing code -->
<sonar.skip>true</sonar.skip>
</properties>
@@ -43,11 +42,7 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-fips</artifactId>
- <version>1.0.5</version>
- </dependency>
- <dependency>
- <groupId>com.google.re2j</groupId>
- <artifactId>re2j</artifactId>
+ <version>1.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -55,44 +50,12 @@
<version>3.1</version>
</dependency>
<dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>gson</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
+
+ <!-- from parent -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
@@ -103,5 +66,10 @@
<artifactId>openpojo</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
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;