summaryrefslogtreecommitdiffstats
path: root/model/event-model/src/test
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-22 00:37:28 -0500
committerRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-24 14:06:57 -0500
commit632899642b6a1d1489a0b96932c9c38863a53a26 (patch)
treeab9665853aa637ab1d76d7c25523c77835d3ca3e /model/event-model/src/test
parentc719ee941bd4202b617544e351a11a35b20b8a6a (diff)
Add TOSCA policy status header field to APEX event create CLI
In order to expose the processing status of a TOSCA policy to APEX-PDP, a new header field for APEX concept "event" has been introduced to track this within an APEX policy implementation. This field will be leveraged to extract the TOSCA policy execution metrics. Note, that the field is marked as optional for backward compatibility. Unit tests have been augmented to test for the field wherever applicable and the default empty value is retained for the others. "example-grpc" module has been updated to include this field. Exposing the TOSCA policy execution metrics is outside the scope of this patch since the current changes are already very large owing to the atomic nature of the change introduced. Issue-ID: POLICY-3845 Signed-off-by: Rashmi Pujar <rashmi.pujar1@bell.ca> Change-Id: Ief6d70f9abcfc8414e10aa51a27815ee9028e4c8
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.java52
1 files changed, 37 insertions, 15 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 21601d770..111d27f70 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +33,7 @@ import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
@@ -51,7 +53,7 @@ public class EventsTest {
assertNotNull(new AxEvent(new AxArtifactKey(), "namespace"));
assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target"));
assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target"));
- assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target", parameterMap));
+ assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target", parameterMap, ""));
final AxEvent event = new AxEvent();
@@ -72,6 +74,9 @@ public class EventsTest {
event.setParameterMap(parameterMap);
assertEquals(0, event.getParameterMap().size());
+ event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
+ assertEquals(AxToscaPolicyProcessingStatus.ENTRY.name(), event.getToscaPolicyState());
+
final AxField eventField =
new AxField(new AxReferenceKey(eventKey, "Field0"), new AxArtifactKey("Field0Schema", "0.0.1"));
event.getParameterMap().put(eventField.getKey().getLocalName(), eventField);
@@ -178,6 +183,12 @@ public class EventsTest {
result = event.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ event.setToscaPolicyState("invalid_enum");
+ result = new AxValidationResult();
+ result = event.validate(result);
+ assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
+
event.clean();
event.afterUnmarshal(null, null);
@@ -192,25 +203,36 @@ public class EventsTest {
assertEquals(event, clonedEvent);
assertNotNull(event);
assertNotEquals(event, (Object) "Hello");
- assertNotEquals(
- event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty));
- assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap));
+ assertNotEquals(event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
+ 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)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty)));
- assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap)));
+ .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())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotNull(event.getKeys());
@@ -292,4 +314,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