summaryrefslogtreecommitdiffstats
path: root/model/context-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/context-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/context-model')
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java54
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java81
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java6
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java30
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java38
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextAlbums.java24
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextModel.java44
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextSchemas.java23
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModel.java58
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparison.java93
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java18
11 files changed, 276 insertions, 193 deletions
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
index 32555662e..564e2d48c 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
@@ -46,22 +46,22 @@ import org.onap.policy.apex.model.utilities.Assertions;
/**
* This class is used to define an album of context.
- * <p>
- * A context album is a distributed map of context that will be distributed across all process instances that require
+ *
+ * <p>A context album is a distributed map of context that will be distributed across all process instances that require
* access to it. This class defines the schema (structure) of the items in the context album, whether the items on the
* context album are writable or not, and what the scope of the context album is.
- * <p>
- * The structure of items (objects) the context album is defined as a schema, which is understood by whatever schema
+ *
+ * <p>The structure of items (objects) the context album is defined as a schema, which is understood by whatever schema
* implementation is being used for the context album.
- * <p>
- * The scope of a context album is a string field, understood by whatever distribution mechanism is being used for the
- * context album. The distribution mechanism uses the scope of the context album to decide to which executable entities
- * a given context album is distributed.
- * <p>
- * The writable flag on a context album defines whether users of a context album can write to the context album or just
- * read objects from the context album.
- * <p>
- * Validation checks that the album key and the context schema key are not null and that the scope field is not
+ *
+ * <p>The scope of a context album is a string field, understood by whatever distribution mechanism is being used for
+ * the context album. The distribution mechanism uses the scope of the context album to decide to which executable
+ * entities a given context album is distributed.
+ *
+ * <p>The writable flag on a context album defines whether users of a context album can write to the context album or
+ * just read objects from the context album.
+ *
+ * <p>Validation checks that the album key and the context schema key are not null and that the scope field is not
* undefined and matches the regular expression SCOPE_REGEXP.
*/
@Entity
@@ -69,8 +69,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexContextAlbum", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxContextAlbum", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = { "key", "scope", "isWritable", "itemSchema" })
+@XmlType(name = "AxContextAlbum", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "scope", "isWritable", "itemSchema" })
public class AxContextAlbum extends AxConcept {
private static final String SCOPE_STRING = "scope";
@@ -113,8 +113,8 @@ public class AxContextAlbum extends AxConcept {
/**
* The default constructor creates a context album with a null artifact key. The scope of the context album is set
- * as SCOPE_UNDEFINED, the album is writable, and the artifact key of the context schema is set to the null
- * artifact key.
+ * as SCOPE_UNDEFINED, the album is writable, and the artifact key of the context schema is set to the null artifact
+ * key.
*/
public AxContextAlbum() {
this(new AxArtifactKey());
@@ -124,7 +124,7 @@ public class AxContextAlbum extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -134,8 +134,8 @@ public class AxContextAlbum extends AxConcept {
/**
* The keyed constructor creates a context album with the specified artifact key. The scope of the context album is
- * set as SCOPE_UNDEFINED, the album is writable, and the artifact key of the context schema is set to the
- * null artifact key.
+ * set as SCOPE_UNDEFINED, the album is writable, and the artifact key of the context schema is set to the null
+ * artifact key.
*
* @param key the key of the context album
*/
@@ -152,7 +152,7 @@ public class AxContextAlbum extends AxConcept {
* @param itemSchema the artifact key of the context schema to use for this context album
*/
public AxContextAlbum(final AxArtifactKey key, final String scope, final boolean isWritable,
- final AxArtifactKey itemSchema) {
+ final AxArtifactKey itemSchema) {
super();
Assertions.argumentNotNull(key, "key may not be null");
Assertions.argumentNotNull(scope, "scope may not be null");
@@ -264,26 +264,26 @@ public class AxContextAlbum 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 (scope.replaceAll("\\s+$", "").length() == 0 || scope.equals(SCOPE_UNDEFINED)) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "scope is not defined"));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "scope is not defined"));
}
try {
Assertions.validateStringParameter(SCOPE_STRING, scope, SCOPE_REGEXP);
} catch (final IllegalArgumentException e) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "scope invalid-" + e.getMessage()));
+ "scope invalid-" + e.getMessage()));
}
if (itemSchema.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "itemSchema reference is a null key, an item schema must be specified"));
+ "itemSchema reference is a null key, an item schema must be specified"));
}
result = itemSchema.validate(result);
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
index a6e2ad9ac..9df11ae25 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
@@ -51,22 +51,22 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.utilities.Assertions;
/**
- * This class is a context album container and holds a map of the context albums for an entire Apex
- * model. All Apex models that use context albums must have an {@link AxContextAlbums} field. The
- * {@link AxContextAlbums} class implements the helper methods of the {@link AxConceptGetter}
- * interface to allow {@link AxContextAlbum} 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 observation is issued if no context
- * albums are defined in the container. If context albums do exist, they are checked to ensure that
- * keys and values are not null and that the map key matches the key in the map value for all album
- * entries. Each context album entry is then validated individually.
+ * This class is a context album container and holds a map of the context albums for an entire Apex model. All Apex
+ * models that use context albums must have an {@link AxContextAlbums} field. The {@link AxContextAlbums} class
+ * implements the helper methods of the {@link AxConceptGetter} interface to allow {@link AxContextAlbum} 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 observation is issued if no context albums are defined in
+ * the container. If context albums do exist, they are checked to ensure that keys and values are not null and that the
+ * map key matches the key in the map value for all album entries. Each context album entry is then validated
+ * individually.
*/
@Entity
@Table(name = "AxContextAlbums")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxContextAlbums", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = {"key", "albums"})
+@XmlType(name = "AxContextAlbums", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "albums" })
public final class AxContextAlbums extends AxConcept implements AxConceptGetter<AxContextAlbum> {
private static final long serialVersionUID = -4844259809024470975L;
@@ -84,15 +84,15 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
// @formatter:on
/**
- * The Default Constructor creates a {@link AxContextAlbums} object with a null artifact key and
- * creates an empty context album map.
+ * The Default Constructor creates a {@link AxContextAlbums} object with a null artifact key and creates an empty
+ * context album map.
*/
public AxContextAlbums() {
this(new AxArtifactKey());
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -101,8 +101,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
/**
- * The Key Constructor creates a {@link AxContextAlbums} object with the given artifact key and
- * creates an empty context album map.
+ * The Key Constructor creates a {@link AxContextAlbums} object with the given artifact key and creates an empty
+ * context album map.
*
* @param key the key of the context album container
*/
@@ -127,15 +127,14 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
/**
- * When a model is unmarshalled from disk or from the database, the context album 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 context album 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 unmarsaller 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 unmarsaller, final Object parent) {
// The map must be navigable to allow name and version searching, unmarshaling returns a
// hash map
final NavigableMap<AxArtifactKey, AxContextAlbum> navigableAlbums = new TreeMap<>();
@@ -236,8 +235,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (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
@@ -245,23 +243,24 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
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 (albums.size() == 0) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION, "albums are empty"));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
+ "albums are empty"));
} else {
for (final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry : albums.entrySet()) {
if (contextAlbumEntry.getKey().equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on context album entry " + contextAlbumEntry.getKey() + " may not be the null key"));
+ "key on context album entry " + contextAlbumEntry.getKey()
+ + " may not be the null key"));
} else if (contextAlbumEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on context album entry " + contextAlbumEntry.getKey() + " may not be null"));
+ "value on context album entry " + contextAlbumEntry.getKey() + " may not be null"));
} else {
validateContextAlbumKey(result, contextAlbumEntry);
@@ -274,19 +273,19 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
private void validateContextAlbumKey(final AxValidationResult result,
- final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry) {
+ final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry) {
if (!contextAlbumEntry.getKey().equals(contextAlbumEntry.getValue().getKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on context album entry key " + contextAlbumEntry.getKey()
- + " does not equal context album value key " + contextAlbumEntry.getValue().getKey()));
+ "key on context album entry key " + contextAlbumEntry.getKey()
+ + " does not equal context album value key "
+ + contextAlbumEntry.getValue().getKey()));
}
}
/*
* (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
@@ -301,7 +300,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
final Map<AxArtifactKey, AxContextAlbum> newContextAlbum = new TreeMap<>();
for (final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry : albums.entrySet()) {
newContextAlbum.put(new AxArtifactKey(contextAlbumEntry.getKey()),
- new AxContextAlbum(contextAlbumEntry.getValue()));
+ new AxContextAlbum(contextAlbumEntry.getValue()));
}
copy.setAlbumsMap(newContextAlbum);
@@ -399,13 +398,12 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (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 AxContextAlbum get(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxContextAlbum>) albums).get(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
/*
@@ -421,12 +419,11 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (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<AxContextAlbum> getAll(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxContextAlbum>) albums).getAll(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
}
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
index 2aa6fc70a..56983f37b 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
@@ -48,8 +48,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
* constructed that just contains context and the key information for that context. The model contains schema
* definitions and the definitions of context albums that use those schemas. In the case where Apex context is being
* used without policy or independent of policy, an Apex context model is sufficient to get Apex context working.
- * <p>
- * Validation runs {@link AxModel} validation on the model. In addition, the {@link AxContextSchemas} and
+ *
+ * <p>Validation runs {@link AxModel} validation on the model. In addition, the {@link AxContextSchemas} and
* {@link AxContextAlbums} validation is run on the context schemas and albums in the model.
*/
@Entity
@@ -102,7 +102,7 @@ public class AxContextModel extends AxModel {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
index 87c89376e..5dad2e9e8 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
@@ -50,24 +50,24 @@ import org.onap.policy.apex.model.utilities.Assertions;
* schema flavour defines the type of schema being defined and the schema itself defines the schema. The schema flavour
* is used by Apex to look up and load a plugin class that understands and interprets the schema definition and can
* create instances of classes for the schema.
- * <p>
- * An {@link AxContextSchema} is used to define each parameter in Apex events, the messages that enter, exit, and are
+ *
+ * <p>An {@link AxContextSchema} is used to define each parameter in Apex events, the messages that enter, exit, and are
* passed internally in Apex. In addition, an Apex {@link AxContextAlbum} instances hold a map of
* {@link AxContextSchema} instances to represent the context being managed as an {@link AxContextAlbum}. For example,
* the state of all cells in a mobile network might be represented as an {@link AxContextAlbum} with its
* {@link AxContextSchema} being defined as @code cell} objects.
- * <p>
- * Validation checks that the schema key is not null. It also checks that the schema flavour is defined and matches the
- * regular expression SCHEMA_FLAVOUR_REGEXP. Finally, validation checks that the defined schema is not a blank
- * or empty string.
+ *
+ * <p>Validation checks that the schema key is not null. It also checks that the schema flavour is defined and matches
+ * the regular expression SCHEMA_FLAVOUR_REGEXP. Finally, validation checks that the defined schema is not a blank or
+ * empty string.
*/
@Entity
@Table(name = "AxContextSchema")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexContextSchema", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxContextSchema", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = { "key", "schemaFlavour", "schemaDefinition" })
+@XmlType(name = "AxContextSchema", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "schemaFlavour", "schemaDefinition" })
public class AxContextSchema extends AxConcept {
private static final String SCHEMA_FLAVOUR = "schemaFlavour";
@@ -108,7 +108,7 @@ public class AxContextSchema extends AxConcept {
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -222,28 +222,28 @@ public class AxContextSchema 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 (schemaFlavour.replaceAll(WHITESPACE_REGEXP, "").length() == 0
- || schemaFlavour.equals(SCHEMA_FLAVOUR_UNDEFINED)) {
+ || schemaFlavour.equals(SCHEMA_FLAVOUR_UNDEFINED)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "schema flavour is not defined"));
+ "schema flavour is not defined"));
}
try {
Assertions.validateStringParameter(SCHEMA_FLAVOUR, schemaFlavour, SCHEMA_FLAVOUR_REGEXP);
} catch (final IllegalArgumentException e) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "schema flavour invalid-" + e.getMessage()));
+ "schema flavour invalid-" + e.getMessage()));
}
if (schemaDefinition.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "no schemaDefinition specified, schemaDefinition may not be blank"));
+ "no schemaDefinition specified, schemaDefinition may not be blank"));
}
return result;
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
index df94a87a9..2b31aa425 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
@@ -55,8 +55,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
* models that use context schemas must have an {@link AxContextSchemas} field. The {@link AxContextSchemas} class
* implements the helper methods of the {@link AxConceptGetter} interface to allow {@link AxContextSchema} 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 context schemas are defined in the
+ *
+ * <p>Validation checks that the container key is not null. An error is issued if no context schemas are defined in the
* container. Each context schema 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 context schema entry is then validated individually.
*/
@@ -64,7 +64,8 @@ import org.onap.policy.apex.model.utilities.Assertions;
@Table(name = "AxContextSchemas")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxContextSchemas", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = { "key", "schemas" })
+@XmlType(name = "AxContextSchemas", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "key", "schemas" })
public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxContextSchema> {
private static final long serialVersionUID = -3203734282886453582L;
@@ -93,7 +94,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
}
/**
- * Copy constructor
+ * Copy constructor.
*
* @param copyConcept the concept to copy from
*/
@@ -132,10 +133,10 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
* 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 unmarshaller 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 unmarshaller, final Object parent) {
// The map must be navigable to allow name and version searching, unmarshaling returns a
// hash map
final NavigableMap<AxArtifactKey, AxContextSchema> navigableContextSchemas = new TreeMap<>();
@@ -208,28 +209,31 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
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 (schemas.size() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "contextSchemas may not be empty"));
+ "contextSchemas may not be empty"));
} else {
for (final Entry<AxArtifactKey, AxContextSchema> contextSchemaEntry : schemas.entrySet()) {
if (contextSchemaEntry.getKey().equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on schemas entry " + contextSchemaEntry.getKey() + " may not be the null key"));
+ "key on schemas entry " + contextSchemaEntry.getKey()
+ + " may not be the null key"));
} else if (contextSchemaEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on schemas entry " + contextSchemaEntry.getKey() + " may not be null"));
+ "value on schemas entry " + contextSchemaEntry.getKey() + " may not be null"));
} else {
if (!contextSchemaEntry.getKey().equals(contextSchemaEntry.getValue().getKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(),
- ValidationResult.INVALID, "key on schemas entry " + contextSchemaEntry.getKey()
- + " does not equal entry key " + contextSchemaEntry.getValue().getKey()));
+ result.addValidationMessage(
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key on schemas entry " + contextSchemaEntry.getKey()
+ + " does not equal entry key "
+ + contextSchemaEntry.getValue().getKey()));
}
result = contextSchemaEntry.getValue().validate(result);
@@ -291,7 +295,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
final Map<AxArtifactKey, AxContextSchema> newcontextSchemas = new TreeMap<>();
for (final Entry<AxArtifactKey, AxContextSchema> contextSchemasEntry : schemas.entrySet()) {
newcontextSchemas.put(new AxArtifactKey(contextSchemasEntry.getKey()),
- new AxContextSchema(contextSchemasEntry.getValue()));
+ new AxContextSchema(contextSchemasEntry.getValue()));
}
copy.setSchemasMap(newcontextSchemas);
@@ -393,7 +397,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
@Override
public AxContextSchema get(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxContextSchema>) schemas).get(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
/*
@@ -414,6 +418,6 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
@Override
public Set<AxContextSchema> getAll(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxContextSchema>) schemas).getAll(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextAlbums.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextAlbums.java
index 839e19835..6ba0b2fa6 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextAlbums.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextAlbums.java
@@ -35,6 +35,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
/**
+ * Context album tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestContextAlbums {
@@ -62,7 +64,7 @@ public class TestContextAlbums {
fail("test should throw an exception here");
} catch (final Exception e) {
assertEquals("parameter \"scope\": value \"\", does not match regular expression \"[A-Za-z0-9\\-_]+\"",
- e.getMessage());
+ e.getMessage());
}
album.setScope("NewAlbumScope");
@@ -114,9 +116,9 @@ public class TestContextAlbums {
album.clean();
final AxContextAlbum clonedAlbum = new AxContextAlbum(album);
- assertEquals(
- "AxContextAlbum:(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1),scope=NewAlbumScope,isWritable=true,itemSchema=AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))",
- clonedAlbum.toString());
+ assertEquals("AxContextAlbum:(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1),"
+ + "scope=NewAlbumScope,isWritable=true,itemSchema="
+ + "AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))", clonedAlbum.toString());
assertFalse(album.hashCode() == 0);
@@ -134,13 +136,13 @@ public class TestContextAlbums {
assertEquals(0, album.compareTo(clonedAlbum));
assertNotEquals(0, album.compareTo(null));
assertNotEquals(0, album.compareTo(new AxArtifactKey()));
- assertNotEquals(0,
- album.compareTo(new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey())));
+ assertNotEquals(0, album.compareTo(
+ new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey())));
assertNotEquals(0, album.compareTo(new AxContextAlbum(newKey, "Scope", false, AxArtifactKey.getNullKey())));
+ assertNotEquals(0, album
+ .compareTo(new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey())));
assertNotEquals(0,
- album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey())));
- assertNotEquals(0,
- album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
+ album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
assertEquals(0, album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, albumSchemaKey)));
final AxContextAlbums albums = new AxContextAlbums();
@@ -182,8 +184,8 @@ public class TestContextAlbums {
albums.clean();
final AxContextAlbums clonedAlbums = new AxContextAlbums(albums);
- assertTrue(clonedAlbums.toString()
- .startsWith("AxContextAlbums:(AxContextAlbums:(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)"));
+ assertTrue(clonedAlbums.toString().startsWith(
+ "AxContextAlbums:(AxContextAlbums:(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)"));
assertFalse(albums.hashCode() == 0);
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextModel.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextModel.java
index 163e50018..290183e5f 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextModel.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextModel.java
@@ -34,6 +34,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
/**
+ * Context model tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestContextModel {
@@ -43,19 +45,21 @@ public class TestContextModel {
assertNotNull(new AxContextModel());
assertNotNull(new AxContextModel(new AxArtifactKey()));
assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation()));
- assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation()));
-
+ assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(),
+ new AxKeyInformation()));
+
final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1");
final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxArtifactKey albumsKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxArtifactKey keyInfoKey = new AxArtifactKey("SchemasKey", "0.0.1");
- final AxContextModel model = new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey));
+ final AxContextModel model = new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey));
model.register();
-
+
model.clean();
assertNotNull(model);
assertEquals("AxContextModel:(AxContextModel:(key=AxArtifactKey:", model.toString().substring(0, 50));
-
+
final AxContextModel clonedModel = new AxContextModel(model);
assertFalse(model.hashCode() == 0);
@@ -64,19 +68,29 @@ public class TestContextModel {
assertTrue(model.equals(clonedModel));
assertFalse(model.equals("Hello"));
assertFalse(model.equals(new AxContextModel(new AxArtifactKey())));
- assertFalse(model.equals(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation())));
- assertFalse(model.equals(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation())));
- assertFalse(model.equals(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
- assertFalse(model.equals(new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
- assertTrue(model.equals(new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
+ assertFalse(model.equals(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(),
+ new AxKeyInformation())));
+ assertFalse(model.equals(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
+ new AxKeyInformation())));
+ assertFalse(model.equals(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
+ new AxKeyInformation(keyInfoKey))));
+ assertFalse(model.equals(new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(),
+ new AxKeyInformation(keyInfoKey))));
+ assertTrue(model.equals(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
assertEquals(0, model.compareTo(model));
assertEquals(0, model.compareTo(clonedModel));
assertNotEquals(0, model.compareTo(new AxArtifactKey()));
- assertNotEquals(0, model.compareTo(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation())));
- assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation())));
- assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
- assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
- assertEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
+ assertNotEquals(0, model.compareTo(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(),
+ new AxContextAlbums(), new AxKeyInformation())));
+ assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
+ new AxKeyInformation())));
+ assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
+ new AxKeyInformation(keyInfoKey))));
+ assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
+ assertEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
}
}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextSchemas.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextSchemas.java
index 02dfd6fb1..a8dde7781 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextSchemas.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/TestContextSchemas.java
@@ -35,7 +35,7 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
+ * Context schema tests.
*/
public class TestContextSchemas {
@@ -44,8 +44,8 @@ public class TestContextSchemas {
assertNotNull(new AxContextSchema());
assertNotNull(new AxContextSchema(new AxArtifactKey(), "SchemaFlavour", "SchemaDefinition"));
- final AxContextSchema schema =
- new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour", "SchemaDefinition");
+ final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
+ "SchemaDefinition");
assertNotNull(schema);
final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
@@ -57,9 +57,8 @@ public class TestContextSchemas {
schema.setSchemaFlavour("");
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "parameter \"schemaFlavour\": value \"\", does not match regular expression \"[A-Za-z0-9\\-_]+\"",
- e.getMessage());
+ assertEquals("parameter \"schemaFlavour\": value \"\", "
+ + "does not match regular expression \"[A-Za-z0-9\\-_]+\"", e.getMessage());
}
schema.setSchemaFlavour("NewSchemaFlavour");
@@ -105,16 +104,16 @@ public class TestContextSchemas {
schema.clean();
final AxContextSchema clonedSchema = new AxContextSchema(schema);
- assertEquals(
- "AxContextSchema:(key=AxArtifactKey:(name=NewSchemaName,version=0.0.1),schemaFlavour=NewSchemaFlavour,schemaDefinition=NewSchemaDefinition)",
- clonedSchema.toString());
+ assertEquals("AxContextSchema:(key=AxArtifactKey:(name=NewSchemaName,version=0.0.1),"
+ + "schemaFlavour=NewSchemaFlavour,schemaDefinition=NewSchemaDefinition)",
+ clonedSchema.toString());
assertFalse(schema.hashCode() == 0);
assertTrue(schema.equals(schema));
assertTrue(schema.equals(clonedSchema));
assertFalse(schema.equals(null));
- assertFalse(schema.equals("Hello"));
+ assertFalse(schema.equals((Object) "Hello"));
assertFalse(schema.equals(new AxContextSchema(new AxArtifactKey(), "Flavour", "Def")));
assertFalse(schema.equals(new AxContextSchema(newKey, "Flavour", "Def")));
assertFalse(schema.equals(new AxContextSchema(newKey, "NewSchemaFlavour", "Def")));
@@ -169,14 +168,14 @@ public class TestContextSchemas {
final AxContextSchemas clonedSchemas = new AxContextSchemas(schemas);
assertTrue(clonedSchemas.toString()
- .startsWith("AxContextSchemas:(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),"));
+ .startsWith("AxContextSchemas:(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),"));
assertFalse(schemas.hashCode() == 0);
assertTrue(schemas.equals(schemas));
assertTrue(schemas.equals(clonedSchemas));
assertFalse(schemas.equals(null));
- assertFalse(schemas.equals("Hello"));
+ assertFalse(schemas.equals((Object) "Hello"));
assertFalse(schemas.equals(new AxContextSchemas(new AxArtifactKey())));
assertEquals(0, schemas.compareTo(schemas));
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModel.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModel.java
index 10609ec9b..94a36844f 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModel.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModel.java
@@ -34,10 +34,21 @@ import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+/**
+ * Apex context model tests.
+ *
+ * @author liam
+ *
+ */
public class TestApexContextModel {
private Connection connection;
TestApexModel<AxContextModel> testApexModel;
+ /**
+ * Set up tests.
+ *
+ * @throws Exception a testing exception
+ */
@Before
public void setup() throws Exception {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
@@ -83,17 +94,17 @@ public class TestApexContextModel {
}
@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");
@@ -104,24 +115,39 @@ public class TestApexContextModel {
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"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
- + "********************************";
+ + "***observations noted during validation of model***\n"
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
+ + "********************************";
private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "********************************";
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:"
+ + "UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "********************************";
private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=StringType,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:no schemaDefinition specified, schemaDefinition may not be blank\n"
- + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
- + "********************************";
+ + "AxArtifactKey:(name=StringType,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:"
+ + "no schemaDefinition specified, schemaDefinition may not be blank\n"
+ + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:"
+ + "scope is not defined\n" + "********************************";
private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=ContextModel,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=ContextSchemas,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "********************************";
+ + "AxArtifactKey:(name=ContextModel,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:"
+ + "key not found for key information entry\n" + "AxArtifactKey:(name=ContextSchemas,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
+ + "key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) "
+ + "does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)\n"
+ + "AxArtifactKey:(name=contextAlbums,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:"
+ + "key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) "
+ + "does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
+ + "********************************";
}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparison.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparison.java
index 794cfa9f7..65295c13b 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparison.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparison.java
@@ -33,6 +33,8 @@ import org.onap.policy.apex.model.contextmodel.handling.ContextComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
/**
+ * Test context comparisons.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestContextComparison {
@@ -42,122 +44,145 @@ public class TestContextComparison {
private AxContextModel shellModel;
private AxContextModel singleEntryModel;
+ /**
+ * Set up tests.
+ */
@Before
public void getContext() {
final TestContextComparisonFactory factory = new TestContextComparisonFactory();
- emptyModel = factory.getEmptyModel();
- fullModel = factory.getFullModel();
+ emptyModel = factory.getEmptyModel();
+ fullModel = factory.getFullModel();
noGlobalContextModel = factory.getNoGlobalContextModel();
- shellModel = factory.getShellModel();
- singleEntryModel = factory.getSingleEntryModel();
+ shellModel = factory.getShellModel();
+ singleEntryModel = factory.getSingleEntryModel();
}
-
+
@Test
public void testEmptyEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(emptyModel.getSchemas(), emptyModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(emptyModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(emptyModel.getSchemas().getSchemasMap().equals(schemaResult.getIdenticalValues()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(emptyModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(emptyModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertTrue(emptyModel.getAlbums().getAlbumsMap().equals(albumResult.getIdenticalValues()));
}
-
+
@Test
public void testEmptyFull() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(emptyModel.getSchemas(), fullModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(emptyModel.getSchemas(), fullModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(fullModel.getSchemas().getSchemasMap().equals(schemaResult.getRightOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(emptyModel.getAlbums(), fullModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(emptyModel.getAlbums(), fullModel.getAlbums());
assertNotNull(albumResult);
assertTrue(fullModel.getAlbums().getAlbumsMap().equals(albumResult.getRightOnly()));
}
-
+
@Test
public void testFullEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(fullModel.getSchemas(), emptyModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(fullModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(fullModel.getSchemas().getSchemasMap().equals(schemaResult.getLeftOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(fullModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(fullModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertTrue(fullModel.getAlbums().getAlbumsMap().equals(albumResult.getLeftOnly()));
}
-
+
@Test
public void testEmptyNoGlobalContext() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(emptyModel.getSchemas(), noGlobalContextModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(emptyModel.getSchemas(), noGlobalContextModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(noGlobalContextModel.getSchemas().getSchemasMap().equals(schemaResult.getRightOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(emptyModel.getAlbums(), noGlobalContextModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(emptyModel.getAlbums(), noGlobalContextModel.getAlbums());
assertNotNull(albumResult);
assertTrue(noGlobalContextModel.getAlbums().getAlbumsMap().equals(albumResult.getRightOnly()));
}
-
+
@Test
public void testNoGlobalContextEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(noGlobalContextModel.getSchemas(), emptyModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(noGlobalContextModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(noGlobalContextModel.getSchemas().getSchemasMap().equals(schemaResult.getLeftOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(noGlobalContextModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(noGlobalContextModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertTrue(noGlobalContextModel.getAlbums().getAlbumsMap().equals(albumResult.getLeftOnly()));
}
-
+
@Test
public void testEmptyShell() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(emptyModel.getSchemas(), shellModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(emptyModel.getSchemas(), shellModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(shellModel.getSchemas().getSchemasMap().equals(schemaResult.getRightOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(emptyModel.getAlbums(), shellModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(emptyModel.getAlbums(), shellModel.getAlbums());
assertNotNull(albumResult);
assertTrue(shellModel.getAlbums().getAlbumsMap().equals(albumResult.getRightOnly()));
}
-
+
@Test
public void testShellEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(shellModel.getSchemas(), emptyModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(shellModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(shellModel.getSchemas().getSchemasMap().equals(schemaResult.getLeftOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(shellModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(shellModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertTrue(shellModel.getAlbums().getAlbumsMap().equals(albumResult.getLeftOnly()));
}
-
+
@Test
public void testEmptySingleEntry() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(emptyModel.getSchemas(), singleEntryModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(emptyModel.getSchemas(), singleEntryModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(singleEntryModel.getSchemas().getSchemasMap().equals(schemaResult.getRightOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(emptyModel.getAlbums(), singleEntryModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(emptyModel.getAlbums(), singleEntryModel.getAlbums());
assertNotNull(albumResult);
assertTrue(singleEntryModel.getAlbums().getAlbumsMap().equals(albumResult.getRightOnly()));
}
-
+
@Test
public void testSingleEntryEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(singleEntryModel.getSchemas(), emptyModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(singleEntryModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(singleEntryModel.getSchemas().getSchemasMap().equals(schemaResult.getLeftOnly()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(singleEntryModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(singleEntryModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertTrue(singleEntryModel.getAlbums().getAlbumsMap().equals(albumResult.getLeftOnly()));
}
-
+
@Test
public void testFullFull() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer().compare(fullModel.getSchemas(), fullModel.getSchemas());
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
+ .compare(fullModel.getSchemas(), fullModel.getSchemas());
assertNotNull(schemaResult);
assertTrue(fullModel.getSchemas().getSchemasMap().equals(schemaResult.getIdenticalValues()));
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer().compare(fullModel.getAlbums(), fullModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
+ .compare(fullModel.getAlbums(), fullModel.getAlbums());
assertNotNull(albumResult);
assertTrue(fullModel.getAlbums().getAlbumsMap().equals(albumResult.getIdenticalValues()));
}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
index 2c6f8e172..f7c7a1345 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
@@ -26,12 +26,16 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
/**
- * This class creates sample Policy Models
+ * This class creates sample Policy Models.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestContextComparisonFactory {
+ /**
+ * Get a full context model.
+ * @return the model
+ */
public AxContextModel getFullModel() {
final AxContextSchema testContextSchema000 =
new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
@@ -69,6 +73,10 @@ public class TestContextComparisonFactory {
return new AxContextModel(new AxArtifactKey("Context", "0.0.1"));
}
+ /**
+ * Get a skeleton model.
+ * @return The model
+ */
public AxContextModel getShellModel() {
final AxContextSchema testContextSchema000 =
new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
@@ -88,6 +96,10 @@ public class TestContextComparisonFactory {
return contextModel;
}
+ /**
+ * Get a single entry model.
+ * @return The single entry model
+ */
public AxContextModel getSingleEntryModel() {
final AxContextSchema testContextSchema000 =
new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
@@ -104,6 +116,10 @@ public class TestContextComparisonFactory {
return contextModel;
}
+ /**
+ * Get a model with no global entries.
+ * @return the model
+ */
public AxContextModel getNoGlobalContextModel() {
final AxContextSchema testContextSchema000 =
new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",