summaryrefslogtreecommitdiffstats
path: root/model/event-model/src/test
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2022-02-09 19:04:25 +0000
committerGerrit Code Review <gerrit@onap.org>2022-02-09 19:04:25 +0000
commitc9da04cc4ff4b133edd68ceee77f5bb5128d6574 (patch)
tree701523daabcb77f4ded20bd3dfe4c3660bb1fb90 /model/event-model/src/test
parent143d9c2e74ebe962640810140aa028637af88a6c (diff)
parent59b90519eda3b95b0cfc49b6349a591c7d0c78e2 (diff)
Merge "Remove JAXB and XML, use GSON for JSON"
Diffstat (limited to 'model/event-model/src/test')
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java58
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java5
2 files changed, 32 insertions, 31 deletions
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
index 111d27f70..7062fcb3c 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
/**
* Test events.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class EventsTest {
@@ -78,20 +79,20 @@ public class EventsTest {
assertEquals(AxToscaPolicyProcessingStatus.ENTRY.name(), event.getToscaPolicyState());
final AxField eventField =
- new AxField(new AxReferenceKey(eventKey, "Field0"), new AxArtifactKey("Field0Schema", "0.0.1"));
+ new AxField(new AxReferenceKey(eventKey, "Field0"), new AxArtifactKey("Field0Schema", "0.0.1"));
event.getParameterMap().put(eventField.getKey().getLocalName(), eventField);
assertEquals(1, event.getParameterMap().size());
final AxField eventFieldBadParent =
- new AxField(new AxReferenceKey(new AxArtifactKey("OtherEvent", "0.0.01"), "Field0"),
- new AxArtifactKey("Field0Schema", "0.0.1"));
+ new AxField(new AxReferenceKey(new AxArtifactKey("OtherEvent", "0.0.01"), "Field0"),
+ new AxArtifactKey("Field0Schema", "0.0.1"));
final AxArtifactKey newEventKey = new AxArtifactKey("NewEventName", "0.0.1");
event.setKey(newEventKey);
assertEquals("NewEventName:0.0.1", event.getKey().getId());
assertEquals("NewEventName:0.0.1", event.getKeys().get(0).getId());
assertEquals("NewEventName:0.0.1",
- event.getParameterMap().get("Field0").getKey().getParentArtifactKey().getId());
+ event.getParameterMap().get("Field0").getKey().getParentArtifactKey().getId());
event.setKey(eventKey);
assertEquals("EventName:0.0.1", event.getKey().getId());
assertEquals("EventName:0.0.1", event.getKeys().get(0).getId());
@@ -190,11 +191,13 @@ public class EventsTest {
event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
event.clean();
- event.afterUnmarshal(null, null);
+ event.buildReferences();
+ assertNotEquals(AxKey.NULL_KEY_NAME,
+ event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
final AxEvent clonedEvent = new AxEvent(event);
assertEquals("AxEvent:(key=AxArtifactKey:(name=EventName,version=0.0.1),nameSpace=namespace",
- clonedEvent.toString().substring(0, 77));
+ clonedEvent.toString().substring(0, 77));
assertNotEquals(0, event.hashCode());
@@ -202,37 +205,38 @@ public class EventsTest {
assertEquals(event, event); // NOSONAR
assertEquals(event, clonedEvent);
assertNotNull(event);
- assertNotEquals(event, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(event, helloObj);
assertNotEquals(event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertEquals(0, event.compareTo(event));
assertEquals(0, event.compareTo(clonedEvent));
assertNotEquals(0, event.compareTo(new AxArtifactKey()));
assertNotEquals(0, event.compareTo(null));
- assertNotEquals(0, event
- .compareTo(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target",
+ parameterMap, AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotNull(event.getKeys());
@@ -285,17 +289,19 @@ public class EventsTest {
assertEquals(ValidationResult.VALID, result.getValidationResult());
events.clean();
- events.afterUnmarshal(null, null);
+ event.buildReferences();
+ assertNotEquals(AxKey.NULL_KEY_NAME,
+ event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
final AxEvents clonedEvents = new AxEvents(events);
assertEquals("AxEvents:(key=AxArtifactKey:(name=EventsKey,version=0.0.1),e",
- clonedEvents.toString().substring(0, 60));
+ clonedEvents.toString().substring(0, 60));
assertNotEquals(0, events.hashCode());
assertEquals(events, clonedEvents);
assertNotNull(events);
- assertNotEquals(events, (Object) "Hello");
+ assertNotEquals(event, helloObj);
assertNotEquals(events, new AxEvents(new AxArtifactKey()));
assertEquals(0, events.compareTo(events));
@@ -314,4 +320,4 @@ public class EventsTest {
assertEquals(1, events.getAll("EventName", "0.0.1").size());
assertEquals(0, events.getAll("NonExistantEventsName").size());
}
-} \ No newline at end of file
+}
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
index 5f770d1b3..21b97c454 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
@@ -273,11 +273,6 @@ public class ApexEventModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}