summaryrefslogtreecommitdiffstats
path: root/model/policy-model
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2021-06-22 15:55:46 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2021-06-28 10:36:48 +0100
commit926646d8e5e86e680a119360f93d7bdb46c89435 (patch)
tree7ff431e59672b19f658faed87c80b4d147253c9c /model/policy-model
parent63637d939697451d3ac63216d938780a157ff895 (diff)
Changes to support multiple outputs from a state
This review addresses two main changes: 1) inputFields and outputFields are not tied to task definition anymore. Instead inputEvent and outputEvents associated to a task is populated as part of the policy state definition, as the state definition have the information anyway. - Clean up of the usage of inputFields and outputFields in task definition will happen in a future review - inputFields and outputFields defined in task definition in policies until honolulu will not make the policy invalid as the changes are done in backward compatible way. 2) Multiple output events can come out of a final state now. - Define another policy state output with the relevant eventName in the command file - In the task logic, create a map to store the fields of the relevant outputEvent, and then just call "executor.addFieldsToOutput(<the_map_of_fields>)" These 2 steps are enough to send multiple events to relevant components as per the apex configuration. Change-Id: Id88ca402704106404f529e595e1a76f6bf167876 Issue-ID: POLICY-3336 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'model/policy-model')
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java9
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java80
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java180
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java3
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java3
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java9
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java46
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java20
8 files changed, 92 insertions, 258 deletions
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
index d55fbd329..4ee176d97 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -502,9 +503,9 @@ public class AxPolicyModel extends AxModel {
}
for (final AxStateOutput stateOutput : state.getStateOutputs().values()) {
- if (events.getEventMap().get(stateOutput.getOutgingEvent()) == null) {
+ if (events.getEventMap().get(stateOutput.getOutgoingEvent()) == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
- ValidationResult.INVALID, "output event " + stateOutput.getOutgingEvent().getId()
+ ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
+ " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
}
@@ -555,10 +556,10 @@ public class AxPolicyModel extends AxModel {
ValidationResult.INVALID, "state output on task reference for task " + task.getId() + " is null"));
} else {
- final AxEvent usedEvent = events.getEventMap().get(stateOutput.getOutgingEvent());
+ final AxEvent usedEvent = events.getEventMap().get(stateOutput.getOutgoingEvent());
if (usedEvent == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
- ValidationResult.INVALID, "output event " + stateOutput.getOutgingEvent().getId()
+ ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
+ " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
index 27c187356..1337e2417 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -23,17 +24,24 @@
package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
+import java.util.Set;
import javax.persistence.AttributeOverride;
+import javax.persistence.CollectionTable;
import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -68,13 +76,15 @@ import org.onap.policy.common.utils.validation.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexStateOutput", namespace = "http://www.onap.org/policy/apex-pdp")
@XmlType(name = "AxStateOutput", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "outgoingEvent", "nextState"})
-
+ propOrder = {"key", "outgoingEvent", "outgoingEventSet", "nextState"})
+@Getter
+@Setter
public class AxStateOutput extends AxConcept {
private static final long serialVersionUID = 8041771382337655535L;
@EmbeddedId
@XmlElement(name = "key", required = true)
+ @NonNull
private AxReferenceKey key;
// @formatter:off
@@ -83,8 +93,17 @@ public class AxStateOutput extends AxConcept {
@AttributeOverride(name = "version", column = @Column(name = "outgoingEventVersion"))
@Column(name = "outgoingEvent")
@XmlElement(required = true)
+ @NonNull
private AxArtifactKey outgoingEvent;
+ @ElementCollection
+ @CollectionTable(joinColumns = {@JoinColumn(name = "stateParentKeyName", referencedColumnName = "parentKeyName"),
+ @JoinColumn(name = "stateParentKeyVersion", referencedColumnName = "parentKeyVersion"),
+ @JoinColumn(name = "stateParentLocalName", referencedColumnName = "parentLocalName"),
+ @JoinColumn(name = "stateLocalName", referencedColumnName = "localName")})
+ @XmlElement(name = "outgoingEventReference", required = false)
+ private Set<AxArtifactKey> outgoingEventSet;
+
@Embedded
@AttributeOverride(name = "parentKeyName", column = @Column(name = "nextStateParentKeyName"))
@AttributeOverride(name = "parentKeyVersion", column = @Column(name = "nextStateParentKeyVersion"))
@@ -92,6 +111,7 @@ public class AxStateOutput extends AxConcept {
@AttributeOverride(name = "localName", column = @Column(name = "nextStateLocalName"))
@Column(name = "nextState")
@XmlElement(required = true)
+ @NonNull
private AxReferenceKey nextState;
// @formatter:on
@@ -164,14 +184,6 @@ public class AxStateOutput extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public AxReferenceKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
keyList.add(new AxKeyUse(outgoingEvent));
@@ -184,54 +196,6 @@ public class AxStateOutput extends AxConcept {
}
/**
- * Sets the reference key for the state output.
- *
- * @param key the reference key for the state output
- */
- public void setKey(final AxReferenceKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the outgoing event emitted on use of this state output.
- *
- * @return the outgoing event emitted on use of this state output
- */
- public AxArtifactKey getOutgingEvent() {
- return outgoingEvent;
- }
-
- /**
- * Sets the outgoing event emitted on use of this state output.
- *
- * @param outgoingEvent the outgoing event emitted on use of this state output
- */
- public void setOutgoingEvent(final AxArtifactKey outgoingEvent) {
- Assertions.argumentNotNull(outgoingEvent, "outgoingEvent may not be null");
- this.outgoingEvent = outgoingEvent;
- }
-
- /**
- * Gets the next state to which execution will pass on use of this state output.
- *
- * @return the next state to which execution will pass on use of this state output
- */
- public AxReferenceKey getNextState() {
- return nextState;
- }
-
- /**
- * Sets the next state to which execution will pass on use of this state output.
- *
- * @param nextState the next state to which execution will pass on use of this state output
- */
- public void setNextState(final AxReferenceKey nextState) {
- Assertions.argumentNotNull(nextState, "nextState may not be null");
- this.nextState = nextState;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
index 04b40e44b..a30a80acc 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -33,6 +34,7 @@ import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@@ -42,6 +44,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -50,6 +55,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.model.eventmodel.concepts.AxInputField;
import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField;
@@ -90,9 +96,13 @@ import org.onap.policy.common.utils.validation.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexTask", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxTask", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "inputFields", "outputFields", "taskParameters", "contextAlbumReferenceSet", "taskLogic"})
-
+@XmlType(
+ name = "AxTask",
+ namespace = "http://www.onap.org/policy/apex-pdp",
+ propOrder = {"key", "inputEvent", "outputEvents", "inputFields", "outputFields", "taskParameters",
+ "contextAlbumReferenceSet", "taskLogic"})
+@Getter
+@Setter
public class AxTask extends AxConcept {
private static final String DOES_NOT_EQUAL_TASK_KEY = " does not equal task key";
@@ -100,8 +110,25 @@ public class AxTask extends AxConcept {
@EmbeddedId
@XmlElement(name = "key", required = true)
+ @NonNull
private AxArtifactKey key;
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinTable(
+ name = "INPUT_EVENT_JT",
+ joinColumns = {@JoinColumn(name = "inEventTaskName", referencedColumnName = "name", updatable = false),
+ @JoinColumn(name = "inEventTaskVersion", referencedColumnName = "version", updatable = false)})
+ @XmlElement(name = "inputEvent", required = false)
+ private AxEvent inputEvent;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ @JoinTable(
+ name = "OUTPUT_EVENT_JT",
+ joinColumns = {@JoinColumn(name = "outEventTaskName", referencedColumnName = "name", updatable = false),
+ @JoinColumn(name = "outEventTaskVersion", referencedColumnName = "version", updatable = false)})
+ @XmlElement(name = "outputEvents", required = false)
+ private Map<String, AxEvent> outputEvents;
+
@OneToMany(cascade = CascadeType.ALL)
@XmlElement(name = "inputFields", required = true)
private Map<String, AxInputField> inputFields;
@@ -119,11 +146,13 @@ public class AxTask extends AxConcept {
@CollectionTable(joinColumns = {@JoinColumn(name = "contextAlbumName", referencedColumnName = "name"),
@JoinColumn(name = "contextAlbumVersion", referencedColumnName = "version")})
@XmlElement(name = "contextAlbumReference")
+ @NonNull
private Set<AxArtifactKey> contextAlbumReferenceSet;
// @formatter:on
@OneToOne(cascade = CascadeType.ALL)
@XmlElement(required = true)
+ @NonNull
private AxTaskLogic taskLogic;
/**
@@ -219,14 +248,6 @@ public class AxTask extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
for (final AxInputField inputField : inputFields.values()) {
@@ -246,25 +267,6 @@ public class AxTask extends AxConcept {
}
/**
- * Sets the key of the task.
- *
- * @param key the key of the task
- */
- public void setKey(final AxArtifactKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the input fields that the task expects.
- *
- * @return the input fields that the task expects
- */
- public Map<String, AxInputField> getInputFields() {
- return inputFields;
- }
-
- /**
* Gets the raw input fields that the task expects as a tree map.
*
* @return the raw input fields that the task expects
@@ -287,16 +289,6 @@ public class AxTask extends AxConcept {
}
/**
- * Sets the input fields that the task expects.
- *
- * @param inputFields the input fields that the task expects
- */
- public void setInputFields(final Map<String, AxInputField> inputFields) {
- Assertions.argumentNotNull(inputFields, "inputFields may not be null");
- this.inputFields = inputFields;
- }
-
- /**
* Copy the input fields from the given map into the task. This method is used to get a copy of
* the input fields, which can be useful for unit testing of policies and tasks.
*
@@ -314,15 +306,6 @@ public class AxTask extends AxConcept {
}
/**
- * Gets the output fields that the task emits.
- *
- * @return the output fields that the task emits
- */
- public Map<String, AxOutputField> getOutputFields() {
- return outputFields;
- }
-
- /**
* Gets the raw output fields that the task emits as a tree map.
*
* @return the raw output fields as a tree map
@@ -345,16 +328,6 @@ public class AxTask extends AxConcept {
}
/**
- * Sets the output fields that the task emits.
- *
- * @param outputFields the output fields that the task emits
- */
- public void setOutputFields(final Map<String, AxOutputField> outputFields) {
- Assertions.argumentNotNull(outputFields, "outputFields may not be null");
- this.outputFields = outputFields;
- }
-
- /**
* Copy the output fields from the given map into the task. This method is used to get a copy of
* the output fields, which can be useful for unit testing of policies and tasks.
*
@@ -371,24 +344,6 @@ public class AxTask extends AxConcept {
}
}
- /**
- * Gets the task parameters that are used to initialize tasks of this type.
- *
- * @return the task parameters that are used to initialize tasks of this type
- */
- public Map<String, AxTaskParameter> getTaskParameters() {
- return taskParameters;
- }
-
- /**
- * Sets the task parameters that are used to initialize tasks of this type.
- *
- * @param taskParameters the task parameters that are used to initialize tasks of this type
- */
- public void setTaskParameters(final Map<String, AxTaskParameter> taskParameters) {
- Assertions.argumentNotNull(taskParameters, "taskParameters may not be null");
- this.taskParameters = taskParameters;
- }
/**
* Gets the context album reference set defines the context that may be used by Task Logic in
@@ -414,25 +369,6 @@ public class AxTask extends AxConcept {
}
/**
- * Gets the task logic that performs the domain specific work of the task.
- *
- * @return the task logic that performs the domain specific work of the task
- */
- public AxTaskLogic getTaskLogic() {
- return taskLogic;
- }
-
- /**
- * Sets the task logic that performs the domain specific work of the task.
- *
- * @param taskLogic the task logic that performs the domain specific work of the task
- */
- public void setTaskLogic(final AxTaskLogic taskLogic) {
- Assertions.argumentNotNull(taskLogic, "taskLogic may not be null");
- this.taskLogic = taskLogic;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -446,30 +382,12 @@ public class AxTask extends AxConcept {
result = key.validate(result);
- if (inputFields.size() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "inputFields may not be empty"));
- } else {
- for (final Entry<String, AxInputField> inputFieldEntry : inputFields.entrySet()) {
- result = validateField(inputFieldEntry.getKey(), inputFieldEntry.getValue(), "input", result);
- }
- }
-
- if (outputFields.size() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "outputFields may not be empty"));
- } else {
- for (final Entry<String, AxOutputField> outputFieldEntry : outputFields.entrySet()) {
- result = validateField(outputFieldEntry.getKey(), outputFieldEntry.getValue(), "input", result);
- }
- }
-
for (final Entry<String, AxTaskParameter> taskParameterEntry : taskParameters.entrySet()) {
- result = vaildateTaskParameterEntry(taskParameterEntry, result);
+ result = validateTaskParameterEntry(taskParameterEntry, result);
}
for (final AxArtifactKey contextAlbumReference : contextAlbumReferenceSet) {
- result = vaildateContextAlbumReference(contextAlbumReference, result);
+ result = validateContextAlbumReference(contextAlbumReference, result);
}
if (!taskLogic.getKey().getParentArtifactKey().equals(key)) {
@@ -481,39 +399,13 @@ public class AxTask extends AxConcept {
}
/**
- * Validate a field.
- *
- * @param fieldKey the key of the field to validate
- * @param field the field to validate
- * @param direction The direction of the field
- * @param result The validation result to append to
- * @return The result of the validation
- */
- private AxValidationResult validateField(final String fieldKey, final AxField field, final String direction,
- AxValidationResult result) {
- if (field == null) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "null " + direction + " field value found on " + direction + " field " + fieldKey));
- } else {
- if (!field.getKey().getParentArtifactKey().equals(key)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent key on " + direction + " field " + fieldKey + DOES_NOT_EQUAL_TASK_KEY));
- }
-
- result = field.validate(result);
- }
-
- return result;
- }
-
- /**
* Validate a task parameter entry.
*
* @param taskParameterEntry the task parameter entry to validate
* @param result The validation result to append to
* @return The result of the validation
*/
- private AxValidationResult vaildateTaskParameterEntry(final Entry<String, AxTaskParameter> taskParameterEntry,
+ private AxValidationResult validateTaskParameterEntry(final Entry<String, AxTaskParameter> taskParameterEntry,
AxValidationResult result) {
if (taskParameterEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
@@ -537,7 +429,7 @@ public class AxTask extends AxConcept {
* @param result The validation result to append to
* @return The result of the validation
*/
- private AxValidationResult vaildateContextAlbumReference(final AxArtifactKey contextAlbumReference,
+ private AxValidationResult validateContextAlbumReference(final AxArtifactKey contextAlbumReference,
AxValidationResult result) {
if (contextAlbumReference.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java
index 4d076cfda..3a4c36bc5 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -137,7 +138,7 @@ public class PolicyAnalyser {
// Event usage by state
result.getEventUsage().get(state.getTrigger()).add(state.getKey());
for (final AxStateOutput stateOutput : state.getStateOutputs().values()) {
- result.getEventUsage().get(stateOutput.getOutgingEvent()).add(state.getKey());
+ result.getEventUsage().get(stateOutput.getOutgoingEvent()).add(state.getKey());
}
// State Context Usage
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
index 86bbf3e93..48022e878 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.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) 2021 Bell Canada. 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.
@@ -335,7 +336,7 @@ public class PolicyModelTest {
final AxStateOutput so = model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs()
.get(savedStateOutputName);
- final AxArtifactKey savedOutEvent = so.getOutgingEvent();
+ final AxArtifactKey savedOutEvent = so.getOutgoingEvent();
so.setOutgoingEvent(new AxArtifactKey("NonExistantEvent", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java
index 8bd29fc55..049783a7f 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.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) 2021 Bell Canada. 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.
@@ -53,20 +54,20 @@ public class StateOutputTest {
final AxArtifactKey eKey = new AxArtifactKey("EventName", "0.0.1");
assertThatThrownBy(() -> so.setKey(null))
- .hasMessage("key may not be null");
+ .hasMessage("key is marked non-null but is null");
so.setKey(soKey);
assertEquals("SOStateParent:0.0.1:SOState:SOName", so.getKey().getId());
assertEquals("SOStateParent:0.0.1:SOState:SOName", so.getKeys().get(0).getId());
assertThatThrownBy(() -> so.setNextState(null))
- .hasMessage("nextState may not be null");
+ .hasMessage("nextState is marked non-null but is null");
so.setNextState(nsKey);
assertEquals(nsKey, so.getNextState());
assertThatThrownBy(() -> so.setOutgoingEvent(null))
- .hasMessage("outgoingEvent may not be null");
+ .hasMessage("outgoingEvent is marked non-null but is null");
so.setOutgoingEvent(eKey);
- assertEquals(eKey, so.getOutgingEvent());
+ assertEquals(eKey, so.getOutgoingEvent());
AxValidationResult result = new AxValidationResult();
result = so.validate(result);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
index 100adb9fd..95266acc8 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.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) 2021 Bell Canada. 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.
@@ -26,6 +27,7 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
import org.junit.Test;
@@ -33,6 +35,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.model.eventmodel.concepts.AxInputField;
import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField;
@@ -91,7 +94,8 @@ public class TasksTest {
assertEquals(ofMap, task.getOutputFields());
assertTrue(task.getOutputFieldSet().contains(of0));
assertTrue(task.getRawOutputFields().keySet().contains(of0.getKey().getLocalName()));
-
+ task.setInputEvent(new AxEvent());
+ task.setOutputEvents(Map.of("Event", new AxEvent()));
final TreeMap<String, AxField> ifDupMap = new TreeMap<>();
final TreeMap<String, AxField> ofDupMap = new TreeMap<>();
ifDupMap.put(if1.getKey().getLocalName(), if1);
@@ -131,46 +135,6 @@ public class TasksTest {
result = task.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- task.setInputFields(ifEmptyMap);
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- task.setInputFields(ifMap);
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- ifMap.put("NullField", null);
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- ifMap.remove("NullField");
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- task.setOutputFields(ofEmptyMap);
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- task.setOutputFields(ofMap);
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- ofMap.put("NullField", null);
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- ofMap.remove("NullField");
- result = new AxValidationResult();
- result = task.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
// Empty task parameter map is OK
task.setTaskParameters(tpEmptyMap);
result = new AxValidationResult();
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java
index 3fca39739..ea2de8603 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java
@@ -1,25 +1,27 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.policymodel.handling;
+import java.util.Map;
import java.util.UUID;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
@@ -52,7 +54,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
/**
* Model creator for model tests.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPolicyModel> {
@@ -136,6 +138,9 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
+ task.setInputEvent(inEvent);
+ task.setOutputEvents(Map.of(outEvent0.getId(), outEvent0, outEvent1.getId(), outEvent1));
+
final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter0"),
"Task parameter 0 value");
final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter1"),
@@ -206,7 +211,7 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
/**
* Gets another policy model.
- *
+ *
* @return the model
*/
public AxPolicyModel getAnotherModel() {
@@ -287,6 +292,9 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
+ task.setInputEvent(inEvent);
+ task.setOutputEvents(Map.of(outEvent0.getId(), outEvent0, outEvent1.getId(), outEvent1));
+
final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA0"),
"Task parameter 0 value");
final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA1"),
@@ -406,6 +414,8 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
anotherTask.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
+ anotherTask.setInputEvent(inEvent);
+ anotherTask.setOutputEvents(Map.of(outEvent0.getId(), outEvent0));
final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter0"),
"Task parameter 0 value");
final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter1"),