summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-10-09 15:22:21 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-10-09 16:54:08 +0200
commit5c51d64a26c09c6d300681751b5e622820888216 (patch)
treecb077ba82dfdeeea10c2cac6a14d86a4300dbba4 /aai-core/src/test
parent51186f010e5aa43da43c56758bc5d761bec155d9 (diff)
Refactor DeltaEvents
- get rid of StoreNotificationEvent class and directly publish to Kafka - use Lombok in related classes Issue-ID: AAI-4014 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: Ic6433b75a4540f597edf1316afe6d6c56a7bd08b
Diffstat (limited to 'aai-core/src/test')
-rw-r--r--aai-core/src/test/java/org/onap/aai/AAISetup.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/DataLinkSetup.java3
-rw-r--r--aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java225
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties2
7 files changed, 6 insertions, 237 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/AAISetup.java b/aai-core/src/test/java/org/onap/aai/AAISetup.java
index f51b5732..5273c6e7 100644
--- a/aai-core/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-core/src/test/java/org/onap/aai/AAISetup.java
@@ -40,8 +40,6 @@ import org.onap.aai.setup.AAIConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
-import org.onap.aai.web.KafkaConfig;
-import org.onap.aai.web.KafkaNotificationEventConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
@@ -55,7 +53,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
classes = {ConfigConfiguration.class, AAIConfigTranslator.class, EdgeIngestor.class, EdgeSerializer.class,
NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class, RestBeanConfig.class,
XmlFormatTransformerConfiguration.class, ValidationService.class, ValidationConfiguration.class,
- KafkaConfig.class, LoaderFactory.class, NotificationService.class, KafkaNotificationEventConfig.class})
+ KafkaConfig.class, LoaderFactory.class, NotificationService.class, KafkaConfig.class})
@TestPropertySource(
properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.translator.list=config",
"schema.nodes.location=src/test/resources/onap/oxm",
diff --git a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java
index b0825162..5ede5c22 100644
--- a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java
+++ b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java
@@ -38,7 +38,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.testutils.TestUtilConfigTranslatorforDataLink;
import org.onap.aai.util.AAIConstants;
-import org.onap.aai.web.KafkaNotificationEventConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.annotation.DirtiesContext;
@@ -50,7 +49,7 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
@ContextConfiguration(
classes = {ConfigConfiguration.class, TestUtilConfigTranslatorforDataLink.class, EdgeIngestor.class,
EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class,
- RestBeanConfig.class, XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, KafkaNotificationEventConfig.class})
+ RestBeanConfig.class, XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, KafkaConfig.class})
@TestPropertySource(
properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.version.api.default = v4",
"schema.version.edge.label.start = v4", "schema.version.depth.start = v3",
diff --git a/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java
index fa52c014..d00fa818 100644
--- a/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java
@@ -75,7 +75,6 @@ import lombok.extern.slf4j.Slf4j;
@EmbeddedKafka(partitions = 1, topics = { "AAI-EVENT" })
@TestPropertySource(
properties = {
- "jms.bind.address=tcp://localhost:61647",
"aai.events.enabled=true",
"spring.kafka.producer.retries=0",
"spring.kafka.producer.properties.sasl.jaas.config=#{null}",
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
index 629243a7..7685360b 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
@@ -42,6 +42,7 @@ import org.junit.*;
import org.junit.runner.RunWith;
import org.onap.aai.config.ConfigConfiguration;
import org.onap.aai.config.IntrospectionConfig;
+import org.onap.aai.config.KafkaConfig;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.config.XmlFormatTransformerConfiguration;
import org.onap.aai.db.props.AAIProperties;
@@ -58,7 +59,6 @@ import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
-import org.onap.aai.web.KafkaNotificationEventConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
@@ -69,7 +69,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(
classes = {ConfigConfiguration.class, QueryTestsConfigTranslator.class, NodeIngestor.class, EdgeIngestor.class,
EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class,
- XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, KafkaNotificationEventConfig.class})
+ XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, KafkaConfig.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@TestPropertySource(
properties = {"schema.translator.list = config", "schema.nodes.location=src/test/resources/onap/oxm",
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java
index bec04ee8..6db9e4fa 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java
@@ -42,6 +42,7 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.onap.aai.config.ConfigConfiguration;
import org.onap.aai.config.IntrospectionConfig;
+import org.onap.aai.config.KafkaConfig;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.config.XmlFormatTransformerConfiguration;
import org.onap.aai.db.props.AAIProperties;
@@ -61,7 +62,6 @@ import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
-import org.onap.aai.web.KafkaNotificationEventConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
@@ -73,7 +73,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
classes = {ConfigConfiguration.class, AAICoreFakeEdgesConfigTranslator.class, NodeIngestor.class,
EdgeIngestor.class, EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class,
XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class,
- KafkaNotificationEventConfig.class})
+ KafkaConfig.class})
@TestPropertySource(
properties = {"schema.translator.list = config", "schema.nodes.location=src/test/resources/onap/oxm",
"schema.edges.location=src/test/resources/onap/dbedgerules","aai.notifications.enabled=false"})
diff --git a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java b/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java
deleted file mode 100644
index 7d3a19d4..00000000
--- a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aai.util;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.io.IOException;
-
-import org.eclipse.persistence.dynamic.DynamicEntity;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.aai.AAISetup;
-import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.Introspector;
-import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.ModelType;
-import org.onap.aai.kafka.AAIKafkaEventJMSProducer;
-
-public class StoreNotificationEventTest extends AAISetup {
-
- private static AAIKafkaEventJMSProducer producer;
- private static StoreNotificationEvent sne;
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @BeforeClass
- public static void setUp() {
- producer = Mockito.mock(AAIKafkaEventJMSProducer.class);
- // sne = new StoreNotificationEvent(producer, "transiationId", "sourceOfTruth");
- }
-
- @Before
- public void setUpBefore() {
- producer = Mockito.mock(AAIKafkaEventJMSProducer.class);
- sne = new StoreNotificationEvent(producer, "transiationId", "sourceOfTruth");
-
- }
-
- @Test(expected = AAIException.class)
- public void testStoreEventNullObj() throws AAIException {
- sne.storeEventAndSendToJms(new EventHeader(), null);
- }
-
- @Test(expected = AAIException.class)
- public void testStoreEventInvalidObjForPojoUtils() throws AAIException {
- sne.storeEventAndSendToJms(new EventHeader(), new Object());
- }
-
- @Test
- public void testStoreEventEmptyEventHeader()
- throws AAIException, JsonGenerationException, JsonMappingException, IOException {
-
- ObjectNode object = mapper.createObjectNode().put("hello", "world");
- String res = sne.storeEventAndSendToJms(new EventHeader(), object);
-
- assertNotNull(res);
- assertTrue(res.contains("\"cambria.partition\" : \"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\""));
- assertTrue(res.contains("\"event-header\""));
- assertTrue(res.contains("\"id\""));
- assertTrue(res.contains("\"timestamp\""));
- assertTrue(res
- .contains("\"source-name\" : \"" + AAIConfig.get("aai.notificationEvent.default.sourceName") + "\""));
- assertTrue(res.contains("\"domain\" : \"" + AAIConfig.get("aai.notificationEvent.default.domain") + "\""));
- assertTrue(res.contains(
- "\"sequence-number\" : \"" + AAIConfig.get("aai.notificationEvent.default.sequenceNumber") + "\""));
- assertTrue(res.contains("\"severity\" : \"" + AAIConfig.get("aai.notificationEvent.default.severity") + "\""));
- assertTrue(
- res.contains("\"event-type\" : \"" + AAIConfig.get("aai.notificationEvent.default.eventType") + "\""));
- assertTrue(res.contains("\"version\" : \"" + AAIConfig.get("aai.notificationEvent.default.version") + "\""));
- assertTrue(res.contains("\"action\" : \"UNK\""));
- assertTrue(res.contains("\"entity-link\" : \"UNK\""));
- assertTrue(res.contains("\"entity\""));
- assertTrue(res.contains("\"hello\""));
- assertTrue(res.contains("\"world\""));
- }
-
- @Test
- public void testStoreEvent() throws AAIException, JsonGenerationException, JsonMappingException, IOException {
- ObjectNode object = mapper.createObjectNode().put("hello", "world");
- EventHeader eh = new EventHeader();
- eh.setId("123");
- eh.setTimestamp("current-time");
- eh.setEntityLink("entity-link");
- eh.setAction("action!");
- eh.setEventType("surprise");
- eh.setDomain("PROD");
- eh.setSourceName("source");
- eh.setSequenceNumber("23");
- eh.setSeverity("ALERT");
- eh.setVersion("v12");
-
- String res = sne.storeEventAndSendToJms(eh, object);
-
- assertNotNull(res);
- assertTrue(res.contains("\"cambria.partition\" : \"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\""));
- assertTrue(res.contains("\"event-header\""));
- assertTrue(res.contains("\"id\" : \"123\""));
- assertTrue(res.contains("\"timestamp\" : \"current-time\""));
- assertTrue(res.contains("\"source-name\" : \"source\""));
- assertTrue(res.contains("\"domain\" : \"PROD\""));
- assertTrue(res.contains("\"sequence-number\" : \"23\""));
- assertTrue(res.contains("\"severity\" : \"ALERT\""));
- assertTrue(res.contains("\"event-type\" : \"surprise\""));
- assertTrue(res.contains("\"version\" : \"v12\""));
- assertTrue(res.contains("\"action\" : \"action!\""));
- assertTrue(res.contains("\"entity-link\" : \"entity-link\""));
- assertTrue(res.contains("\"entity\""));
- assertTrue(res.contains("\"hello\""));
- assertTrue(res.contains("\"world\""));
- }
-
- @Test(expected = AAIException.class)
- public void testStoreDynamicEventNullObj() throws AAIException {
- DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class);
- DynamicJAXBContext notificationJaxbContext =
- nodeIngestor.getContextForVersion(schemaVersions.getEdgeLabelVersion());
- sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, null);
- }
-
- @Test(expected = Exception.class)
- public void testStoreDynamicEventAAIException() throws Exception {
-
- DynamicJAXBContext notificationJaxbContext =
- nodeIngestor.getContextForVersion(schemaVersions.getEdgeLabelVersion());
- DynamicEntity obj = Mockito.mock(DynamicEntity.class);
- DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class);
- sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, obj);
- }
-
- @Test(expected = AAIException.class)
- public void testStoreEventIntrospectorNullObj() throws Exception {
- Loader loader = Mockito.mock(Loader.class);
- sne.storeEventAndSendToJms(loader, null, null);
- }
-
- @Ignore("Stopped working since the model driven story")
- @Test
- public void testStoreEvent1Introspector() throws Exception {
- Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getEdgeLabelVersion());
- Introspector eventHeader = loader.introspectorFromName("notification-event-header");
- eventHeader.setValue("id", "123");
- eventHeader.setValue("timestamp", "current-time");
- eventHeader.setValue("entity-link", "entity-link");
- eventHeader.setValue("action", "action!");
- eventHeader.setValue("event-type", "surprise");
- eventHeader.setValue("domain", "PROD");
- eventHeader.setValue("source-name", "source");
- eventHeader.setValue("sequence-number", "23");
- eventHeader.setValue("severity", "ALERT");
- eventHeader.setValue("version", "v12");
- Introspector obj = loader.introspectorFromName("notification-event");
- String res = sne.storeEventAndSendToJms(loader, eventHeader, obj);
-
- assertNotNull(res);
- assertTrue(res.contains("\"cambria.partition\":\"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\""));
- assertTrue(res.contains("\"event-header\""));
- assertTrue(res.contains("\"id\":\"123\""));
- assertTrue(res.contains("\"timestamp\":\"current-time\""));
- assertTrue(res.contains("\"source-name\":\"source\""));
- assertTrue(res.contains("\"domain\":\"PROD\""));
- assertTrue(res.contains("\"sequence-number\":\"23\""));
- assertTrue(res.contains("\"severity\":\"ALERT\""));
- assertTrue(res.contains("\"event-type\":\"surprise\""));
- assertTrue(res.contains("\"version\":\"v12\""));
- assertTrue(res.contains("\"action\":\"action!\""));
- assertTrue(res.contains("\"entity-link\":\"entity-link\""));
- assertTrue(res.contains("\"notification-event\""));
- }
-
- @Ignore("Stopped working since the model driven story")
- @Test
- public void testStoreEventIntrospectorEmptyEventHeader() throws Exception {
- Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getEdgeLabelVersion());
- Introspector eventHeader = loader.introspectorFromName("notification-event-header");
- Introspector obj = loader.introspectorFromName("notification-event");
-
- String res = sne.storeEventAndSendToJms(loader, eventHeader, obj);
-
- assertNotNull(res);
- assertTrue(res.contains("\"cambria.partition\":\"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\""));
- assertTrue(res.contains("\"event-header\""));
- assertTrue(res.contains("\"id\""));
- assertTrue(res.contains("\"timestamp\""));
- assertTrue(
- res.contains("\"source-name\":\"" + AAIConfig.get("aai.notificationEvent.default.sourceName") + "\""));
- assertTrue(res.contains("\"domain\":\"" + AAIConfig.get("aai.notificationEvent.default.domain") + "\""));
- assertTrue(res.contains(
- "\"sequence-number\":\"" + AAIConfig.get("aai.notificationEvent.default.sequenceNumber") + "\""));
- assertTrue(res.contains("\"severity\":\"" + AAIConfig.get("aai.notificationEvent.default.severity") + "\""));
- assertTrue(res.contains("\"event-type\":\"" + AAIConfig.get("aai.notificationEvent.default.eventType") + "\""));
- assertTrue(res.contains("\"version\":\"" + AAIConfig.get("aai.notificationEvent.default.version") + "\""));
- assertTrue(res.contains("\"action\":\"UNK\""));
- assertTrue(res.contains("\"entity-link\":\"UNK\""));
- assertTrue(res.contains("\"notification-event\""));
- }
-}
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
index c7eaad36..40554216 100644
--- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
@@ -50,8 +50,6 @@ aai.example.int=7748
aai.realtime.clients=RO,SDNC,SO
-aai.jms.enable=false
-
aai.rest.getall.depthparam=someuuid
aaf.valid.issuer.wildcard=aaf wild card issuer|aafWildCardIssuer|OU=another