summaryrefslogtreecommitdiffstats
path: root/model/event-model/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-02-07 17:56:44 +0000
committerliamfallon <liam.fallon@est.tech>2022-02-08 18:39:03 +0000
commit59b90519eda3b95b0cfc49b6349a591c7d0c78e2 (patch)
tree810e07f7d5cf270582264c40245372f597c713a2 /model/event-model/src/test/java
parentdef44b294fa00bb5470e977eef9a05e5087035f0 (diff)
Remove JAXB and XML, use GSON for JSON
This review converst apex-pdp to use GSON for JSON handling. In order to preserve backward compatibility with the JAXB format of JSON, custom handling of maps was required. Therefore, the policy-common StandardCoder could not be used. There are a lot of small changes, removing annotations from concepts and tweaking of test data. However, this cleans up the code base so it is worth doing. Issue-ID: POLICY-1820 Change-Id: I213fa64f6d7f3f1df8d10f111d9fbedbe80f9fe0 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'model/event-model/src/test/java')
-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();
}