summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-12-11 09:21:34 +0100
committerFiete Ostkamp <fiete.ostkamp@telekom.de>2024-12-11 08:27:21 +0000
commit5c2e24008d5b093f86aa5dce8db1336d9211d1d2 (patch)
tree9e60f3f5ec3b76a442206b9b9752e6ec5a616a3e /aai-core/src/test
parent498b357833a128211aac0bf6c4325f0b100b72b6 (diff)
Reduce org.json usage in aai-common
- org.json [is slow](https://github.com/fabienrenaud/java-json-benchmark?tab=readme-ov-file#users-model) - Jackson should be consistently used everywhere - only XmlFormatTransformer is left, but that warrants a dedicated change with (likely) further tests since it appears to be quite a critical execution path - remove unused imports - update org.json to a non-vulnerable version Issue-ID: AAI-4085 Change-Id: I84610523447d70a1729348392ffd302d17e9379d Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-core/src/test')
-rw-r--r--aai-core/src/test/java/org/onap/aai/HttpTestUtil.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/IntegrationTest.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/JanusgraphCassandraConfiguration.java3
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java28
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java1
8 files changed, 18 insertions, 20 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
index 62f63ea3..2759ab99 100644
--- a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -21,7 +21,6 @@
package org.onap.aai;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
diff --git a/aai-core/src/test/java/org/onap/aai/IntegrationTest.java b/aai-core/src/test/java/org/onap/aai/IntegrationTest.java
index 9ee5fce5..9398ed37 100644
--- a/aai-core/src/test/java/org/onap/aai/IntegrationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/IntegrationTest.java
@@ -22,7 +22,6 @@ package org.onap.aai;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.aai.config.ConfigConfiguration;
-import org.onap.aai.config.GraphConfig;
import org.onap.aai.config.IntrospectionConfig;
import org.onap.aai.config.KafkaConfig;
import org.onap.aai.config.RestBeanConfig;
@@ -36,7 +35,6 @@ import org.onap.aai.prevalidation.ValidationService;
import org.onap.aai.rest.notification.NotificationService;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.setup.AAIConfigTranslator;
-import org.onap.aai.util.GraphChecker;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
diff --git a/aai-core/src/test/java/org/onap/aai/JanusgraphCassandraConfiguration.java b/aai-core/src/test/java/org/onap/aai/JanusgraphCassandraConfiguration.java
index 08c99170..f9914445 100644
--- a/aai-core/src/test/java/org/onap/aai/JanusgraphCassandraConfiguration.java
+++ b/aai-core/src/test/java/org/onap/aai/JanusgraphCassandraConfiguration.java
@@ -5,9 +5,6 @@ import java.io.FileNotFoundException;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.ex.ConfigurationException;
-import org.janusgraph.core.JanusGraphProperty;
-import org.janusgraph.core.schema.JanusGraphConfiguration;
-import org.onap.aai.dbmap.AAIGraphConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java
index 4982f1d6..b1e22f2b 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java
@@ -23,15 +23,19 @@ package org.onap.aai.introspection;
import java.util.HashSet;
import java.util.Set;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.aai.AAISetup;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
@Ignore("Not a used/flushed out feature")
+// This has been converted from org.json to Jackson,
+// but not in a way that tests are working
public class JSONStrategyTest extends AAISetup {
private JSONStrategy jsonStrategy;
private JSONStrategy jsonStrategyContainer;
@@ -40,21 +44,25 @@ public class JSONStrategyTest extends AAISetup {
@Before
public void setup() {
try {
- JSONObject pserver = new JSONObject();
+
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode pserver = mapper.createObjectNode();
+
pserver.put("hostname", "value1");
pserver.put("numberofCpus", 4);
jsonStrategy = new JSONStrategy(pserver, "pserver-type");
// The values of this object are arrays containing JSONObjects
- JSONArray pservers = new JSONArray();
+ ArrayNode pservers = mapper.createArrayNode();
pservers.add(pserver);
- JSONObject container = new JSONObject();
- container.put("pservers", pservers);
+
+ ObjectNode container = mapper.createObjectNode();
+ container.set("pservers", pservers);
jsonStrategyContainer = new JSONStrategy(container, "pservers-type");
// The values of this object are JSONObjects
- JSONObject complex = new JSONObject();
- complex.put("pserver", pserver);
+ ObjectNode complex = mapper.createObjectNode();
+ complex.set("pserver", pserver);
jsonStrategyComplex = new JSONStrategy(complex, "pservers-type");
} catch (Exception e) {
System.out.println("error during setup: " + e.getMessage());
@@ -96,8 +104,8 @@ public class JSONStrategyTest extends AAISetup {
@Test
public void getJavaClassNameTest() {
- Assert.assertEquals("org.json.simple.JSONObject", jsonStrategy.getJavaClassName());
- Assert.assertEquals("org.json.simple.JSONObject", jsonStrategyContainer.getJavaClassName());
+ Assert.assertEquals("com.fasterxml.jackson.databind.node.ObjectNode", jsonStrategy.getJavaClassName());
+ Assert.assertEquals("com.fasterxml.jackson.databind.node.ObjectNode", jsonStrategyContainer.getJavaClassName());
}
@Test
diff --git a/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java
index 38731288..48c3e60a 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java
@@ -47,7 +47,6 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.domain.notificationEvent.NotificationEvent;
import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader;
-import org.onap.aai.introspection.ModelType;
import org.onap.aai.rest.notification.UEBNotification;
import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
diff --git a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
index 0eafdf1c..50a81767 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
@@ -59,7 +59,6 @@ import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.domain.notificationEvent.NotificationEvent;
import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.ModelType;
import org.onap.aai.rest.notification.UEBNotification;
import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java
index 6b90782c..ba7fcae3 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java
@@ -25,7 +25,6 @@ import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import java.io.UnsupportedEncodingException;
diff --git a/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java b/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java
index 4fd21497..a042d5da 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java
@@ -24,7 +24,6 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;