aboutsummaryrefslogtreecommitdiffstats
path: root/model/policy-model
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-10 17:05:36 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-10 17:07:47 +0100
commitd100854291559df1426ea1e64351872ae2d3867b (patch)
tree78baab90111307cd3d2460b2cca37e93a20ac9a3 /model/policy-model
parent8f82d7adcb53b349e14d3b356bda03588a554f95 (diff)
Checkstyle changes for apex model
Fix checkstyle warnings in the apex mode and knock on changes. Issue-ID: POLICY-1034 Change-Id: I10537e4288e9cad5ef18165ed2cdc1d3ab3139c1 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'model/policy-model')
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java67
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java79
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java124
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java20
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java42
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java6
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java7
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java4
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java24
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java2
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java10
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyException.java6
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyRuntimeException.java6
-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/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java10
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparer.java19
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestExceptions.java1
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestLogic.java13
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicies.java51
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicyModel.java153
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestState.java93
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateOutput.java2
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateTaskReference.java28
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTaskParameter.java7
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTasks.java4
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModel.java96
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModelCreator.java183
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyLogicReader.java20
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyModelMerger.java18
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/PolicyModelValidator.java14
33 files changed, 591 insertions, 545 deletions
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
index 2fc4467dc..99642d1ae 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
@@ -47,18 +47,16 @@ import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
import org.onap.policy.apex.model.utilities.Assertions;
/**
- * This class holds Logic for executing a task or task selection on an Apex policy state. The
- * flavour of the logic describes the type of logic being used and it may be a language identifier
- * such as "Javascript" or "Jython". The logic itself is held as a string. The {@link AxLogic}
- * instance is used by the Apex engine to start an executor with the required flavour. Once the
- * executor is started, the Apex engine passes the logic to the executor and the executor executes
- * it. In the Apex engine, executors are deployed as plugins. Apex also provides the executor with
- * run-time context, which makes context such as input fields, output fields, and context albums
- * available to the task at runtime.
- * <p>
- * Validation checks that the logic key is valid, that the logic flavour is defined and is valid
- * when checked against the {@code LOGIC_FLAVOUR_REGEXP} regular expression, and that the specified
- * logic string is not null or blank.
+ * This class holds Logic for executing a task or task selection on an Apex policy state. The flavour of the logic
+ * describes the type of logic being used and it may be a language identifier such as "Javascript" or "Jython". The
+ * logic itself is held as a string. The {@link AxLogic} instance is used by the Apex engine to start an executor with
+ * the required flavour. Once the executor is started, the Apex engine passes the logic to the executor and the executor
+ * executes it. In the Apex engine, executors are deployed as plugins. Apex also provides the executor with run-time
+ * context, which makes context such as input fields, output fields, and context albums available to the task at
+ * runtime.
+ *
+ * <p>Validation checks that the logic key is valid, that the logic flavour is defined and is valid when checked against
+ * the {@code LOGIC_FLAVOUR_REGEXP} regular expression, and that the specified logic string is not null or blank.
*/
@Entity
@@ -67,8 +65,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxLogic", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "logicFlavour", "logic"})
+@XmlType(name = "AxLogic", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "logicFlavour", "logic" })
public class AxLogic extends AxConcept {
private static final long serialVersionUID = -4260562004005697328L;
@@ -105,8 +103,8 @@ public class AxLogic extends AxConcept {
private String logic;
/**
- * The Default Constructor creates a logic instance with a null key, undefined logic flavour and
- * a null logic string.
+ * The Default Constructor creates a logic instance with a null key, undefined logic flavour and a null logic
+ * string.
*/
public AxLogic() {
this(new AxReferenceKey());
@@ -114,7 +112,7 @@ public class AxLogic extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -123,8 +121,8 @@ public class AxLogic extends AxConcept {
}
/**
- * The Key Constructor creates a logic instance with the given reference key, undefined logic
- * flavour and a null logic string.
+ * The Key Constructor creates a logic instance with the given reference key, undefined logic flavour and a null
+ * logic string.
*
* @param key the reference key of the logic
*/
@@ -133,8 +131,8 @@ public class AxLogic extends AxConcept {
}
/**
- * This Constructor creates a logic instance with a reference key constructed from the parents
- * key and the logic local name and all of its fields defined.
+ * This Constructor creates a logic instance with a reference key constructed from the parents key and the logic
+ * local name and all of its fields defined.
*
* @param parentKey the reference key of the parent of this logic
* @param logicName the logic name, held as the local name of the reference key of this logic
@@ -142,13 +140,12 @@ public class AxLogic extends AxConcept {
* @param logic the actual logic as a string
*/
public AxLogic(final AxReferenceKey parentKey, final String logicName, final String logicFlavour,
- final String logic) {
+ final String logic) {
this(new AxReferenceKey(parentKey, logicName), logicFlavour, logic);
}
/**
- * This Constructor creates a logic instance with the given reference key and all of its fields
- * defined.
+ * This Constructor creates a logic instance with the given reference key and all of its fields defined.
*
* @param key the reference key of this logic
* @param logicFlavour the flavour of this logic
@@ -166,8 +163,8 @@ public class AxLogic extends AxConcept {
}
/**
- * This Constructor creates a logic instance with the given reference key and logic flavour, the
- * logic is provided by the given logic reader instance.
+ * This Constructor creates a logic instance with the given reference key and logic flavour, the logic is provided
+ * by the given logic reader instance.
*
* @param key the reference key of this logic
* @param logicFlavour the flavour of this logic
@@ -254,8 +251,7 @@ public class AxLogic extends AxConcept {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
* basicmodel.concepts.AxValidationResult)
*/
@Override
@@ -263,28 +259,28 @@ public class AxLogic extends AxConcept {
AxValidationResult result = resultIn;
if (key.equals(AxReferenceKey.getNullKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key is a null key"));
}
result = key.validate(result);
if (logicFlavour.replaceAll(WHITESPACE_REGEXP, "").length() == 0
- || logicFlavour.equals(LOGIC_FLAVOUR_UNDEFINED)) {
+ || logicFlavour.equals(LOGIC_FLAVOUR_UNDEFINED)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "logic flavour is not defined"));
+ "logic flavour is not defined"));
}
try {
Assertions.validateStringParameter(LOGIC_FLAVOUR_TOKEN, logicFlavour, LOGIC_FLAVOUR_REGEXP);
} catch (final IllegalArgumentException e) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "logic flavour invalid-" + e.getMessage()));
+ "logic flavour invalid-" + e.getMessage()));
}
if (logic.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "no logic specified, logic may not be blank"));
+ "no logic specified, logic may not be blank"));
}
return result;
@@ -327,8 +323,7 @@ public class AxLogic extends AxConcept {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
* basicmodel.concepts.AxConcept)
*/
@Override
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
index 1937edac0..3be3e4a31 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
@@ -51,22 +51,21 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.utilities.Assertions;
/**
- * This class is a policy container and holds a map of the policies for an entire Apex model. All
- * Apex models that use policies must have an {@link AxPolicies} field. The {@link AxPolicies} class
- * implements the helper methods of the {@link AxConceptGetter} interface to allow {@link AxPolicy}
- * instances to be retrieved by calling methods directly on this class without referencing the
- * contained map.
- * <p>
- * Validation checks that the container key is not null. An error is issued if no policies are
- * defined in the container. Each policy entry is checked to ensure that its key and value are not
- * null and that the key matches the key in the map value. Each policy entry is then validated
- * individually.
+ * This class is a policy container and holds a map of the policies for an entire Apex model. All Apex models that use
+ * policies must have an {@link AxPolicies} field. The {@link AxPolicies} class implements the helper methods of the
+ * {@link AxConceptGetter} interface to allow {@link AxPolicy} instances to be retrieved by calling methods directly on
+ * this class without referencing the contained map.
+ *
+ * <p>Validation checks that the container key is not null. An error is issued if no policies are defined in the
+ * container. Each policy entry is checked to ensure that its key and value are not null and that the key matches the
+ * key in the map value. Each policy entry is then validated individually.
*/
@Entity
@Table(name = "AxPolicies")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxPolicies", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = {"key", "policyMap"})
+@XmlType(name = "AxPolicies", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "policyMap" })
public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
private static final long serialVersionUID = 4290442590545820316L;
@@ -87,16 +86,16 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
// @formatter:on
/**
- * The Default Constructor creates a {@link AxPolicies} object with a null artifact key and
- * creates an empty event map.
+ * The Default Constructor creates a {@link AxPolicies} object with a null artifact key and creates an empty event
+ * map.
*/
public AxPolicies() {
this(new AxArtifactKey());
}
/**
- * The Key Constructor creates a {@link AxPolicies} object with the given artifact key and
- * creates an empty event map.
+ * The Key Constructor creates a {@link AxPolicies} object with the given artifact key and creates an empty event
+ * map.
*
* @param key the key
*/
@@ -105,7 +104,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -130,15 +129,14 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
}
/**
- * When a model is unmarshalled from disk or from the database, the policy map is returned as a
- * raw hash map. This method is called by JAXB after unmarshaling and is used to convert the
- * hash map to a {@link NavigableMap} so that it will work with the {@link AxConceptGetter}
- * interface.
+ * When a model is unmarshalled from disk or from the database, the policy map is returned as a raw hash map. This
+ * method is called by JAXB after unmarshaling and is used to convert the hash map to a {@link NavigableMap} so that
+ * it will work with the {@link AxConceptGetter} interface.
*
- * @param u the unmarshaler that is unmarshaling the model
+ * @param unmarshaler the unmarshaler that is unmarshaling the model
* @param parent the parent object of this object in the unmarshaler
*/
- public void afterUnmarshal(final Unmarshaller u, final Object parent) {
+ public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
// The map must be navigable to allow name and version searching, unmarshaling returns a
// hash map
final NavigableMap<AxArtifactKey, AxPolicy> navigablePolicyMap = new TreeMap<>();
@@ -205,8 +203,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
* basicmodel.concepts.AxValidationResult)
*/
@Override
@@ -214,24 +211,24 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
AxValidationResult result = resultIn;
if (key.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key is a null key"));
}
result = key.validate(result);
if (policyMap.size() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "policyMap may not be empty"));
+ "policyMap may not be empty"));
} else {
for (final Entry<AxArtifactKey, AxPolicy> policyEntry : policyMap.entrySet()) {
final AxArtifactKey entryKey = policyEntry.getKey();
if (entryKey.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on policy entry " + entryKey + " may not be the null key"));
+ "key on policy entry " + entryKey + " may not be the null key"));
} else if (policyEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on policy entry " + entryKey + " may not be null"));
+ "value on policy entry " + entryKey + " may not be null"));
} else {
validate(result, policyEntry, entryKey);
result = policyEntry.getValue().validate(result);
@@ -243,11 +240,11 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
}
private void validate(final AxValidationResult result, final Entry<AxArtifactKey, AxPolicy> policyEntry,
- final AxArtifactKey entryKey) {
+ final AxArtifactKey entryKey) {
if (!entryKey.equals(policyEntry.getValue().getKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key on policy entry key "
- + entryKey + " does not equal policy value key " + policyEntry.getValue().getKey()));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key on policy entry key " + entryKey + " does not equal policy value key "
+ + policyEntry.getValue().getKey()));
}
}
@@ -286,8 +283,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
* basicmodel.concepts.AxConcept)
*/
@Override
@@ -379,8 +375,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(org.onap.policy.apex.model
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(org.onap.policy.apex.model
* .basicmodel.concepts.AxArtifactKey)
*/
@Override
@@ -401,13 +396,12 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(java.lang.String,
- * java.lang.String)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(java.lang.String, java.lang.String)
*/
@Override
public AxPolicy get(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxPolicy>) policyMap).get(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
/*
@@ -423,12 +417,11 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#getAll(java.lang.String,
- * java.lang.String)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#getAll(java.lang.String, java.lang.String)
*/
@Override
public Set<AxPolicy> getAll(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxPolicy>) policyMap).getAll(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
index 8b87c41ce..a03b49f13 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
@@ -51,39 +51,30 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.utilities.Assertions;
/**
- * This class holds the definition of an Apex policy. A policy is made up of a tree of states, each
- * represented by an {@link AxState} instance. The states of a policy are held in a map in the
- * policy. The state tree is built up at policy design time by a policy editor and each state is
- * connected to its next state by an {@link AxStateOutput} instance.
- * <p>
- * Execution of a policy is triggered by an event. A policy starts execution from its first state so
- * the trigger event for the first sate is the trigger event for the entire policy. Execution from
- * that first state can continue to one or more subsequent states and so on down branches of states.
- * The state output of the final state in a branch has no next state, indicating the end of
- * execution of that branch. Therefore, the set of output events from final states in the policy are
- * the possible set of output events on the policy. A state may only be used once in the state tree
- * of a policy and recursive execution of states in the same execution branch is not allowed, so the
- * same state may not execute more than once on a single execution of a policy.
- * <p>
- * The template of a policy is a string that can be used by policy editors to store meta information
- * on the policy that can be used at design time. The policy template string is not used during
- * policy execution.
- * <p>
- * During validation of a policy, the validation checks listed below are executed:
- * <ol>
- * <li>The policy key must not be a null key
- * <li>The policy key must be valid
- * <li>If the policy template is not set, an observation is issued
- * <li>At least one state must be defined
- * <li>Keys and values must all be defined, that is not null
- * <li>The key on each entry in the state map must match the key in the entry's value
- * <li>The parent key of each state in the state map of a policy must be the key of that policy
- * <li>Each state must itself be valid, see validation in {@link AxState}
- * <li>The next state of the state output of each state must be defined as a state in the policy
- * <li>The first state of a policy must be set
- * <li>The first state of a policy must be defined in the policy
- * <li>If a state is defined but is not used in a policy,a warning is issued
- * <li>The state tree of the policy must be valid, see validation in {@link AxStateTree}
+ * This class holds the definition of an Apex policy. A policy is made up of a tree of states, each represented by an
+ * {@link AxState} instance. The states of a policy are held in a map in the policy. The state tree is built up at
+ * policy design time by a policy editor and each state is connected to its next state by an {@link AxStateOutput}
+ * instance.
+ *
+ * <p>Execution of a policy is triggered by an event. A policy starts execution from its first state so the trigger
+ * event for the first sate is the trigger event for the entire policy. Execution from that first state can continue to
+ * one or more subsequent states and so on down branches of states. The state output of the final state in a branch has
+ * no next state, indicating the end of execution of that branch. Therefore, the set of output events from final states
+ * in the policy are the possible set of output events on the policy. A state may only be used once in the state tree of
+ * a policy and recursive execution of states in the same execution branch is not allowed, so the same state may not
+ * execute more than once on a single execution of a policy.
+ *
+ * <p>The template of a policy is a string that can be used by policy editors to store meta information on the policy
+ * that can be used at design time. The policy template string is not used during policy execution.
+ *
+ * <p>During validation of a policy, the validation checks listed below are executed: <ol> <li>The policy key must not
+ * be a null key <li>The policy key must be valid <li>If the policy template is not set, an observation is issued <li>At
+ * least one state must be defined <li>Keys and values must all be defined, that is not null <li>The key on each entry
+ * in the state map must match the key in the entry's value <li>The parent key of each state in the state map of a
+ * policy must be the key of that policy <li>Each state must itself be valid, see validation in {@link AxState} <li>The
+ * next state of the state output of each state must be defined as a state in the policy <li>The first state of a policy
+ * must be set <li>The first state of a policy must be defined in the policy <li>If a state is defined but is not used
+ * in a policy,a warning is issued <li>The state tree of the policy must be valid, see validation in {@link AxStateTree}
* </ol>
*/
@@ -91,8 +82,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
@Table(name = "AxPolicy")
@XmlRootElement(name = "apexPolicy", namespace = "http://www.onap.org/policy/apex-pdp")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxPolicy", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "template", "stateMap", "firstState"})
+@XmlType(name = "AxPolicy", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "template", "stateMap", "firstState" })
public class AxPolicy extends AxConcept {
private static final long serialVersionUID = -1775614096390365941L;
@@ -118,15 +109,14 @@ public class AxPolicy extends AxConcept {
private String firstState;
/**
- * The Default Constructor creates a policy instance with a null key, a blank template and
- * undefined first state.
+ * The Default Constructor creates a policy instance with a null key, a blank template and undefined first state.
*/
public AxPolicy() {
this(new AxArtifactKey());
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -135,8 +125,7 @@ public class AxPolicy extends AxConcept {
}
/**
- * The Key Constructor creates a policy instance with the given key, a blank template and
- * undefined first state.
+ * The Key Constructor creates a policy instance with the given key, a blank template and undefined first state.
*
* @param key the key of the policy
*/
@@ -153,7 +142,7 @@ public class AxPolicy extends AxConcept {
* @param firstState the first state that will execute on this policy
*/
public AxPolicy(final AxArtifactKey key, final String template, final Map<String, AxState> stateMap,
- final String firstState) {
+ final String firstState) {
super();
Assertions.argumentNotNull(key, "key may not be null");
Assertions.argumentNotNull(template, "template may not be null");
@@ -167,12 +156,10 @@ public class AxPolicy extends AxConcept {
}
/**
- * Gets a tree that holds all the possible execution paths for this policy. This method may be
- * used for verification of policies, to find the branches of policy execution and the final
- * states of policies.
+ * Gets a tree that holds all the possible execution paths for this policy. This method may be used for verification
+ * of policies, to find the branches of policy execution and the final states of policies.
*
- * @return the state tree of the policy, a tree representing the execution branches of the
- * policy
+ * @return the state tree of the policy, a tree representing the execution branches of the policy
*/
public AxStateTree getStateTree() {
return new AxStateTree(this, stateMap.get(firstState), null);
@@ -272,8 +259,7 @@ public class AxPolicy extends AxConcept {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
* basicmodel.concepts.AxValidationResult)
*/
@Override
@@ -281,20 +267,20 @@ public class AxPolicy extends AxConcept {
AxValidationResult result = resultIn;
if (key.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key is a null key"));
}
result = key.validate(result);
if (template.trim().length() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
- "a policy template has not been specified"));
+ "a policy template has not been specified"));
}
if (stateMap.size() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "stateMap may not be empty"));
+ "stateMap may not be empty"));
} else {
for (final Entry<String, AxState> stateEntry : stateMap.entrySet()) {
result = validateStateEntry(stateEntry, result);
@@ -310,11 +296,11 @@ public class AxPolicy extends AxConcept {
// We only check the unused states on models validated this far
if (firstState.trim().length() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "no first state specified, first state may not be blank"));
+ "no first state specified, first state may not be blank"));
} else {
if (!stateMap.containsKey(firstState)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "first state not found in stateMap"));
+ "first state not found in stateMap"));
} else {
validateStateTree(result);
}
@@ -324,7 +310,7 @@ public class AxPolicy extends AxConcept {
}
/**
- * Validate a state entry
+ * Validate a state entry.
*
* @param stateEntry the state entry to validate
* @param result The validation result to append to
@@ -333,35 +319,37 @@ public class AxPolicy extends AxConcept {
private AxValidationResult validateStateEntry(final Entry<String, AxState> stateEntry, AxValidationResult result) {
if (stateEntry.getKey() == null || stateEntry.getKey().equals(AxKey.NULL_KEY_NAME)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on state entry key " + stateEntry.getKey() + " may not be the null key"));
+ "key on state entry key " + stateEntry.getKey() + " may not be the null key"));
return result;
}
if (stateEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on state entry value " + stateEntry.getKey() + " may not be null"));
+ "value on state entry value " + stateEntry.getKey() + " may not be null"));
return result;
}
if (!stateEntry.getKey().equals(stateEntry.getValue().getKey().getLocalName())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on state entry key " + stateEntry.getKey() + " does not equal state entry value local name "
- + stateEntry.getValue().getKey().getLocalName()));
+ "key on state entry key " + stateEntry.getKey()
+ + " does not equal state entry value local name "
+ + stateEntry.getValue().getKey().getLocalName()));
}
if (!stateEntry.getValue().getKey().getParentArtifactKey().equals(key)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent key on state entry key " + stateEntry.getValue().getKey() + " does not equal policy key"));
+ "parent key on state entry key " + stateEntry.getValue().getKey()
+ + " does not equal policy key"));
}
result = stateEntry.getValue().validate(result);
for (final AxStateOutput stateOutput : stateEntry.getValue().getStateOutputs().values()) {
if (!stateOutput.getNextState().equals(AxReferenceKey.getNullKey())
- && !stateMap.containsKey(stateOutput.getNextState().getLocalName())) {
+ && !stateMap.containsKey(stateOutput.getNextState().getLocalName())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- " nextState of state " + stateEntry.getKey() + " not found in StateMap: "
- + stateOutput.getNextState().getId()));
+ " nextState of state " + stateEntry.getKey() + " not found in StateMap: "
+ + stateOutput.getNextState().getId()));
}
}
@@ -369,7 +357,7 @@ public class AxPolicy extends AxConcept {
}
/**
- * Validate a state tree to ensure there are no circular references in it
+ * Validate a state tree to ensure there are no circular references in it.
*
* @param result The validation result to append to
* @return The result of the validation
@@ -386,11 +374,12 @@ public class AxPolicy extends AxConcept {
for (final AxState unreferencedState : unreferencedStateSet) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "state " + unreferencedState.getKey() + " is not referenced in the policy execution tree"));
+ "state " + unreferencedState.getKey()
+ + " is not referenced in the policy execution tree"));
}
} catch (PolicyRuntimeException pre) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "state tree in policy is invalid"));
+ "state tree in policy is invalid"));
}
return result;
@@ -432,8 +421,7 @@ public class AxPolicy extends AxConcept {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
* basicmodel.concepts.AxConcept)
*/
@Override
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 ad465a48e..8233a0517 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
@@ -62,19 +62,19 @@ import org.onap.policy.apex.model.utilities.Assertions;
* required to run policies in Apex. The model contains schema definitions, definitions of events
* and context albums that use those schemas, definitions of tasks for policies and definitions of
* the policies themselves.
- * <p>
- * An Apex policy model is an important artifact in Apex. At editing time, an Apex editor creates
+ *
+ * <p>An Apex policy model is an important artifact in Apex. At editing time, an Apex editor creates
* and edits a policy model and a policy model is loaded into and is executed by an Apex engine.
* Therefore, an Apex model and the set of policies that it holds is the way that the policy domain
* that an Apex engine or a group of Apex engines executes across is expressed, both at design time
* and run time. The Apex deployment system is responsible for deploying Apex models to and the
* context they need the appropriate engines for execution.
- * <p>
- * Model registration is carried out by calling the {@code register()} method, which registers the
+ *
+ * <p>Model registration is carried out by calling the {@code register()} method, which registers the
* policy model and all its constituent containers with the model service. The containers for
* context schemas, events, context albums, tasks, policies, and key information are all registered.
- * <p>
- * Once a policy model is composed, the overall structure of the policy model and all its references
+ *
+ * <p>Once a policy model is composed, the overall structure of the policy model and all its references
* can be validated. During validation of a policy model, the validation checks listed below are
* executed:
* <ol>
@@ -155,7 +155,7 @@ public class AxPolicyModel extends AxModel {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -467,7 +467,7 @@ public class AxPolicyModel extends AxModel {
}
/**
- * Validate that the references used on a state are valid
+ * Validate that the references used on a state are valid.
*
* @param state The state to check
* @param result the validation result to append to
@@ -518,7 +518,7 @@ public class AxPolicyModel extends AxModel {
/**
* Validate that the fields on tasks and events that trigger them and are output by them are
- * compatible for all tasks used on a state
+ * compatible for all tasks used on a state.
*
* @param state The state to check
* @param result the validation result to append to
@@ -545,7 +545,7 @@ public class AxPolicyModel extends AxModel {
/**
* Validate that the fields on a task of a state output and the events that trigger it are
- * compatible
+ * compatible.
*
* @param state The state to check
* @param task The task to check
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java
index 6851e4859..fd1519620 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java
@@ -67,30 +67,30 @@ import org.onap.policy.apex.model.utilities.Assertions;
* next state. The outputs of a state {@link AxStateOutput} are held as a map in the state. Each
* state output contains the outgoing event of the state and optionally the next state to pass
* control to.
- * <p>
- * A state uses tasks {@link AxTask} to execute its logic. A state holds its tasks in a map and must
+ *
+ * <p>A state uses tasks {@link AxTask} to execute its logic. A state holds its tasks in a map and must
* have at least one task. A state uses Task Selection Logic {@link AxTaskSelectionLogic} to select
* which task should be executed in a given execution cycle. Optional Task Selection Logic can use
* fields on the incoming event and information from the context albums available on the state to
* decide what task to execute in a given context. The default task of a state is the task that is
* executed when task Selection Logic is not specified. In cases where only a single task is
* specified on a state, the default task must be that task and the state always executes that task.
- * <p>
- * What happens when a state completes its execution cycle depends on the task that is selected for
+ *
+ * <p>What happens when a state completes its execution cycle depends on the task that is selected for
* execution by the state. Therefore, the action to be performed a state on execution of each task
* must be defined in the state as a {@link AxStateTaskReference} instance for each task defined in
* the state. The {@link AxStateTaskReference} instance defines the action to be performed as either
* a {@link AxStateTaskOutputType} of {@link AxStateTaskOutputType#DIRECT} or
* {@link AxStateTaskOutputType#LOGIC} and contains an {@link AxReferenceKey} reference to the
* instance that will complete the state output.
- * <p>
- * In the case of direct output, the {@link AxReferenceKey} reference in the
+ *
+ * <p>In the case of direct output, the {@link AxReferenceKey} reference in the
* {@link AxStateTaskReference} instance is a reference to an {@link AxStateOutput} instance. The
* state output defines the event to be emitted by the state and the next state to pass control to
* if any. All fields of the executed task are marshaled onto the outgoing event automatically by
* Apex.
- * <p>
- * In the case of logic output, the {@link AxReferenceKey} reference in the
+ *
+ * <p>In the case of logic output, the {@link AxReferenceKey} reference in the
* {@link AxStateTaskReference} instance is a reference to State Finalizer Logic in an
* {@link AxStateFinalizerLogic} instance, which selects the {@link AxStateOutput} that the state
* will use. The state finalizer logic uses fields emitted by the executed task and information from
@@ -100,13 +100,13 @@ import org.onap.policy.apex.model.utilities.Assertions;
* the state. State Finalizer Logic must marshal the fields of the output event in whatever manner
* it wishes; Apex does not automatically transfer the output fields from the task directly to the
* output event.
- * <p>
- * The Task Selection Logic instance or State Finalizer Logic instances in a state may use
+ *
+ * <p>The Task Selection Logic instance or State Finalizer Logic instances in a state may use
* information in context albums to arrive at their task or state output selections. The context
* albums that the state uses and that should be made available to the state by Apex policy
* distribution are held as a set of references to context albums in the state.
- * <p>
- * During validation of a state, the validation checks listed below are executed:
+ *
+ * <p>During validation of a state, the validation checks listed below are executed:
* <ol>
* <li>The policy key must not be a null key and must be valid, see validation in
* {@link AxReferenceKey}
@@ -247,7 +247,7 @@ public class AxState extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -322,10 +322,10 @@ public class AxState extends AxConcept {
* parent keys of all {@link AxTaskSelectionLogic}, {@link AxStateOutput}, and
* {@link AxStateFinalizerLogic} instance in the state.
*
- * @param u the unmarshaler that is unmarshaling the model
+ * @param unmarshaler the unmarshaler that is unmarshaling the model
* @param parent the parent object of this object in the unmarshaler
*/
- public void afterUnmarshal(final Unmarshaller u, final Object parent) {
+ public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
if (!taskSelectionLogic.getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
taskSelectionLogic.getKey().setParentReferenceKey(key);
}
@@ -623,7 +623,7 @@ public class AxState extends AxConcept {
}
/**
- * Validate the state outputs of the state
+ * Validate the state outputs of the state.
*
* @param result the validation result to append to
*/
@@ -659,7 +659,7 @@ public class AxState extends AxConcept {
}
/**
- * Validate the context album references of the state
+ * Validate the context album references of the state.
*
* @param result the validation result to append to
*/
@@ -676,7 +676,7 @@ public class AxState extends AxConcept {
}
/**
- * Validate the task selection logic of the state
+ * Validate the task selection logic of the state.
*
* @param result the validation result to append to
* @return the result of the validation
@@ -694,7 +694,7 @@ public class AxState extends AxConcept {
}
/**
- * Validate all the state finalizer logic of the state
+ * Validate all the state finalizer logic of the state.
*
* @param result the validation result to append to
*/
@@ -717,7 +717,7 @@ public class AxState extends AxConcept {
}
/**
- * Validate the tasks used the state
+ * Validate the tasks used the state.
*
* @param result the validation result to append to
*/
@@ -762,7 +762,7 @@ public class AxState extends AxConcept {
}
/**
- * Validate the references of a task used in a state
+ * Validate the references of a task used in a state.
*
* @param taskKey The key of the task
* @param taskReference the task reference of the task
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java
index 76704b051..d8ab0ce77 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java
@@ -34,14 +34,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
* This class holds State Finalizer Logic for {@link AxState} states in Apex. It is a specialization
* of the {@link AxLogic} class, so that State Finalizer Logic in Apex states can be strongly typed.
- * <p>
- * State Finalizer Logic is used to select the output {@link AxStateOutput} that a state will use.
+ *
+ * <p>State Finalizer Logic is used to select the output {@link AxStateOutput} that a state will use.
* The logic uses fields emitted by the executed {@link AxTask} task and information from the
* context albums available on a state to decide what state output {@link AxStateOutput} to select
* in a given context. State Finalizer Logic must marshal the output fields from the task onto the
* output event in whatever manner is appropriate for the domain being handled.
- * <p>
- * Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
+ *
+ * <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
*/
@Entity
@Table(name = "AxStateFinalizerLogic")
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 a0c73c260..6f6117027 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
@@ -52,8 +52,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
* state output is selected. If no next state is defined (the next state is a null
* {@link AxReferenceKey} key), then this state output outputs its event to an external system and
* is an output state for the full policy.
- * <p>
- * During validation of a state output, the validation checks listed below are executed:
+ *
+ * <p>During validation of a state output, the validation checks listed below are executed:
* <ol>
* <li>The state output key must not be a null key and must be valid, see validation in
* {@link AxReferenceKey}
@@ -105,7 +105,7 @@ public class AxStateOutput extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java
index 8a43e371d..fdf73149f 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java
@@ -59,9 +59,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
* case of {@link AxStateTaskOutputType#LOGIC} output selection, the output reference key held in
* this {@link AxStateTaskReference} instance to an instance of an {@link AxStateFinalizerLogic}
* class. See the explanation in the {@link AxState} class for a full description of this handling.
- * <p>
- *
- * During validation of a state task reference, the validation checks listed below are executed:
+ *
+ * <p>During validation of a state task reference, the validation checks listed below are executed:
* <ol>
* <li>The state task reference key must not be a null key and must be valid, see validation in
* {@link AxReferenceKey}
@@ -111,7 +110,7 @@ public class AxStateTaskReference extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java
index 478608ca4..0233aa6bf 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java
@@ -34,8 +34,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
* creates a tree that holds the state fan out branches in a policy that starts from the given top
* state of the tree. Each branch from a state is held in a set of next states for the top state and
* each branch in the state tree is itself a {@link AxStateTree} instance.
- * <p>
- * Validation checks for recursive state use, in other words validation forbids the use of a given
+ *
+ * <p>Validation checks for recursive state use, in other words validation forbids the use of a given
* state more than once in a state tree.
*/
public class AxStateTree implements Comparable<AxStateTree> {
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 f26331671..cf8f34ce7 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
@@ -60,16 +60,16 @@ import org.onap.policy.apex.model.utilities.Assertions;
* This class holds the definition of a task in Apex. A task is executed by a state and performs
* some domain specific logic to carry out work required to be done by a policy. The Task Logic that
* is executed by a task is held in a {@link AxTaskLogic} instance.
- * <p>
- * A task has a set of input fields and output fields, which are passed to and are emitted from the
+ *
+ * <p>A task has a set of input fields and output fields, which are passed to and are emitted from the
* task during a task execution cycle. A task may have task parameters {@link AxTaskParameter},
* which are configuration values passed to a task at initialization time.
- * <p>
- * The Task Logic in a task may use information in context albums to perform their domain specific
+ *
+ * <p>The Task Logic in a task may use information in context albums to perform their domain specific
* work. The context albums that the task uses and that should be made available to the task by Apex
* policy distribution are held as a set of references to context albums in the task.
- * <p>
- * During validation of a task, the validation checks listed below are executed:
+ *
+ * <p>During validation of a task, the validation checks listed below are executed:
* <ol>
* <li>The task key must not be a null key and must be valid, see validation in
* {@link AxArtifactKey}
@@ -137,7 +137,7 @@ public class AxTask extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -197,10 +197,10 @@ public class AxTask extends AxConcept {
* parent keys of all {@link AxInputField}, {@link AxOutputField}, and {@link AxTaskParameter}
* instance in the task.
*
- * @param u the unmarshaler that is unmarshaling the model
+ * @param unmarshaler the unmarshaler that is unmarshaling the model
* @param parent the parent object of this object in the unmarshaler
*/
- public void afterUnmarshal(final Unmarshaller u, final Object parent) {
+ public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
taskLogic.getKey().setParentArtifactKey(key);
for (final AxInputField inputField : inputFields.values()) {
@@ -490,7 +490,7 @@ public class AxTask extends AxConcept {
}
/**
- * Validate a field
+ * Validate a field.
*
* @param key the key of the field to validate
* @param field the field to validate
@@ -516,7 +516,7 @@ public class AxTask extends AxConcept {
}
/**
- * Validate a task parameter entry
+ * Validate a task parameter entry.
*
* @param taskParameterEntry the task parameter entry to validate
* @param result The validation result to append to
@@ -540,7 +540,7 @@ public class AxTask extends AxConcept {
}
/**
- * Validate a context album reference entry
+ * Validate a context album reference entry.
*
* @param taskParameterEntry the context album reference entry to validate
* @param result The validation result to append to
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java
index 00513e8f7..30f37ffe2 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java
@@ -35,12 +35,12 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
* This class holds Task Logic for {@link AxTask} tasks in Apex. It is a specialization of the
* {@link AxLogic} class, so that Task Logic in Apex states can be strongly typed.
- * <p>
- * Task Logic is used to execute tasks {@link AxTask} in Apex. The logic uses fields on the incoming
+ *
+ * <p>Task Logic is used to execute tasks {@link AxTask} in Apex. The logic uses fields on the incoming
* trigger event and information from the context albums available on a task to get context during
* execution. The task logic populates the output fields of the task.
- * <p>
- * Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
+ *
+ * <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
*/
@Entity
@Table(name = "AxTaskLogic")
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java
index 5ae3bfa42..236956020 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java
@@ -76,7 +76,7 @@ public class AxTaskParameter extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java
index 89c9418a4..32d8ef3b3 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java
@@ -34,12 +34,12 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
* This class holds Task Selection Logic for {@link AxState} states in Apex. It is a specialization
* of the {@link AxLogic} class, so that Task Selection Logic in Apex states can be strongly typed.
- * <p>
- * Task Selection Logic is used to select the task {@link AxTask} that a state will execute. The
+ *
+ * <p>Task Selection Logic is used to select the task {@link AxTask} that a state will execute. The
* logic uses fields on the incoming trigger event and information from the context albums available
* on a state to decide what task {@link AxTask} to select for execution in a given context.
- * <p>
- * Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
+ *
+ * <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
*/
@Entity
@Table(name = "AxTaskSelectionLogic")
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java
index 532d7d017..75fe632a6 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java
@@ -55,8 +55,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
* models that use tasks must have an {@link AxTasks} field. The {@link AxTasks} class implements
* the helper methods of the {@link AxConceptGetter} interface to allow {@link AxTask} instances to
* be retrieved by calling methods directly on this class without referencing the contained map.
- * <p>
- * Validation checks that the container key is not null. An error is issued if no tasks are defined
+ *
+ * <p>Validation checks that the container key is not null. An error is issued if no tasks are defined
* in the container. Each task entry is checked to ensure that its key and value are not null and
* that the key matches the key in the map value. Each task entry is then validated individually.
*/
@@ -92,7 +92,7 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -132,10 +132,10 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
* hash map to a {@link NavigableMap} so that it will work with the {@link AxConceptGetter}
* interface.
*
- * @param u the unmarshaler that is unmarshaling the model
+ * @param unmarshaler the unmarshaler that is unmarshaling the model
* @param parent the parent object of this object in the unmarshaler
*/
- public void afterUnmarshal(final Unmarshaller u, final Object parent) {
+ public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
// The map must be navigable to allow name and version searching, unmarshaling returns a
// hash map
final NavigableMap<AxArtifactKey, AxTask> navigableTaskMap = new TreeMap<>();
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyException.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyException.java
index 3b0d53f9c..271e0c2af 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyException.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyException.java
@@ -43,9 +43,9 @@ public class PolicyException extends ApexException {
* Instantiates a new apex policy exception with a message and a caused by exception.
*
* @param message the message
- * @param e the exception that caused this exception to be thrown
+ * @param exception the exception that caused this exception to be thrown
*/
- public PolicyException(final String message, final Exception e) {
- super(message, e);
+ public PolicyException(final String message, final Exception exception) {
+ super(message, exception);
}
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyRuntimeException.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyRuntimeException.java
index dbd2fb64f..7ad293187 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyRuntimeException.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/PolicyRuntimeException.java
@@ -43,9 +43,9 @@ public class PolicyRuntimeException extends ApexRuntimeException {
* Instantiates a new apex policy runtime exception with a message and a caused by exception.
*
* @param message the message
- * @param e the exception that caused this exception to be thrown
+ * @param exception the exception that caused this exception to be thrown
*/
- public PolicyRuntimeException(final String message, final Exception e) {
- super(message, e);
+ public PolicyRuntimeException(final String message, final Exception exception) {
+ super(message, exception);
}
}
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 99058484b..244346c99 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
@@ -38,7 +38,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.onap.policy.apex.model.utilities.Assertions;
/**
- * This class analyses a policy model and shows what the usage of each context album, context item, data type, and event is.
+ * This class analyses a policy model and shows what the usage of each context album, context item, data type, and event
+ * is.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java
index 2f5cd43d8..654ab2fc5 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java
@@ -32,7 +32,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
/**
- * This class finds and holds the usage of context schemas, context albums, events, and tasks by the policies in a policy model.
+ * This class finds and holds the usage of context schemas, context albums, events, and tasks by the policies in a
+ * policy model.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -50,8 +51,8 @@ public class PolicyAnalysisResult {
private final Map<AxArtifactKey, Set<AxKey>> taskUsage = new TreeMap<>();
/**
- * This constructor creates a {@link PolicyAnalysisResult} instance that holds maps that contain the usage of context schemas, contxt albums, events, and
- * tasks by all policies in a policy model.
+ * This constructor creates a {@link PolicyAnalysisResult} instance that holds maps that contain the usage of
+ * context schemas, contxt albums, events, and tasks by all policies in a policy model.
*
* @param policyModel the policy model to analyse
*/
@@ -60,7 +61,8 @@ public class PolicyAnalysisResult {
contextSchemaUsage.put(contextSchemaKey, new TreeSet<AxKey>());
}
- for (final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry : policyModel.getAlbums().getAlbumsMap().entrySet()) {
+ for (final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry : policyModel.getAlbums().getAlbumsMap()
+ .entrySet()) {
contextAlbumUsage.put(contextAlbumEntry.getKey(), new TreeSet<AxKey>());
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparer.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparer.java
index 545a02e89..723e8b235 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparer.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparer.java
@@ -34,10 +34,9 @@ import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
/**
- * This class compares two policy models {@link AxPolicyModel} and holds the result of that
- * comparison. It compares policy models on their keys, their context schema differences, their
- * event differences, their context album differences, their task differences, their policy
- * differences, and their key information differences.
+ * This class compares two policy models {@link AxPolicyModel} and holds the result of that comparison. It compares
+ * policy models on their keys, their context schema differences, their event differences, their context album
+ * differences, their task differences, their policy differences, and their key information differences.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -47,8 +46,7 @@ public class PolicyModelComparer {
// Comparison of context schemas
private final KeyDifference<AxArtifactKey> contextSchemasKeyDifference;
- private KeyedMapDifference<AxArtifactKey, AxContextSchema> contextSchemaComparisonResult =
- new KeyedMapDifference<>();
+ private KeyedMapDifference<AxArtifactKey, AxContextSchema> contextSchemaCompareResult = new KeyedMapDifference<>();
// Comparison of events
private final KeyDifference<AxArtifactKey> eventsKeyDifference;
@@ -86,13 +84,14 @@ public class PolicyModelComparer {
policiesKeyDifference = new KeyComparer<AxArtifactKey>().compareKeys(left.getKey(), right.getKey());
keyInformationKeyDifference = new KeyComparer<AxArtifactKey>().compareKeys(left.getKey(), right.getKey());
- contextSchemaComparisonResult = new KeyedMapComparer<AxArtifactKey, AxContextSchema>().compareMaps(
+ contextSchemaCompareResult = new KeyedMapComparer<AxArtifactKey, AxContextSchema>().compareMaps(
left.getSchemas().getSchemasMap(), right.getSchemas().getSchemasMap());
eventComparisonResult = new KeyedMapComparer<AxArtifactKey, AxEvent>().compareMaps(
left.getEvents().getEventMap(), right.getEvents().getEventMap());
contextAlbumComparisonResult = new KeyedMapComparer<AxArtifactKey, AxContextAlbum>().compareMaps(
left.getAlbums().getAlbumsMap(), right.getAlbums().getAlbumsMap());
- taskComparisonResult = new KeyedMapComparer<AxArtifactKey, AxTask>().compareMaps(left.getTasks().getTaskMap(), right.getTasks().getTaskMap());
+ taskComparisonResult = new KeyedMapComparer<AxArtifactKey, AxTask>()
+ .compareMaps(left.getTasks().getTaskMap(), right.getTasks().getTaskMap());
policyComparisonResult = new KeyedMapComparer<AxArtifactKey, AxPolicy>().compareMaps(
left.getPolicies().getPolicyMap(), right.getPolicies().getPolicyMap());
keyInfoComparisonResult = new KeyedMapComparer<AxArtifactKey, AxKeyInfo>().compareMaps(
@@ -124,7 +123,7 @@ public class PolicyModelComparer {
* @return the difference between context schemas
*/
public KeyedMapDifference<AxArtifactKey, AxContextSchema> getContextSchemaComparisonResult() {
- return contextSchemaComparisonResult;
+ return contextSchemaCompareResult;
}
/**
@@ -242,7 +241,7 @@ public class PolicyModelComparer {
builder.append("*** context schema differences ***\n");
builder.append(contextSchemasKeyDifference.asString(diffsOnly));
- builder.append(contextSchemaComparisonResult.asString(diffsOnly, keysOnly));
+ builder.append(contextSchemaCompareResult.asString(diffsOnly, keysOnly));
builder.append("*** event differences ***\n");
builder.append(eventsKeyDifference.asString(diffsOnly));
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestExceptions.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestExceptions.java
index 9c7405b97..1fa3928b5 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestExceptions.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestExceptions.java
@@ -30,6 +30,7 @@ import org.onap.policy.apex.model.policymodel.concepts.PolicyException;
import org.onap.policy.apex.model.policymodel.concepts.PolicyRuntimeException;
/**
+ * Test model exceptions.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestExceptions {
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestLogic.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestLogic.java
index 3b1fc6b8f..710b360f9 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestLogic.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestLogic.java
@@ -38,6 +38,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic;
import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
/**
+ * Test apex logic.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestLogic {
@@ -117,9 +119,8 @@ public class TestLogic {
logic.setLogicFlavour("");
fail("test shold throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "parameter \"logicFlavour\": value \"\", does not match regular expression \"[A-Za-z0-9\\-_]+\"",
- e.getMessage());
+ assertEquals("parameter \"logicFlavour\": value \"\", "
+ + "does not match regular expression \"[A-Za-z0-9\\-_]+\"", e.getMessage());
}
logic.setLogicFlavour(AxLogic.LOGIC_FLAVOUR_UNDEFINED);
@@ -152,9 +153,9 @@ public class TestLogic {
logic.clean();
final AxLogic clonedLogic = new AxLogic(logic);
- assertEquals(
- "AxLogic:(key=AxReferenceKey:(parentKeyName=LogicParentName,parentKeyVersion=0.0.1,parentLocalName=PLN,localName=LN),logicFlavour=LogicFlavour,logic=Logic)",
- clonedLogic.toString());
+ assertEquals("AxLogic:(key=AxReferenceKey:(parentKeyName=LogicParentName,parentKeyVersion=0.0.1,"
+ + "parentLocalName=PLN,localName=LN),logicFlavour=LogicFlavour,logic=Logic)",
+ clonedLogic.toString());
assertFalse(logic.hashCode() == 0);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicies.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicies.java
index b2a3911bf..1e0e88c7b 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicies.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicies.java
@@ -44,6 +44,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxStateTree;
import org.onap.policy.apex.model.policymodel.handling.TestApexPolicyModelCreator;
/**
+ * Test apex policies.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestPolicies {
@@ -63,9 +65,9 @@ public class TestPolicies {
final AxState firstState = new AxState(new AxReferenceKey(policy.getKey(), "FirstState"));
final AxState badState = new AxState(new AxReferenceKey(policy.getKey(), "BadState"));
- final AxStateOutput badSO = new AxStateOutput(badState.getKey(), AxArtifactKey.getNullKey(),
- new AxReferenceKey(policyKey, "BadNextState"));
- badState.getStateOutputs().put(badSO.getKey().getLocalName(), badSO);
+ final AxStateOutput badStateOutput = new AxStateOutput(badState.getKey(), AxArtifactKey.getNullKey(),
+ new AxReferenceKey(policyKey, "BadNextState"));
+ badState.getStateOutputs().put(badStateOutput.getKey().getLocalName(), badStateOutput);
stateMap.put(firstState.getKey().getLocalName(), firstState);
try {
@@ -231,7 +233,7 @@ public class TestPolicies {
final AxPolicy clonedPolicy = new AxPolicy(policy);
assertEquals("AxPolicy:(key=AxArtifactKey:(name=policy,version=0.0.1),template=FREEFORM,sta",
- clonedPolicy.toString().substring(0, 77));
+ clonedPolicy.toString().substring(0, 77));
assertFalse(policy.hashCode() == 0);
@@ -239,8 +241,8 @@ public class TestPolicies {
assertTrue(policy.equals(clonedPolicy));
assertFalse(policy.equals(null));
assertFalse(policy.equals("Hello"));
- assertFalse(
- policy.equals(new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState)));
+ assertFalse(policy.equals(
+ new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState)));
assertFalse(policy.equals(new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState)));
assertFalse(policy.equals(new AxPolicy(savedPolicyKey, savedTemplate, stateMapEmpty, savedFirstState)));
assertFalse(policy.equals(new AxPolicy(savedPolicyKey, savedTemplate, savedStateMap, "SomeFirstState")));
@@ -250,14 +252,14 @@ public class TestPolicies {
assertEquals(0, policy.compareTo(clonedPolicy));
assertNotEquals(0, policy.compareTo(new AxArtifactKey()));
assertNotEquals(0, policy.compareTo(null));
- assertNotEquals(0, policy
- .compareTo(new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState)));
+ assertNotEquals(0, policy.compareTo(
+ new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState)));
assertNotEquals(0,
- policy.compareTo(new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState)));
+ policy.compareTo(new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState)));
assertNotEquals(0,
- policy.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, stateMapEmpty, savedFirstState)));
+ policy.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, stateMapEmpty, savedFirstState)));
assertNotEquals(0,
- policy.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, savedStateMap, "SomeFirstState")));
+ policy.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, savedStateMap, "SomeFirstState")));
assertEquals(0, policy.compareTo(new AxPolicy(savedPolicyKey, savedTemplate, savedStateMap, savedFirstState)));
assertNotNull(policy.getKeys());
@@ -315,7 +317,7 @@ public class TestPolicies {
final AxPolicies clonedPolicies = new AxPolicies(policies);
assertEquals("AxPolicies:(key=AxArtifactKey:(name=PoliciesKey,version=0.0.",
- clonedPolicies.toString().substring(0, 60));
+ clonedPolicies.toString().substring(0, 60));
assertFalse(policies.hashCode() == 0);
@@ -359,18 +361,17 @@ public class TestPolicies {
assertNotNull(stateTree.getNextStates());
policy.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0")
- .setNextState(policy.getStateMap().get("state").getKey());
+ .setNextState(policy.getStateMap().get("state").getKey());
try {
policy.getStateTree();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "loop detected in state tree for policy policy:0.0.1 state SecondState, next state state referenced more than once",
- e.getMessage());
+ assertEquals("loop detected in state tree for policy policy:0.0.1 state SecondState, "
+ + "next state state referenced more than once", e.getMessage());
}
policy.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0")
- .setNextState(AxReferenceKey.getNullKey());
+ .setNextState(AxReferenceKey.getNullKey());
final AxState thirdState = new AxState(policy.getStateMap().get("state"));
thirdState.getKey().setLocalName("ThirdState");
@@ -378,12 +379,12 @@ public class TestPolicies {
policy.getStateMap().put("ThirdState", thirdState);
policy.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0").setNextState(thirdState.getKey());
policy.getStateMap().get("ThirdState").getStateOutputs().get("stateOutput0")
- .setNextState(AxReferenceKey.getNullKey());
+ .setNextState(AxReferenceKey.getNullKey());
stateTree = policy.getStateTree();
- final AxStateOutput ssS0Clone =
- new AxStateOutput(policy.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0"));
+ final AxStateOutput ssS0Clone = new AxStateOutput(
+ policy.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0"));
ssS0Clone.getKey().setLocalName("ssS0Clone");
policy.getStateMap().get("SecondState").getStateOutputs().put("ssS0Clone", ssS0Clone);
@@ -391,9 +392,8 @@ public class TestPolicies {
policy.getStateTree();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "loop detected in state tree for policy policy:0.0.1 state SecondState, next state ThirdState referenced more than once",
- e.getMessage());
+ assertEquals("loop detected in state tree for policy policy:0.0.1 state SecondState, "
+ + "next state ThirdState referenced more than once", e.getMessage());
}
policy.getStateMap().get("SecondState").getStateOutputs().remove("ssS0Clone");
@@ -411,9 +411,8 @@ public class TestPolicies {
policy.getStateTree();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "loop detected in state tree for policy policy:0.0.1 state ThirdState, next state SecondState referenced more than once",
- e.getMessage());
+ assertEquals("loop detected in state tree for policy policy:0.0.1 state ThirdState, "
+ + "next state SecondState referenced more than once", e.getMessage());
}
thirdState.getStateOutputs().get("stateOutput0").setNextState(AxReferenceKey.getNullKey());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicyModel.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicyModel.java
index 5df831cc7..b2803c4f8 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicyModel.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestPolicyModel.java
@@ -49,6 +49,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
import org.onap.policy.apex.model.policymodel.handling.TestApexPolicyModelCreator;
/**
+ * Test policy models.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestPolicyModel {
@@ -58,7 +60,7 @@ public class TestPolicyModel {
assertNotNull(new AxPolicyModel());
assertNotNull(new AxPolicyModel(new AxArtifactKey()));
assertNotNull(new AxPolicyModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(),
- new AxEvents(), new AxContextAlbums(), new AxTasks(), new AxPolicies()));
+ new AxEvents(), new AxContextAlbums(), new AxTasks(), new AxPolicies()));
final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1");
final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
@@ -69,8 +71,8 @@ public class TestPolicyModel {
final AxArtifactKey policiesKey = new AxArtifactKey("PoliciesKey", "0.0.1");
AxPolicyModel model = new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(tasksKey), new AxPolicies(policiesKey));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
+ new AxTasks(tasksKey), new AxPolicies(policiesKey));
model.register();
@@ -90,63 +92,59 @@ public class TestPolicyModel {
assertFalse(model.equals("Hello"));
assertFalse(model.equals(new AxPolicyModel(new AxArtifactKey())));
assertFalse(model.equals(new AxPolicyModel(AxArtifactKey.getNullKey(), new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(tasksKey), new AxPolicies(policiesKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
+ new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertFalse(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
- new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
- new AxPolicies(policiesKey))));
+ new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
+ new AxPolicies(policiesKey))));
assertFalse(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
- new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
- new AxPolicies(policiesKey))));
+ new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
+ new AxPolicies(policiesKey))));
assertFalse(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
- new AxPolicies(policiesKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(), new AxContextAlbums(albumsKey),
+ new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertFalse(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(), new AxTasks(tasksKey),
- new AxPolicies(policiesKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(),
+ new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertFalse(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(), new AxPolicies(policiesKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
+ new AxTasks(), new AxPolicies(policiesKey))));
assertFalse(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(tasksKey), new AxPolicies())));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
+ new AxTasks(tasksKey), new AxPolicies())));
assertTrue(model.equals(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(tasksKey), new AxPolicies(policiesKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
+ new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertEquals(0, model.compareTo(model));
assertEquals(0, model.compareTo(clonedModel));
assertNotEquals(0, model.compareTo(new AxArtifactKey()));
- assertNotEquals(0,
- model.compareTo(new AxPolicyModel(AxArtifactKey.getNullKey(), new AxContextSchemas(schemasKey),
+ assertNotEquals(0, model.compareTo(new AxPolicyModel(AxArtifactKey.getNullKey(),
+ new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey),
+ new AxContextAlbums(albumsKey), new AxTasks(tasksKey), new AxPolicies(policiesKey))));
+ assertNotEquals(0, model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(),
new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertNotEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
- new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
- new AxPolicies(policiesKey))));
- assertNotEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
- new AxEvents(eventsKey), new AxContextAlbums(albumsKey), new AxTasks(tasksKey),
- new AxPolicies(policiesKey))));
- assertNotEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
+ model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
+ new AxTasks(tasksKey), new AxPolicies(policiesKey))));
+ assertNotEquals(0, model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
new AxKeyInformation(keyInfoKey), new AxEvents(), new AxContextAlbums(albumsKey),
new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertNotEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(),
- new AxTasks(tasksKey), new AxPolicies(policiesKey))));
+ model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey),
+ new AxContextAlbums(), new AxTasks(tasksKey), new AxPolicies(policiesKey))));
assertNotEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(), new AxPolicies(policiesKey))));
+ model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey),
+ new AxContextAlbums(albumsKey), new AxTasks(), new AxPolicies(policiesKey))));
assertNotEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
- new AxTasks(tasksKey), new AxPolicies())));
- assertEquals(0,
- model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
+ model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey),
+ new AxContextAlbums(albumsKey), new AxTasks(tasksKey), new AxPolicies())));
+ assertEquals(0, model.compareTo(new AxPolicyModel(modelKey, new AxContextSchemas(schemasKey),
new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey),
new AxTasks(tasksKey), new AxPolicies(policiesKey))));
@@ -168,7 +166,7 @@ public class TestPolicyModel {
assertEquals(ValidationResult.VALID, result.getValidationResult());
final AxField badField = new AxField(new AxReferenceKey(model.getEvents().get("inEvent").getKey(), "BadField"),
- new AxArtifactKey("NonExistantSchema", "0.0.1"));
+ new AxArtifactKey("NonExistantSchema", "0.0.1"));
model.getEvents().get("inEvent").getParameterMap().put(badField.getKey().getLocalName(), badField);
result = new AxValidationResult();
result = model.validate(result);
@@ -180,7 +178,7 @@ public class TestPolicyModel {
assertEquals(ValidationResult.VALID, result.getValidationResult());
final AxContextAlbum badAlbum = new AxContextAlbum(new AxArtifactKey("BadAlbum", "0.0.1"), "SomeScope", true,
- new AxArtifactKey("NonExistantSchema", "0.0.1"));
+ new AxArtifactKey("NonExistantSchema", "0.0.1"));
model.getAlbums().getAlbumsMap().put(badAlbum.getKey(), badAlbum);
result = new AxValidationResult();
result = model.validate(result);
@@ -191,8 +189,8 @@ public class TestPolicyModel {
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- final AxInputField badInField =
- new AxInputField(new AxReferenceKey(model.getTasks().get("task").getKey(), "BadInField"),
+ final AxInputField badInField = new AxInputField(
+ new AxReferenceKey(model.getTasks().get("task").getKey(), "BadInField"),
new AxArtifactKey("NonExistantSchema", "0.0.1"));
model.getTasks().get("task").getInputFields().put(badInField.getKey().getLocalName(), badInField);
result = new AxValidationResult();
@@ -204,8 +202,8 @@ public class TestPolicyModel {
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- final AxOutputField badOutField =
- new AxOutputField(new AxReferenceKey(model.getTasks().get("task").getKey(), "BadOutField"),
+ final AxOutputField badOutField = new AxOutputField(
+ new AxReferenceKey(model.getTasks().get("task").getKey(), "BadOutField"),
new AxArtifactKey("NonExistantSchema", "0.0.1"));
model.getTasks().get("task").getOutputFields().put(badOutField.getKey().getLocalName(), badOutField);
result = new AxValidationResult();
@@ -218,32 +216,32 @@ public class TestPolicyModel {
assertEquals(ValidationResult.VALID, result.getValidationResult());
model.getTasks().get("task").getContextAlbumReferences()
- .add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
+ .add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
model.getTasks().get("task").getContextAlbumReferences()
- .remove(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
+ .remove(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
model.getPolicies().get("policy").getStateMap().get("state").getContextAlbumReferences()
- .add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
+ .add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
model.getPolicies().get("policy").getStateMap().get("state").getContextAlbumReferences()
- .remove(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
+ .remove(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
final AxArtifactKey savedTrigger = model.getPolicies().get("policy").getStateMap().get("state").getTrigger();
model.getPolicies().get("policy").getStateMap().get("state")
- .setTrigger(new AxArtifactKey("NonExistantEvent", "0.0.1"));
+ .setTrigger(new AxArtifactKey("NonExistantEvent", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -253,10 +251,10 @@ public class TestPolicyModel {
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- final AxArtifactKey savedDefaultTask =
- model.getPolicies().get("policy").getStateMap().get("state").getDefaultTask();
+ final AxArtifactKey savedDefaultTask = model.getPolicies().get("policy").getStateMap().get("state")
+ .getDefaultTask();
model.getPolicies().get("policy").getStateMap().get("state")
- .setDefaultTask(new AxArtifactKey("NonExistantTask", "0.0.1"));
+ .setDefaultTask(new AxArtifactKey("NonExistantTask", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -267,10 +265,10 @@ public class TestPolicyModel {
assertEquals(ValidationResult.VALID, result.getValidationResult());
// It is OK not to have TSL
- final AxTaskSelectionLogic savedTSL =
- model.getPolicies().get("policy").getStateMap().get("state").getTaskSelectionLogic();
+ final AxTaskSelectionLogic savedTaskSelectionLogic = model.getPolicies().get("policy").getStateMap()
+ .get("state").getTaskSelectionLogic();
model.getPolicies().get("policy").getStateMap().get("state")
- .setTaskSelectionLogic(new AxTaskSelectionLogic(AxReferenceKey.getNullKey()));
+ .setTaskSelectionLogic(new AxTaskSelectionLogic(AxReferenceKey.getNullKey()));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
@@ -285,71 +283,72 @@ public class TestPolicyModel {
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- model.getPolicies().get("policy").getStateMap().get("state").setTaskSelectionLogic(savedTSL);
+ model.getPolicies().get("policy").getStateMap().get("state").setTaskSelectionLogic(savedTaskSelectionLogic);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
final AxStateOutput badStateOutput = new AxStateOutput(
- new AxReferenceKey(model.getPolicies().get("policy").getStateMap().get("state").getKey(), "BadSO"),
- new AxArtifactKey("NonExistantEvent", "0.0.1"), AxReferenceKey.getNullKey());
+ new AxReferenceKey(model.getPolicies().get("policy").getStateMap().get("state").getKey(),
+ "BadSO"),
+ new AxArtifactKey("NonExistantEvent", "0.0.1"), AxReferenceKey.getNullKey());
model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs()
- .put(badStateOutput.getKey().getLocalName(), badStateOutput);
+ .put(badStateOutput.getKey().getLocalName(), badStateOutput);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs()
- .remove(badStateOutput.getKey().getLocalName());
+ .remove(badStateOutput.getKey().getLocalName());
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- final AxStateTaskReference badTR = new AxStateTaskReference(
- new AxReferenceKey(model.getPolicies().get("policy").getStateMap().get("state").getKey(),
- "NonExistantTask"),
- AxStateTaskOutputType.LOGIC, badStateOutput.getKey());
+ final AxStateTaskReference badTaskReference = new AxStateTaskReference(
+ new AxReferenceKey(model.getPolicies().get("policy").getStateMap().get("state").getKey(),
+ "NonExistantTask"),
+ AxStateTaskOutputType.LOGIC, badStateOutput.getKey());
model.getPolicies().get("policy").getStateMap().get("state").getTaskReferences()
- .put(new AxArtifactKey("NonExistantTask", "0.0.1"), badTR);
+ .put(new AxArtifactKey("NonExistantTask", "0.0.1"), badTaskReference);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
- badTR.setStateTaskOutputType(AxStateTaskOutputType.DIRECT);
+ badTaskReference.setStateTaskOutputType(AxStateTaskOutputType.DIRECT);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
model.getPolicies().get("policy").getStateMap().get("state").getTaskReferences()
- .remove(new AxArtifactKey("NonExistantTask", "0.0.1"));
+ .remove(new AxArtifactKey("NonExistantTask", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
final AxStateTaskReference tr = model.getPolicies().get("policy").getStateMap().get("state").getTaskReferences()
- .get(new AxArtifactKey("task", "0.0.1"));
+ .get(new AxArtifactKey("task", "0.0.1"));
- final String savedSOName = tr.getOutput().getLocalName();
+ final String savedStateOutputName = tr.getOutput().getLocalName();
tr.getOutput().setLocalName("NonExistantOutput");
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
- tr.getOutput().setLocalName(savedSOName);
+ tr.getOutput().setLocalName(savedStateOutputName);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- final AxStateOutput so =
- model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs().get(savedSOName);
+ final AxStateOutput so = model.getPolicies().get("policy").getStateMap().get("state").getStateOutputs()
+ .get(savedStateOutputName);
- final AxArtifactKey savedOE = so.getOutgingEvent();
+ final AxArtifactKey savedOutEvent = so.getOutgingEvent();
so.setOutgoingEvent(new AxArtifactKey("NonExistantEvent", "0.0.1"));
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
- so.setOutgoingEvent(savedOE);
+ so.setOutgoingEvent(savedOutEvent);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestState.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestState.java
index c53fff1ca..56d0a6a82 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestState.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestState.java
@@ -45,6 +45,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference;
import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
/**
+ * Test policy states.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestState {
@@ -64,7 +66,7 @@ public class TestState {
assertNotNull(new AxState());
assertNotNull(new AxState(new AxReferenceKey()));
assertNotNull(new AxState(new AxReferenceKey(), new AxArtifactKey(), soEmptyMap, ctxtEmptySet,
- new AxTaskSelectionLogic(), sflEmptyMap, new AxArtifactKey(), trEmptyMap));
+ new AxTaskSelectionLogic(), sflEmptyMap, new AxArtifactKey(), trEmptyMap));
final AxState state = new AxState();
@@ -89,25 +91,28 @@ public class TestState {
assertEquals("PolicyName:0.0.1:NULL:StateName", state.getKey().getId());
assertEquals("PolicyName:0.0.1:NULL:StateName", state.getKeys().get(0).getId());
- final AxStateOutput so0 = new AxStateOutput(new AxReferenceKey(stateKey, "SO0"), triggerKey, new AxReferenceKey());
+ final AxStateOutput so0 = new AxStateOutput(new AxReferenceKey(stateKey, "SO0"), triggerKey,
+ new AxReferenceKey());
final AxStateOutput soU = new AxStateOutput(new AxReferenceKey(stateKey, "SOU"), triggerKey, stateKeyNext);
final AxStateOutput soSame = new AxStateOutput(new AxReferenceKey(stateKey, "SOU"), triggerKey, stateKey);
final AxArtifactKey cr0 = new AxArtifactKey("ContextReference", "0.0.1");
final AxStateFinalizerLogic sfl = new AxStateFinalizerLogic(stateKey, "SFLogicName", "LogicFlavour", "Logic");
- final AxStateFinalizerLogic sflU = new AxStateFinalizerLogic(stateKey, "UnusedSFLogicName", "LogicFlavour", "Logic");
+ final AxStateFinalizerLogic sflU = new AxStateFinalizerLogic(stateKey, "UnusedSFLogicName", "LogicFlavour",
+ "Logic");
final AxStateTaskReference str0 = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR0"),
- AxStateTaskOutputType.DIRECT, so0.getKey());
+ AxStateTaskOutputType.DIRECT, so0.getKey());
final AxStateTaskReference str1 = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR1"),
- AxStateTaskOutputType.DIRECT, so0.getKey());
+ AxStateTaskOutputType.DIRECT, so0.getKey());
final AxStateTaskReference str2 = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR2"),
- AxStateTaskOutputType.LOGIC, sfl.getKey());
+ AxStateTaskOutputType.LOGIC, sfl.getKey());
final AxStateTaskReference strBadState = new AxStateTaskReference(new AxReferenceKey(stateKeyBad, "STR2"),
- AxStateTaskOutputType.LOGIC, sfl.getKey());
- final AxStateTaskReference strBadSO = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR2"),
- AxStateTaskOutputType.UNDEFINED, sfl.getKey());
- final AxStateTaskReference strBadSFL = new AxStateTaskReference(new AxReferenceKey(stateKeyBad, "STR2"),
- AxStateTaskOutputType.LOGIC, new AxReferenceKey(stateKey, "SomeSFL"));
+ AxStateTaskOutputType.LOGIC, sfl.getKey());
+ final AxStateTaskReference strBadStateOutput = new AxStateTaskReference(new AxReferenceKey(stateKey, "STR2"),
+ AxStateTaskOutputType.UNDEFINED, sfl.getKey());
+ final AxStateTaskReference strBadStateFinalizerLogic = new AxStateTaskReference(
+ new AxReferenceKey(stateKeyBad, "STR2"), AxStateTaskOutputType.LOGIC,
+ new AxReferenceKey(stateKey, "SomeSFL"));
soMap.put(so0.getKey().getLocalName(), so0);
ctxtSet.add(cr0);
@@ -358,7 +363,7 @@ public class TestState {
result = state.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- trMap.put(taskKeyBad, strBadSO);
+ trMap.put(taskKeyBad, strBadStateOutput);
result = new AxValidationResult();
result = state.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -378,7 +383,7 @@ public class TestState {
result = state.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- trMap.put(taskKeyBad, strBadSFL);
+ trMap.put(taskKeyBad, strBadStateFinalizerLogic);
result = new AxValidationResult();
result = state.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -429,22 +434,22 @@ public class TestState {
assertTrue(state.equals(clonedState));
assertFalse(state.equals(null));
assertFalse(state.equals("Hello"));
- assertFalse(state
- .equals(new AxState(new AxReferenceKey(), triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
- assertFalse(state
- .equals(new AxState(stateKey, new AxArtifactKey(), soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
- assertFalse(
- state.equals(new AxState(stateKey, triggerKey, soEmptyMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
- assertFalse(
- state.equals(new AxState(stateKey, triggerKey, soMap, ctxtEmptySet, tsl, sflMap, defTaskKey, trMap)));
+ assertFalse(state.equals(
+ new AxState(new AxReferenceKey(), triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ assertFalse(state.equals(
+ new AxState(stateKey, new AxArtifactKey(), soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ assertFalse(state.equals(
+ new AxState(stateKey, triggerKey, soEmptyMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ assertFalse(state.equals(
+ new AxState(stateKey, triggerKey, soMap, ctxtEmptySet, tsl, sflMap, defTaskKey, trMap)));
assertFalse(state.equals(new AxState(stateKey, triggerKey, soMap, ctxtSet, new AxTaskSelectionLogic(), sflMap,
- defTaskKey, trMap)));
- assertFalse(
- state.equals(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflEmptyMap, defTaskKey, trMap)));
- assertFalse(state
- .equals(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, new AxArtifactKey(), trMap)));
- assertFalse(
- state.equals(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trEmptyMap)));
+ defTaskKey, trMap)));
+ assertFalse(state.equals(
+ new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflEmptyMap, defTaskKey, trMap)));
+ assertFalse(state.equals(
+ new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, new AxArtifactKey(), trMap)));
+ assertFalse(state.equals(
+ new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trEmptyMap)));
assertTrue(state.equals(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
assertEquals(0, state.compareTo(state));
@@ -452,23 +457,23 @@ public class TestState {
assertNotEquals(0, state.compareTo(new AxArtifactKey()));
assertNotEquals(0, state.compareTo(null));
assertNotEquals(0, state.compareTo(
- new AxState(new AxReferenceKey(), triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
- assertNotEquals(0, state
- .compareTo(new AxState(stateKey, new AxArtifactKey(), soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
- assertNotEquals(0, state
- .compareTo(new AxState(stateKey, triggerKey, soEmptyMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
- assertNotEquals(0, state
- .compareTo(new AxState(stateKey, triggerKey, soMap, ctxtEmptySet, tsl, sflMap, defTaskKey, trMap)));
+ new AxState(new AxReferenceKey(), triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ assertNotEquals(0, state.compareTo(
+ new AxState(stateKey, new AxArtifactKey(), soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ assertNotEquals(0, state.compareTo(
+ new AxState(stateKey, triggerKey, soEmptyMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ assertNotEquals(0, state.compareTo(
+ new AxState(stateKey, triggerKey, soMap, ctxtEmptySet, tsl, sflMap, defTaskKey, trMap)));
assertNotEquals(0, state.compareTo(new AxState(stateKey, triggerKey, soMap, ctxtSet, new AxTaskSelectionLogic(),
- sflMap, defTaskKey, trMap)));
- assertNotEquals(0, state
- .compareTo(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflEmptyMap, defTaskKey, trMap)));
- assertNotEquals(0, state
- .compareTo(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, new AxArtifactKey(), trMap)));
- assertNotEquals(0, state
- .compareTo(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trEmptyMap)));
- assertEquals(0,
- state.compareTo(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
+ sflMap, defTaskKey, trMap)));
+ assertNotEquals(0, state.compareTo(
+ new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflEmptyMap, defTaskKey, trMap)));
+ assertNotEquals(0, state.compareTo(
+ new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, new AxArtifactKey(), trMap)));
+ assertNotEquals(0, state.compareTo(
+ new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trEmptyMap)));
+ assertEquals(0, state
+ .compareTo(new AxState(stateKey, triggerKey, soMap, ctxtSet, tsl, sflMap, defTaskKey, trMap)));
assertNotNull(state.getKeys());
}
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateOutput.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateOutput.java
index 5306b7642..90b486053 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateOutput.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateOutput.java
@@ -35,6 +35,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput;
/**
+ * Test state outputs.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestStateOutput {
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateTaskReference.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateTaskReference.java
index eeaf19e07..90c7001b8 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateTaskReference.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestStateTaskReference.java
@@ -36,6 +36,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType;
import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference;
/**
+ * Test state task references.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestStateTaskReference {
@@ -44,15 +46,14 @@ public class TestStateTaskReference {
public void testStateTaskReference() {
assertNotNull(new AxStateTaskReference());
assertNotNull(new AxStateTaskReference(new AxReferenceKey()));
- assertNotNull(
- new AxStateTaskReference(new AxReferenceKey(), AxStateTaskOutputType.UNDEFINED, new AxReferenceKey()));
+ assertNotNull(new AxStateTaskReference(new AxReferenceKey(), AxStateTaskOutputType.UNDEFINED,
+ new AxReferenceKey()));
assertNotNull(new AxStateTaskReference(new AxReferenceKey(), new AxArtifactKey(),
- AxStateTaskOutputType.UNDEFINED, new AxReferenceKey()));
+ AxStateTaskOutputType.UNDEFINED, new AxReferenceKey()));
AxStateTaskReference stRef = new AxStateTaskReference();
AxReferenceKey stRefKey = new AxReferenceKey("StateParent", "0.0.1", "SOState", "SOName");
- AxReferenceKey soKey = new AxReferenceKey("StateParent", "0.0.1", "SOState", "STRef0");
try {
stRef.setKey(null);
@@ -86,6 +87,7 @@ public class TestStateTaskReference {
assertEquals("output may not be null", e.getMessage());
}
+ AxReferenceKey soKey = new AxReferenceKey("StateParent", "0.0.1", "SOState", "STRef0");
stRef.setOutput(soKey);
assertEquals(soKey, stRef.getOutput());
@@ -134,25 +136,25 @@ public class TestStateTaskReference {
assertTrue(stRef.equals(clonedStRef));
assertFalse(stRef.equals(null));
assertFalse(stRef.equals("Hello"));
- assertFalse(stRef
- .equals(new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey)));
+ assertFalse(stRef.equals(
+ new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey)));
assertFalse(stRef.equals(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.DIRECT, soKey)));
- assertFalse(
- stRef.equals(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, new AxReferenceKey())));
+ assertFalse(stRef
+ .equals(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, new AxReferenceKey())));
assertTrue(stRef.equals(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, soKey)));
assertNotNull(new AxStateTaskReference(new AxReferenceKey(), new AxArtifactKey(),
- AxStateTaskOutputType.UNDEFINED, new AxReferenceKey()));
+ AxStateTaskOutputType.UNDEFINED, new AxReferenceKey()));
assertEquals(0, stRef.compareTo(stRef));
assertEquals(0, stRef.compareTo(clonedStRef));
assertNotEquals(0, stRef.compareTo(new AxArtifactKey()));
assertNotEquals(0, stRef.compareTo(null));
- assertNotEquals(0, stRef
- .compareTo(new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey)));
+ assertNotEquals(0, stRef.compareTo(
+ new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey)));
assertNotEquals(0, stRef.compareTo(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.DIRECT, soKey)));
- assertNotEquals(0,
- stRef.compareTo(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, new AxReferenceKey())));
+ assertNotEquals(0, stRef.compareTo(
+ new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, new AxReferenceKey())));
assertEquals(0, stRef.compareTo(new AxStateTaskReference(stRefKey, AxStateTaskOutputType.LOGIC, soKey)));
assertNotNull(stRef.getKeys());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTaskParameter.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTaskParameter.java
index ff6ab42b8..4eb2c4232 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTaskParameter.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTaskParameter.java
@@ -35,6 +35,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter;
/**
+ * Test task parameters.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestTaskParameter {
@@ -89,9 +91,8 @@ public class TestTaskParameter {
par.clean();
final AxTaskParameter clonedPar = new AxTaskParameter(par);
- assertEquals(
- "AxTaskParameter:(key=AxReferenceKey:(parentKeyName=ParParentName,parentKeyVersion=0.0.1,parentLocalName=PLN,localName=LN),defaultValue=DefaultValue)",
- clonedPar.toString());
+ assertEquals("AxTaskParameter:(key=AxReferenceKey:(parentKeyName=ParParentName,parentKeyVersion=0.0.1,"
+ + "parentLocalName=PLN,localName=LN),defaultValue=DefaultValue)", clonedPar.toString());
assertFalse(par.hashCode() == 0);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTasks.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTasks.java
index 78691accb..4f6292f04 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTasks.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TestTasks.java
@@ -43,6 +43,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter;
import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
/**
+ * Test policy tasks.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestTasks {
@@ -302,7 +304,7 @@ public class TestTasks {
final AxTasks clonedTasks = new AxTasks(tasks);
assertEquals("AxTasks:(key=AxArtifactKey:(name=TasksKey,version=0.0.1),tas",
- clonedTasks.toString().substring(0, 60));
+ clonedTasks.toString().substring(0, 60));
assertFalse(tasks.hashCode() == 0);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModel.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModel.java
index 5dfeede0a..6c4fd5174 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModel.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModel.java
@@ -39,6 +39,11 @@ public class TestApexPolicyModel {
private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
+ /**
+ * Set up the policy model tests.
+ *
+ * @throws Exception on setup errors
+ */
@Before
public void setup() throws Exception {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
@@ -65,7 +70,6 @@ public class TestApexPolicyModel {
assertTrue(result.toString().equals(OBSERVATION_MODEL_STRING));
}
-
@Test
public void testApexModelVaidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
@@ -85,17 +89,17 @@ public class TestApexPolicyModel {
}
@Test
- public void testModelWriteReadXML() throws Exception {
+ public void testModelWriteReadXml() throws Exception {
testApexModel.testApexModelWriteReadXml();
}
@Test
- public void testModelWriteReadJSON() throws Exception {
+ public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
@Test
- public void testModelWriteReadJPA() throws Exception {
+ public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
DaoParameters.setPersistenceUnit("DAOTest");
@@ -105,35 +109,71 @@ public class TestApexPolicyModel {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
- private static final String OBSERVATION_MODEL_STRING =
- "\n" + "***observations noted during validation of model***\n"
- + "AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):org.onap.policy.apex.model.policymodel.concepts.AxState:OBSERVATION:state output stateOutput0 is not used directly by any task\n"
+ private static final String OBSERVATION_MODEL_STRING = "\n"
+ + "***observations noted during validation of model***\n"
+ + "AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,"
+ + "localName=state):org.onap.policy.apex.model.policymodel.concepts.AxState:OBSERVATION:"
+ + "state output stateOutput0 is not used directly by any task\n"
+ "********************************";
private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=policy,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicy:WARNING:state AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=anotherState) is not referenced in the policy execution tree\n"
- + "********************************";
+ + "AxArtifactKey:(name=policy,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicy:WARNING:state AxReferenceKey:"
+ + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=anotherState) "
+ + "is not referenced in the policy execution tree\n" + "********************************";
private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
- + "AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:task output field AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false) for task task:0.0.1 not in output event outEvent0:0.0.1\n"
- + "AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:task output field AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false) for task task:0.0.1 not in output event outEvent0:0.0.1\n"
- + "********************************";
+ + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
+ + "AxReferenceKey:"
+ + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):"
+ + "org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "task output field AxOutputField:(key=AxReferenceKey:"
+ + "(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR0),"
+ + "fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false) for task "
+ + "task:0.0.1 not in output event outEvent0:0.0.1\n" + "AxReferenceKey:"
+ + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):"
+ + "org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "task output field AxOutputField:(key=AxReferenceKey:"
+ + "(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR1),"
+ + "fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false) for task "
+ + "task:0.0.1 not in output event outEvent0:0.0.1\n" + "********************************";
private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:keyInfoMap may not be empty\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Schemas,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Events,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Albums,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Policies,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel_Schemas,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:contextSchemas may not be empty\n"
- + "AxArtifactKey:(name=policyModel_Events,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:eventMap may not be empty\n"
- + "AxArtifactKey:(name=policyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty\n"
- + "AxArtifactKey:(name=policyModel_Tasks,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxTasks:INVALID:taskMap may not be empty\n"
- + "AxArtifactKey:(name=policyModel_Policies,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicies:INVALID:policyMap may not be empty\n"
- + "********************************";
+ + "AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1):"
+ + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:"
+ + "keyInfoMap may not be empty\n" + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel_Schemas,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel_Events,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel_Albums,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=policyModel_Policies,version=0.0.1)\n"
+ + "AxArtifactKey:(name=policyModel_Schemas,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
+ + "contextSchemas may not be empty\n" + "AxArtifactKey:(name=policyModel_Events,version=0.0.1):"
+ + "org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:eventMap may not be empty\n"
+ + "AxArtifactKey:(name=policyModel_Albums,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty\n"
+ + "AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxTasks:INVALID:taskMap may not be empty\n"
+ + "AxArtifactKey:(name=policyModel_Policies,version=0.0.1)"
+ + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicies:INVALID:policyMap may not be empty\n"
+ + "********************************";
}
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModelCreator.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModelCreator.java
index cf2bb6524..cbcecc589 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModelCreator.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestApexPolicyModelCreator.java
@@ -52,20 +52,22 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
/**
+ * Model creator for model tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicyModel> {
@Override
public AxPolicyModel getModel() {
- final AxContextSchema schema0 =
- new AxContextSchema(new AxArtifactKey("eventContextItem0", "0.0.1"), "Java", "java.lang.String");
- final AxContextSchema schema1 =
- new AxContextSchema(new AxArtifactKey("eventContextItem1", "0.0.1"), "Java", "java.lang.Long");
+ final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("eventContextItem0", "0.0.1"), "Java",
+ "java.lang.String");
+ final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("eventContextItem1", "0.0.1"), "Java",
+ "java.lang.Long");
final AxContextSchema schema2 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000");
+ "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000");
final AxContextSchema schema3 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A");
+ "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A");
final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
schemas.getSchemasMap().put(schema0.getKey(), schema0);
@@ -73,39 +75,39 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
schemas.getSchemasMap().put(schema2.getKey(), schema2);
schemas.getSchemasMap().put(schema3.getKey(), schema3);
- final AxContextAlbum album0 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema3.getKey());
- final AxContextAlbum album1 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false, schema2.getKey());
+ final AxContextAlbum album0 = new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION",
+ true, schema3.getKey());
+ final AxContextAlbum album1 = new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false,
+ schema2.getKey());
final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
albums.getAlbumsMap().put(album0.getKey(), album0);
albums.getAlbumsMap().put(album1.getKey(), album1);
final AxEvent inEvent = new AxEvent(new AxArtifactKey("inEvent", "0.0.1"),
- "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
+ "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
inEvent.getParameterMap().put("IEPAR0",
- new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR0"), schema0.getKey()));
inEvent.getParameterMap().put("IEPAR1",
- new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR1"), schema1.getKey()));
final AxEvent outEvent0 = new AxEvent(new AxArtifactKey("outEvent0", "0.0.1"),
- "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
+ "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
outEvent0.getParameterMap().put("OE0PAR0",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR0"), schema0.getKey()));
outEvent0.getParameterMap().put("OE0PAR1",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR1"), schema1.getKey()));
outEvent0.getParameterMap().put("OE1PAR0",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR0"), schema0.getKey()));
outEvent0.getParameterMap().put("OE1PAR1",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR1"), schema1.getKey()));
final AxEvent outEvent1 = new AxEvent(new AxArtifactKey("outEvent1", "0.0.1"),
- "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
+ "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
outEvent1.getParameterMap().put("OE1PAR0",
- new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR0"), schema0.getKey()));
outEvent1.getParameterMap().put("OE1PAR1",
- new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR1"), schema1.getKey()));
final AxEvents events = new AxEvents(new AxArtifactKey("events", "0.0.1"));
events.getEventMap().put(inEvent.getKey(), inEvent);
@@ -116,37 +118,37 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
for (final AxField field : inEvent.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "inputFields", field.getKey().getLocalName());
+ "inputFields", field.getKey().getLocalName());
final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
task.getInputFields().put(inputField.getKey().getLocalName(), inputField);
}
for (final AxField field : outEvent0.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFields", field.getKey().getLocalName());
+ "outputFields", field.getKey().getLocalName());
final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
for (final AxField field : outEvent1.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFields", field.getKey().getLocalName());
+ "outputFields", field.getKey().getLocalName());
final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
- final AxTaskParameter taskPar0 =
- new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter0"), "Task parameter 0 value");
- final AxTaskParameter taskPar1 =
- new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter1"), "Task parameter 1 value");
+ final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter0"),
+ "Task parameter 0 value");
+ final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter1"),
+ "Task parameter 1 value");
task.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0);
task.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1);
task.getContextAlbumReferences().add(album0.getKey());
task.getContextAlbumReferences().add(album1.getKey());
- final AxTaskLogic taskLogic =
- new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogic"), "MVEL", "Some task logic");
+ final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogic"), "MVEL",
+ "Some task logic");
task.setTaskLogic(taskLogic);
final AxTasks tasks = new AxTasks(new AxArtifactKey("tasks", "0.0.1"));
@@ -157,7 +159,7 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
final AxState state = new AxState(new AxReferenceKey(policy.getKey(), "state"));
final AxTaskSelectionLogic taskSelectionLogic = new AxTaskSelectionLogic(
- new AxReferenceKey(state.getKey(), "taskSelectionLogic"), "MVEL", "Some TS logic ");
+ new AxReferenceKey(state.getKey(), "taskSelectionLogic"), "MVEL", "Some TS logic ");
state.setTrigger(inEvent.getKey());
state.getContextAlbumReferences().add(album0.getKey());
@@ -166,12 +168,12 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
state.setDefaultTask(task.getKey());
final AxStateOutput stateOutput0 = new AxStateOutput(new AxReferenceKey(state.getKey(), "stateOutput0"),
- outEvent0.getKey(), AxReferenceKey.getNullKey());
+ outEvent0.getKey(), AxReferenceKey.getNullKey());
state.getStateOutputs().put(stateOutput0.getKey().getLocalName(), stateOutput0);
- final AxStateTaskReference stateTaskReference =
- new AxStateTaskReference(new AxReferenceKey(state.getKey(), task.getKey().getName()),
- AxStateTaskOutputType.DIRECT, stateOutput0.getKey());
+ final AxStateTaskReference stateTaskReference = new AxStateTaskReference(
+ new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.DIRECT,
+ stateOutput0.getKey());
state.getTaskReferences().put(task.getKey(), stateTaskReference);
@@ -203,15 +205,20 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
return policyModel;
}
+ /**
+ * Gets another policy model.
+ *
+ * @return the model
+ */
public AxPolicyModel getAnotherModel() {
- final AxContextSchema schema0 =
- new AxContextSchema(new AxArtifactKey("eventContextItemA0", "0.0.1"), "Java", "java.lang.String");
- final AxContextSchema schema1 =
- new AxContextSchema(new AxArtifactKey("eventContextItemA1", "0.0.1"), "Java", "java.lang.Long");
+ final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("eventContextItemA0", "0.0.1"), "Java",
+ "java.lang.String");
+ final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("eventContextItemA1", "0.0.1"), "Java",
+ "java.lang.Long");
final AxContextSchema schema2 = new AxContextSchema(new AxArtifactKey("StringTypeA", "0.0.1"), "Java",
- "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000");
+ "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000");
final AxContextSchema schema3 = new AxContextSchema(new AxArtifactKey("MapTypeA", "0.0.1"), "Java",
- "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A");
+ "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A");
final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemasA", "0.0.1"));
schemas.getSchemasMap().put(schema0.getKey(), schema0);
@@ -219,39 +226,39 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
schemas.getSchemasMap().put(schema2.getKey(), schema2);
schemas.getSchemasMap().put(schema3.getKey(), schema3);
- final AxContextAlbum album0 =
- new AxContextAlbum(new AxArtifactKey("contextAlbumA0", "0.0.1"), "APPLICATION", true, schema3.getKey());
- final AxContextAlbum album1 =
- new AxContextAlbum(new AxArtifactKey("contextAlbumA1", "0.0.1"), "GLOBAL", false, schema2.getKey());
+ final AxContextAlbum album0 = new AxContextAlbum(new AxArtifactKey("contextAlbumA0", "0.0.1"), "APPLICATION",
+ true, schema3.getKey());
+ final AxContextAlbum album1 = new AxContextAlbum(new AxArtifactKey("contextAlbumA1", "0.0.1"), "GLOBAL", false,
+ schema2.getKey());
final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("contextA", "0.0.1"));
albums.getAlbumsMap().put(album0.getKey(), album0);
albums.getAlbumsMap().put(album1.getKey(), album1);
final AxEvent inEvent = new AxEvent(new AxArtifactKey("inEventA", "0.0.1"),
- "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
+ "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
inEvent.getParameterMap().put("IEPARA0",
- new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA0"), schema0.getKey()));
inEvent.getParameterMap().put("IEPARA1",
- new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA1"), schema1.getKey()));
final AxEvent outEvent0 = new AxEvent(new AxArtifactKey("outEventA0", "0.0.1"),
- "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
+ "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
outEvent0.getParameterMap().put("OE0PARA0",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA0"), schema0.getKey()));
outEvent0.getParameterMap().put("OE0PARA1",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA1"), schema1.getKey()));
outEvent0.getParameterMap().put("OE1PARA0",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA0"), schema0.getKey()));
outEvent0.getParameterMap().put("OE1PARA1",
- new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA1"), schema1.getKey()));
final AxEvent outEvent1 = new AxEvent(new AxArtifactKey("outEventA1", "0.0.1"),
- "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
+ "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
outEvent1.getParameterMap().put("OE1PARA0",
- new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA0"), schema0.getKey()));
+ new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA0"), schema0.getKey()));
outEvent1.getParameterMap().put("OE1PARA1",
- new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA1"), schema1.getKey()));
+ new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA1"), schema1.getKey()));
final AxEvents events = new AxEvents(new AxArtifactKey("eventsA", "0.0.1"));
events.getEventMap().put(inEvent.getKey(), inEvent);
@@ -262,37 +269,37 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
for (final AxField field : inEvent.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "inputFieldsA", field.getKey().getLocalName());
+ "inputFieldsA", field.getKey().getLocalName());
final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
task.getInputFields().put(inputField.getKey().getLocalName(), inputField);
}
for (final AxField field : outEvent0.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFieldsA", field.getKey().getLocalName());
+ "outputFieldsA", field.getKey().getLocalName());
final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
for (final AxField field : outEvent1.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFieldsA", field.getKey().getLocalName());
+ "outputFieldsA", field.getKey().getLocalName());
final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
- final AxTaskParameter taskPar0 =
- new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA0"), "Task parameter 0 value");
- final AxTaskParameter taskPar1 =
- new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA1"), "Task parameter 1 value");
+ final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA0"),
+ "Task parameter 0 value");
+ final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA1"),
+ "Task parameter 1 value");
task.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0);
task.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1);
task.getContextAlbumReferences().add(album0.getKey());
task.getContextAlbumReferences().add(album1.getKey());
- final AxTaskLogic taskLogic =
- new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogicA"), "MVEL", "Some task logic");
+ final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogicA"), "MVEL",
+ "Some task logic");
task.setTaskLogic(taskLogic);
final AxTasks tasks = new AxTasks(new AxArtifactKey("tasksA", "0.0.1"));
@@ -303,7 +310,7 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
final AxState state = new AxState(new AxReferenceKey(policy.getKey(), "stateA"));
final AxTaskSelectionLogic taskSelectionLogic = new AxTaskSelectionLogic(
- new AxReferenceKey(state.getKey(), "taskSelectionLogicA"), "MVEL", "Some TS logic ");
+ new AxReferenceKey(state.getKey(), "taskSelectionLogicA"), "MVEL", "Some TS logic ");
state.setTrigger(inEvent.getKey());
state.getContextAlbumReferences().add(album0.getKey());
@@ -312,12 +319,12 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
state.setDefaultTask(task.getKey());
final AxStateOutput stateOutput0 = new AxStateOutput(new AxReferenceKey(state.getKey(), "stateOutputA0"),
- outEvent0.getKey(), AxReferenceKey.getNullKey());
+ outEvent0.getKey(), AxReferenceKey.getNullKey());
state.getStateOutputs().put(stateOutput0.getKey().getLocalName(), stateOutput0);
- final AxStateTaskReference stateTaskReference =
- new AxStateTaskReference(new AxReferenceKey(state.getKey(), task.getKey().getName()),
- AxStateTaskOutputType.DIRECT, stateOutput0.getKey());
+ final AxStateTaskReference stateTaskReference = new AxStateTaskReference(
+ new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.DIRECT,
+ stateOutput0.getKey());
state.getTaskReferences().put(task.getKey(), stateTaskReference);
@@ -362,12 +369,12 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
final AxState state = policyModel.getPolicies().get("policy").getStateMap().get("state");
final AxTask task = policyModel.getTasks().get("task");
- final AxStateFinalizerLogic stateFinalizerLogic =
- new AxStateFinalizerLogic(new AxReferenceKey(state.getKey(), "SFL"), "MVEL", "Some SF logic ");
+ final AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic(
+ new AxReferenceKey(state.getKey(), "SFL"), "MVEL", "Some SF logic ");
state.getStateFinalizerLogicMap().put(stateFinalizerLogic.getKey().getLocalName(), stateFinalizerLogic);
- final AxStateTaskReference stateTaskReference =
- new AxStateTaskReference(new AxReferenceKey(state.getKey(), task.getKey().getName()),
- AxStateTaskOutputType.LOGIC, stateFinalizerLogic.getKey());
+ final AxStateTaskReference stateTaskReference = new AxStateTaskReference(
+ new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.LOGIC,
+ stateFinalizerLogic.getKey());
state.getTaskReferences().put(task.getKey(), stateTaskReference);
@@ -378,8 +385,8 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
public AxPolicyModel getWarningModel() {
final AxPolicyModel policyModel = getModel();
- final AxState anotherState =
- new AxState(new AxReferenceKey(new AxArtifactKey("policy", "0.0.1"), "anotherState"));
+ final AxState anotherState = new AxState(
+ new AxReferenceKey(new AxArtifactKey("policy", "0.0.1"), "anotherState"));
final AxEvent inEvent = policyModel.getEvents().getEventMap().get(new AxArtifactKey("inEvent", "0.0.1"));
final AxEvent outEvent0 = policyModel.getEvents().getEventMap().get(new AxArtifactKey("outEvent0", "0.0.1"));
@@ -388,44 +395,44 @@ public class TestApexPolicyModelCreator implements TestApexModelCreator<AxPolicy
for (final AxField field : inEvent.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(anotherTask.getKey().getName(),
- anotherTask.getKey().getVersion(), "inputFields", field.getKey().getLocalName());
+ anotherTask.getKey().getVersion(), "inputFields", field.getKey().getLocalName());
final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
anotherTask.getInputFields().put(inputField.getKey().getLocalName(), inputField);
}
for (final AxField field : outEvent0.getFields()) {
final AxReferenceKey fieldkey = new AxReferenceKey(anotherTask.getKey().getName(),
- anotherTask.getKey().getVersion(), "outputFields", field.getKey().getLocalName());
+ anotherTask.getKey().getVersion(), "outputFields", field.getKey().getLocalName());
final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
anotherTask.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
}
final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter0"),
- "Task parameter 0 value");
+ "Task parameter 0 value");
final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter1"),
- "Task parameter 1 value");
+ "Task parameter 1 value");
anotherTask.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0);
anotherTask.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1);
- final AxTaskLogic taskLogic =
- new AxTaskLogic(new AxReferenceKey(anotherTask.getKey(), "taskLogic"), "MVEL", "Some task logic");
+ final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(anotherTask.getKey(), "taskLogic"), "MVEL",
+ "Some task logic");
anotherTask.setTaskLogic(taskLogic);
policyModel.getTasks().getTaskMap().put(anotherTask.getKey(), anotherTask);
- final AxStateOutput anotherStateOutput0 =
- new AxStateOutput(new AxReferenceKey(anotherState.getKey(), "stateOutput0"), outEvent0.getKey(),
+ final AxStateOutput anotherStateOutput0 = new AxStateOutput(
+ new AxReferenceKey(anotherState.getKey(), "stateOutput0"), outEvent0.getKey(),
AxReferenceKey.getNullKey());
anotherState.setTrigger(inEvent.getKey());
anotherState.getStateOutputs().put(anotherStateOutput0.getKey().getLocalName(), anotherStateOutput0);
anotherState.setDefaultTask(anotherTask.getKey());
- final AxStateTaskReference anotherStateTaskReference =
- new AxStateTaskReference(new AxReferenceKey(anotherState.getKey(), anotherTask.getKey().getName()),
+ final AxStateTaskReference anotherStateTaskReference = new AxStateTaskReference(
+ new AxReferenceKey(anotherState.getKey(), anotherTask.getKey().getName()),
AxStateTaskOutputType.DIRECT, anotherStateOutput0.getKey());
anotherState.getTaskReferences().put(anotherTask.getKey(), anotherStateTaskReference);
policyModel.getPolicies().getPolicyMap().get(new AxArtifactKey("policy", "0.0.1")).getStateMap()
- .put(anotherState.getKey().getLocalName(), anotherState);
+ .put(anotherState.getKey().getLocalName(), anotherState);
policyModel.getKeyInformation().generateKeyInfo(policyModel);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyLogicReader.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyLogicReader.java
index 446cbeed8..bb16c90d1 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyLogicReader.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyLogicReader.java
@@ -31,6 +31,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxLogic;
import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader;
/**
+ * Logic reader for policy tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestPolicyLogicReader {
@@ -51,9 +53,8 @@ public class TestPolicyLogicReader {
new AxLogic(logicKey, "FunkyLogic", plReader);
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "logic not found for logic \"somewhere/over/the/rainbow/funkylogic/FunkyDefaultLogic.funkylogic\"",
- e.getMessage());
+ assertEquals("logic not found for logic "
+ + "\"somewhere/over/the/rainbow/funkylogic/FunkyDefaultLogic.funkylogic\"", e.getMessage());
}
plReader.setDefaultLogic(null);
@@ -61,9 +62,9 @@ public class TestPolicyLogicReader {
new AxLogic(logicKey, "FunkyLogic", plReader);
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "logic not found for logic \"somewhere/over/the/rainbow/funkylogic/LogicParent_LogicInstanceName.funkylogic\"",
- e.getMessage());
+ assertEquals("logic not found for logic "
+ + "\"somewhere/over/the/rainbow/funkylogic/LogicParent_LogicInstanceName.funkylogic\"",
+ e.getMessage());
}
logicKey.setParentLocalName("LogicParentLocalName");
@@ -71,9 +72,8 @@ public class TestPolicyLogicReader {
new AxLogic(logicKey, "FunkyLogic", plReader);
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "logic not found for logic \"somewhere/over/the/rainbow/funkylogic/LogicParent_LogicParentLocalName_LogicInstanceName.funkylogic\"",
- e.getMessage());
+ assertEquals("logic not found for logic " + "\"somewhere/over/the/rainbow/funkylogic/"
+ + "LogicParent_LogicParentLocalName_LogicInstanceName.funkylogic\"", e.getMessage());
}
plReader.setLogicPackage("path.to.apex.logic");
@@ -98,7 +98,7 @@ public class TestPolicyLogicReader {
try {
final AxLogic logic = new AxLogic(logicKey, "JAVA", plReader);
assertEquals("somewhere.over.the.rainbow.java.LogicParent_LogicParentLocalName_LogicInstanceName",
- logic.getLogic());
+ logic.getLogic());
} catch (final Exception e) {
fail("test should not throw an exception");
}
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyModelMerger.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyModelMerger.java
index 92d1dc32a..8f717a234 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyModelMerger.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/TestPolicyModelMerger.java
@@ -31,6 +31,8 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.handling.PolicyModelMerger;
/**
+ * Test model merging.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestPolicyModelMerger {
@@ -41,8 +43,8 @@ public class TestPolicyModelMerger {
AxPolicyModel rightPolicyModel = new TestApexPolicyModelCreator().getModel();
try {
- final AxPolicyModel mergedPolicyModel =
- PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false);
+ final AxPolicyModel mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel,
+ rightPolicyModel, false);
assertEquals(leftPolicyModel, mergedPolicyModel);
assertEquals(rightPolicyModel, mergedPolicyModel);
} catch (final ApexModelException e) {
@@ -66,8 +68,8 @@ public class TestPolicyModelMerger {
leftPolicyModel.getKeyInformation().generateKeyInfo(leftPolicyModel);
try {
- final AxPolicyModel mergedPolicyModel =
- PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, true);
+ final AxPolicyModel mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel,
+ rightPolicyModel, true);
assertNotNull(mergedPolicyModel);
} catch (final ApexModelException e) {
fail("test should not throw an exception");
@@ -90,8 +92,8 @@ public class TestPolicyModelMerger {
rightPolicyModel.getKeyInformation().generateKeyInfo(rightPolicyModel);
try {
- final AxPolicyModel mergedPolicyModel =
- PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, false);
+ final AxPolicyModel mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel,
+ rightPolicyModel, false);
assertNotNull(mergedPolicyModel);
} catch (final ApexModelException e) {
fail("test should not throw an exception");
@@ -99,8 +101,8 @@ public class TestPolicyModelMerger {
rightPolicyModel = new TestApexPolicyModelCreator().getAnotherModel();
try {
- final AxPolicyModel mergedPolicyModel =
- PolicyModelMerger.getMergedPolicyModel(leftPolicyModel, rightPolicyModel, true);
+ final AxPolicyModel mergedPolicyModel = PolicyModelMerger.getMergedPolicyModel(leftPolicyModel,
+ rightPolicyModel, true);
assertNotNull(mergedPolicyModel);
} catch (final ApexModelException e) {
fail("test should not throw an exception");
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/PolicyModelValidator.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/PolicyModelValidator.java
index 4610a827e..9cee85491 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/PolicyModelValidator.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/utils/PolicyModelValidator.java
@@ -28,11 +28,19 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+/**
+ * Main class to run the policy model validator.
+ */
public class PolicyModelValidator {
+ /**
+ * Main method.
+ * @param args the command line arguments
+ * @throws ApexModelException on errors on the apex model
+ * @throws FileNotFoundException on file find failures
+ */
public static void main(final String[] args) throws ApexModelException, FileNotFoundException {
- final ApexModelReader<AxPolicyModel> policyModelReader =
- new ApexModelReader<AxPolicyModel>(AxPolicyModel.class);
-
+ final ApexModelReader<AxPolicyModel> policyModelReader = new ApexModelReader<AxPolicyModel>(
+ AxPolicyModel.class);
final AxPolicyModel policyModel = policyModelReader.read(new FileInputStream(args[0]));
final AxValidationResult result = policyModel.validate(new AxValidationResult());