aboutsummaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-04 10:41:51 -0400
committerJim Hahn <jrh3@att.com>2021-08-05 08:46:30 -0400
commit7438fe5a86a9fcfaf248ee32197b24d1badaecb3 (patch)
treec96b211c4380bd9bc4a614bed830da330f50c4e3 /model
parent038c19d4042de980d4adccbfa82c1534b53abe5f (diff)
Use lombok in apex-pdp #2
Updated context to use lombok. Issue-ID: POLICY-3391 Change-Id: I349e0202fffad161cac08cebaea4a9571db58bda Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'model')
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java119
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java71
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java81
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java47
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java68
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java11
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java4
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java11
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java4
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java32
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt12
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt12
12 files changed, 93 insertions, 379 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 85a6ab803..b3880bd8c 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
@@ -34,6 +34,10 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -66,6 +70,10 @@ import org.onap.policy.common.utils.validation.Assertions;
@Entity
@Table(name = "AxContextAlbum")
+@Getter
+@ToString
+@EqualsAndHashCode(callSuper = false)
+
@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 =
@@ -84,9 +92,6 @@ public class AxContextAlbum extends AxConcept {
/** The value of scope for a context album for which a scope has not been specified. */
public static final String SCOPE_UNDEFINED = "UNDEFINED";
- private static final int HASH_PRIME_0 = 1231;
- private static final int HASH_PRIME_1 = 1237;
-
@EmbeddedId
@XmlElement(name = "key", required = true)
private AxArtifactKey key;
@@ -97,6 +102,7 @@ public class AxContextAlbum extends AxConcept {
@Column(name = "isWritable")
@XmlElement(name = "isWritable", required = true)
+ @Setter
private boolean isWritable;
// @formatter:off
@@ -165,14 +171,6 @@ public class AxContextAlbum extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
keyList.add(new AxKeyUse(itemSchema.getKey()));
@@ -191,15 +189,6 @@ public class AxContextAlbum extends AxConcept {
}
/**
- * Gets the scope of the context album.
- *
- * @return the context album scope
- */
- public String getScope() {
- return scope;
- }
-
- /**
* Sets the scope of the context album.
*
* @param scope the context album scope
@@ -210,33 +199,6 @@ public class AxContextAlbum extends AxConcept {
}
/**
- * Sets whether the album is writable or not.
- *
- * @param writable the writable flag value
- */
- public void setWritable(final boolean writable) {
- this.isWritable = writable;
- }
-
- /**
- * Checks if the album is writable.
- *
- * @return true, if the album is writable
- */
- public boolean isWritable() {
- return isWritable;
- }
-
- /**
- * Gets the artifact key of the item schema of this context album.
- *
- * @return the item schema key
- */
- public AxArtifactKey getItemSchema() {
- return itemSchema;
- }
-
- /**
* Sets the artifact key of the item schema of this context album.
*
* @param itemSchema the item schema key
@@ -293,26 +255,6 @@ public class AxContextAlbum extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",scope=");
- builder.append(scope);
- builder.append(",isWritable=");
- builder.append(isWritable);
- builder.append(",itemSchema=");
- builder.append(itemSchema);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "targetObject may not be null");
@@ -332,49 +274,6 @@ public class AxContextAlbum extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + scope.hashCode();
- result = prime * result + (isWritable ? HASH_PRIME_0 : HASH_PRIME_1);
- result = prime * result + itemSchema.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxContextAlbum other = (AxContextAlbum) obj;
- if (!key.equals(other.key)) {
- return false;
- }
- if (!scope.equals(other.scope)) {
- return false;
- }
- if (isWritable != other.isWritable) {
- return (false);
- }
- return itemSchema.equals(other.itemSchema);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public int compareTo(final AxConcept otherObj) {
if (otherObj == null) {
return -1;
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 30e021f43..aa5a89a4d 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +40,10 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.AccessLevel;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter;
@@ -63,6 +68,10 @@ import org.onap.policy.common.utils.validation.Assertions;
@Entity
@Table(name = "AxContextAlbums")
+@Getter
+@ToString
+@EqualsAndHashCode(callSuper = false)
+
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AxContextAlbums", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
{ "key", "albums" })
@@ -79,6 +88,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
@JoinTable(joinColumns = {@JoinColumn(name = "contextName", referencedColumnName = "name"),
@JoinColumn(name = "contextVersion", referencedColumnName = "version")})
@XmlElement(name = "albums", required = true)
+ @Getter(AccessLevel.NONE)
private Map<AxArtifactKey, AxContextAlbum> albums;
// @formatter:on
@@ -148,14 +158,6 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
* {@inheritDoc}.
*/
@Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
@@ -212,24 +214,6 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
* {@inheritDoc}.
*/
@Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",albums=");
- builder.append(albums);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public AxValidationResult validate(final AxValidationResult resultIn) {
AxValidationResult result = resultIn;
@@ -299,41 +283,6 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
* {@inheritDoc}.
*/
@Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + albums.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxContextAlbums other = (AxContextAlbums) obj;
- if (!key.equals(other.key)) {
- return false;
- }
- return albums.equals(other.albums);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public int compareTo(final AxConcept otherObj) {
if (otherObj == null) {
return -1;
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 c5919c030..9796fa625 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
@@ -33,6 +33,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -54,6 +57,10 @@ import org.onap.policy.common.utils.validation.Assertions;
@Entity
@Table(name = "AxContextModel")
+@Getter
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+
@XmlRootElement(name = "apexContextModel", namespace = "http://www.onap.org/policy/apex-pdp")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AxContextModel", namespace = "http://www.onap.org/policy/apex-pdp",
@@ -160,15 +167,6 @@ public class AxContextModel extends AxModel {
}
/**
- * Gets the context schemas from the model.
- *
- * @return the context schemas
- */
- public AxContextSchemas getSchemas() {
- return schemas;
- }
-
- /**
* Sets the context schemas on the model.
*
* @param schemas the context schemas
@@ -179,15 +177,6 @@ public class AxContextModel extends AxModel {
}
/**
- * Gets the context albums from the model.
- *
- * @return the context albums
- */
- public AxContextAlbums getAlbums() {
- return albums;
- }
-
- /**
* Sets the context albums on the model.
*
* @param albums the context albums
@@ -223,23 +212,6 @@ public class AxContextModel extends AxModel {
* {@inheritDoc}.
*/
@Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append(super.toString());
- builder.append(",schemas=");
- builder.append(schemas);
- builder.append(",albums=");
- builder.append(albums);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
@@ -258,45 +230,6 @@ public class AxContextModel extends AxModel {
* {@inheritDoc}.
*/
@Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + super.hashCode();
- result = prime * result + schemas.hashCode();
- result = prime * result + albums.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- throw new IllegalArgumentException("comparison object may not be null");
- }
-
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxContextModel other = (AxContextModel) obj;
- if (!super.equals(other)) {
- return false;
- }
- if (!schemas.equals(other.schemas)) {
- return false;
- }
- return albums.equals(other.albums);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public int compareTo(final AxConcept otherObj) {
Assertions.argumentNotNull(otherObj, "comparison object may not be null");
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 bca369157..37f44ba49 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,9 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -63,6 +67,9 @@ import org.onap.policy.common.utils.validation.Assertions;
@Entity
@Table(name = "AxContextSchema")
+@Getter
+@ToString
+
@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 =
@@ -95,6 +102,7 @@ public class AxContextSchema extends AxConcept {
@Convert(converter = CDataConditioner.class)
@XmlJavaTypeAdapter(value = CDataConditioner.class)
@XmlElement(name = "schemaDefinition", required = true)
+ @Getter(AccessLevel.NONE)
private String schemaDefinition;
/**
@@ -147,14 +155,6 @@ public class AxContextSchema extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
return key.getKeys();
}
@@ -170,15 +170,6 @@ public class AxContextSchema extends AxConcept {
}
/**
- * Gets the schema flavour, which defines the schema definition type being used.
- *
- * @return the schema flavour
- */
- public String getSchemaFlavour() {
- return schemaFlavour;
- }
-
- /**
* Sets the schema flavour, which defines the type of schema definition being used.
*
* @param schemaFlavour the schema flavour
@@ -255,24 +246,6 @@ public class AxContextSchema extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",schemaFlavour=");
- builder.append(schemaFlavour);
- builder.append(",schemaDefinition=");
- builder.append(schemaDefinition);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
@@ -296,7 +269,9 @@ public class AxContextSchema extends AxConcept {
var result = 1;
result = prime * result + key.hashCode();
result = prime * result + schemaFlavour.hashCode();
- result = prime * result + schemaDefinition.hashCode();
+
+ final String thisSchema = CDataConditioner.clean(schemaDefinition).replace("\n", "");
+ result = prime * result + thisSchema.hashCode();
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 bfd1809a7..1fa0cf57a 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +40,10 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.AccessLevel;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter;
@@ -62,6 +67,10 @@ import org.onap.policy.common.utils.validation.Assertions;
@Entity
@Table(name = "AxContextSchemas")
+@Getter
+@ToString
+@EqualsAndHashCode(callSuper = false)
+
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AxContextSchemas", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
{ "key", "schemas" })
@@ -81,6 +90,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
inverseJoinColumns = {@JoinColumn(name = "contextSchemaName", referencedColumnName = "name"),
@JoinColumn(name = "contextSchemaVersion", referencedColumnName = "version")})
@XmlElement(name = "schemas", required = true)
+ @Getter(AccessLevel.NONE)
private Map<AxArtifactKey, AxContextSchema> schemas;
// @formatter:on
@@ -147,14 +157,6 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
* {@inheritDoc}.
*/
@Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
keyList.addAll(schemas.keySet());
@@ -252,22 +254,6 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
* {@inheritDoc}.
*/
@Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",schemas=");
- builder.append(schemas);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
@@ -291,40 +277,6 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
* {@inheritDoc}.
*/
@Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + schemas.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxContextSchemas other = (AxContextSchemas) obj;
- if (!key.equals(other.key)) {
- return false;
- }
- return schemas.equals(other.schemas);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public int compareTo(final AxConcept otherObj) {
if (otherObj == null) {
return -1;
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
index 8293feb5b..44161b329 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +22,11 @@
package org.onap.policy.apex.model.contextmodel.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -138,8 +139,8 @@ public class ContextAlbumsTest {
album.setItemSchema(albumSchemaKey);
final AxContextAlbum clonedAlbum = new AxContextAlbum(album);
- assertEquals("AxContextAlbum:(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1),"
- + "scope=NewAlbumScope,isWritable=true,itemSchema="
+ assertEquals("AxContextAlbum(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1), "
+ + "scope=NewAlbumScope, isWritable=true, itemSchema="
+ "AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))", clonedAlbum.toString());
assertNotEquals(0, album.hashCode());
@@ -220,8 +221,8 @@ public class ContextAlbumsTest {
albums.clean();
final AxContextAlbums clonedAlbums = new AxContextAlbums(albums);
- assertTrue(clonedAlbums.toString().startsWith(
- "AxContextAlbums:(AxContextAlbums:(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)"));
+ assertThat(clonedAlbums.toString()).startsWith(
+ "AxContextAlbums(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)");
assertNotEquals(0, albums.hashCode());
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
index eab561e25..b148ef6be 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.apex.model.contextmodel.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
@@ -54,7 +56,7 @@ public class ContextModelTest {
model.clean();
assertNotNull(model);
- assertEquals("AxContextModel:(AxContextModel:(key=AxArtifactKey:", model.toString().substring(0, 50));
+ assertThat(model.toString()).startsWith("AxContextModel(super=AxContextModel:(key=AxArtifactKey:");
final AxContextModel clonedModel = new AxContextModel(model);
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
index fbca04d7e..52cca14bf 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +22,11 @@
package org.onap.policy.apex.model.contextmodel.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -121,8 +122,8 @@ public class ContextSchemasTest {
schema.clean();
final AxContextSchema clonedSchema = new AxContextSchema(schema);
- assertEquals("AxContextSchema:(key=AxArtifactKey:(name=NewSchemaName,version=0.0.1),"
- + "schemaFlavour=NewSchemaFlavour,schemaDefinition=NewSchemaDefinition)",
+ assertEquals("AxContextSchema(key=AxArtifactKey:(name=NewSchemaName,version=0.0.1), "
+ + "schemaFlavour=NewSchemaFlavour, schemaDefinition=NewSchemaDefinition)",
clonedSchema.toString());
assertNotEquals(0, schema.hashCode());
@@ -201,8 +202,8 @@ public class ContextSchemasTest {
schemas.clean();
final AxContextSchemas clonedSchemas = new AxContextSchemas(schemas);
- assertTrue(clonedSchemas.toString()
- .startsWith("AxContextSchemas:(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),"));
+ assertThat(clonedSchemas.toString())
+ .startsWith("AxContextSchemas(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),");
assertNotEquals(0, schemas.hashCode());
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
index 5c87e5621..c23687bb1 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.apex.model.enginemodel.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -92,7 +94,7 @@ public class EngineModelTest {
model.clean();
assertNotNull(model);
- assertEquals("AxEngineModel:(AxEngineModel:(AxEngineModel:(key=A", model.toString().substring(0, 50));
+ assertThat(model.toString()).startsWith("AxEngineModel:(AxContextModel(super=AxEngineModel:(key=A");
final AxEngineModel clonedModel = new AxEngineModel(model);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
index f148f7d2a..0a1e80a20 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
@@ -44,26 +44,26 @@ public class PolicyModelComparerTest {
String resultString = policyModelComparer.asString(false, false);
String checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt");
- assertEquals(resultString.trim().replaceAll("[\\r?\\n]+", " "),
- checkString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(resultString.trim().replaceAll("\\s+", ""),
+ checkString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt");
- assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
- resultString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(checkString.trim().replaceAll("\\s+", ""),
+ resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
- resultString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(checkString.trim().replaceAll("\\s+", ""),
+ resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
- resultString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(checkString.trim().replaceAll("\\s+", ""),
+ resultString.trim().replaceAll("\\s+", ""));
final AxKeyInfo leftOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("LeftOnlyKeyInfo", "0.0.1"),
UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info");
@@ -83,26 +83,26 @@ public class PolicyModelComparerTest {
resultString = policyModelComparer.asString(false, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt");
- assertEquals(resultString.trim().replaceAll("[\\r?\\n]+", " "),
- checkString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(resultString.trim().replaceAll("\\s+", ""),
+ checkString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt");
- assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
- resultString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(checkString.trim().replaceAll("\\s+", ""),
+ resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt");
- assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
- resultString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(checkString.trim().replaceAll("\\s+", ""),
+ resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt");
- assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
- resultString.trim().replaceAll("[\\r?\\n]+", " "));
+ assertEquals(checkString.trim().replaceAll("\\s+", ""),
+ resultString.trim().replaceAll("\\s+", ""));
assertNotNull(policyModelComparer.getContextAlbumComparisonResult());
assertNotNull(policyModelComparer.getContextAlbumKeyDifference());
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
index 7dd0b3955..2138e97f0 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
@@ -6,10 +6,10 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=MapType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A)
-key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=StringType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000)
-key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.String)
-key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.Long)
+key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=MapType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A)
+key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=StringType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000)
+key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.String)
+key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.Long)
*** event differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -25,8 +25,8 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum:(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),scope=APPLICATION,isWritable=true,itemSchema=AxArtifactKey:(name=MapType,version=0.0.1))
-key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum:(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),scope=GLOBAL,isWritable=false,itemSchema=AxArtifactKey:(name=StringType,version=0.0.1))
+key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),scope=APPLICATION,isWritable=true,itemSchema=AxArtifactKey:(name=MapType,version=0.0.1))
+key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),scope=GLOBAL,isWritable=false,itemSchema=AxArtifactKey:(name=StringType,version=0.0.1))
*** task differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
index 149bec002..0faab1cdb 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
@@ -6,10 +6,10 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=MapType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A)
-key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=StringType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000)
-key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.String)
-key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema:(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.Long)
+key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=MapType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A)
+key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=StringType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000)
+key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.String)
+key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.Long)
*** event differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -25,8 +25,8 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum:(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),scope=APPLICATION,isWritable=true,itemSchema=AxArtifactKey:(name=MapType,version=0.0.1))
-key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum:(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),scope=GLOBAL,isWritable=false,itemSchema=AxArtifactKey:(name=StringType,version=0.0.1))
+key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),scope=APPLICATION,isWritable=true,itemSchema=AxArtifactKey:(name=MapType,version=0.0.1))
+key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),scope=GLOBAL,isWritable=false,itemSchema=AxArtifactKey:(name=StringType,version=0.0.1))
*** task differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right