summaryrefslogtreecommitdiffstats
path: root/context
diff options
context:
space:
mode:
Diffstat (limited to 'context')
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java16
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java20
-rw-r--r--context/context-test-utils/pom.xml (renamed from context/context-test/pom.xml)9
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem000.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem001.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem008.java)10
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00A.java)16
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem009.java)16
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem005.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem004.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem002.java)10
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem003.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem007.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem006.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00C.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00B.java)10
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java)78
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java)78
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java)36
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java)0
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java)54
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java552
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java176
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java364
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java)0
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java)128
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java)0
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java)40
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java)0
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java)2
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java)8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java (renamed from context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java)0
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java59
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java (renamed from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java)4
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java (renamed from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java)4
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java (renamed from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java)4
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java (renamed from context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java)4
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java (renamed from context/context-test/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java)11
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java (renamed from context/context-test/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java)47
-rw-r--r--context/context-test-utils/src/test/resources/META-INF/persistence.xml (renamed from context/context-test/src/test/resources/META-INF/persistence.xml)0
-rw-r--r--context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java469
-rw-r--r--context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java159
-rw-r--r--context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java344
-rw-r--r--context/pom.xml2
44 files changed, 1506 insertions, 1288 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
index 147e4eb35..cb4c6128e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
@@ -20,25 +20,27 @@
package org.onap.policy.apex.context.parameters;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
- * An empty distributor parameter class that may be specialized by context distributor plugins that require plugin
- * specific parameters. The class defines the default distributor plugin as the JVM local distributor.
+ * An empty distributor parameter class that may be specialized by context distributor plugins that
+ * require plugin specific parameters. The class defines the default distributor plugin as the JVM
+ * local distributor.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class DistributorParameters extends AbstractParameters {
/** The default distributor makes context albums available to all threads in a single JVM. */
- public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS =
- "org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor";
+ public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS = JVMLocalDistributor.class.getCanonicalName();
// Plugin class names
private String pluginClass = DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
/**
- * Constructor to create a distributor parameters instance and register the instance with the parameter service.
+ * Constructor to create a distributor parameters instance and register the instance with the
+ * parameter service.
*/
public DistributorParameters() {
super(DistributorParameters.class.getCanonicalName());
@@ -46,8 +48,8 @@ public class DistributorParameters extends AbstractParameters {
}
/**
- * Constructor to create a distributor parameters instance with the name of a sub class of this class and register
- * the instance with the parameter service.
+ * Constructor to create a distributor parameters instance with the name of a sub class of this
+ * class and register the instance with the parameter service.
*
* @param parameterClassName the class name of a sub class of this class
*/
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
index 93e422357..1aaee2cc7 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
@@ -20,25 +20,29 @@
package org.onap.policy.apex.context.parameters;
+import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
- * An empty lock manager parameter class that may be specialized by context lock manager plugins that require plugin
- * specific parameters. The class defines the default lock manager plugin as the JVM local lock manager.
+ * An empty lock manager parameter class that may be specialized by context lock manager plugins
+ * that require plugin specific parameters. The class defines the default lock manager plugin as the
+ * JVM local lock manager.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class LockManagerParameters extends AbstractParameters {
- /** The default lock manager can lock context album instance across all threads in a single JVM. */
- public static final String DEFAULT_LOCK_MANAGER_PLUGIN_CLASS =
- "org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager";
+ /**
+ * The default lock manager can lock context album instance across all threads in a single JVM.
+ */
+ public static final String DEFAULT_LOCK_MANAGER_PLUGIN_CLASS = JVMLocalLockManager.class.getCanonicalName();
// Plugin class names
private String pluginClass = DEFAULT_LOCK_MANAGER_PLUGIN_CLASS;
/**
- * Constructor to create a lock manager parameters instance and register the instance with the parameter service.
+ * Constructor to create a lock manager parameters instance and register the instance with the
+ * parameter service.
*/
public LockManagerParameters() {
super(LockManagerParameters.class.getCanonicalName());
@@ -46,8 +50,8 @@ public class LockManagerParameters extends AbstractParameters {
}
/**
- * Constructor to create a lock manager parameters instance with the name of a sub class of this class and register
- * the instance with the parameter service.
+ * Constructor to create a lock manager parameters instance with the name of a sub class of this
+ * class and register the instance with the parameter service.
*
* @param parameterClassName the class name of a sub class of this class
*/
diff --git a/context/context-test/pom.xml b/context/context-test-utils/pom.xml
index ded707adb..dc8ec6e0d 100644
--- a/context/context-test/pom.xml
+++ b/context/context-test-utils/pom.xml
@@ -26,9 +26,9 @@
<version>2.0.0-SNAPSHOT</version>
</parent>
- <artifactId>context-test</artifactId>
+ <artifactId>context-test-utils</artifactId>
<name>${project.artifactId}</name>
- <description>[${project.parent.artifactId}] module to hold test context date for testing</description>
+ <description>[${project.parent.artifactId}] module contain default distributor tests and common test utils</description>
<dependencies>
<dependency>
@@ -51,5 +51,10 @@
<version>${version.derby}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project> \ No newline at end of file
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem000.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
index 49e527822..7f019f57c 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem000.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem000.
*/
-public class TestContextItem000 implements Serializable {
+public class TestContextBooleanItem implements Serializable {
private static final int HASH_PRIME_1 = 31;
private static final int HASH_PRIME_2 = 1231;
private static final int HASH_PRIME_3 = 1237;
@@ -37,14 +37,14 @@ public class TestContextItem000 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem000() {}
+ public TestContextBooleanItem() {}
/**
* The Constructor.
*
* @param flag the flag
*/
- public TestContextItem000(final Boolean flag) {
+ public TestContextBooleanItem(final Boolean flag) {
this.flag = flag;
}
@@ -95,7 +95,7 @@ public class TestContextItem000 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem000 other = (TestContextItem000) obj;
+ final TestContextBooleanItem other = (TestContextBooleanItem) obj;
if (flag != other.flag) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem001.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
index 5d41269fe..2b107b492 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem001.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem001.
*/
-public class TestContextItem001 implements Serializable {
+public class TestContextByteItem implements Serializable {
private static final long serialVersionUID = 1361938145823720386L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@ public class TestContextItem001 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem001() {}
+ public TestContextByteItem() {}
/**
* The Constructor.
*
* @param byteValue the byte value
*/
- public TestContextItem001(final Byte byteValue) {
+ public TestContextByteItem(final Byte byteValue) {
this.byteValue = byteValue;
}
@@ -93,7 +93,7 @@ public class TestContextItem001 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem001 other = (TestContextItem001) obj;
+ final TestContextByteItem other = (TestContextByteItem) obj;
if (byteValue != other.byteValue) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem008.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
index 82a02a80e..f7c849023 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem008.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
@@ -28,7 +28,7 @@ import java.util.TimeZone;
/**
* The Class TestContextItem008.
*/
-public class TestContextItem008 implements Serializable {
+public class TestContextDateItem implements Serializable {
private static final long serialVersionUID = -6984963129968805460L;
private static final int HASH_PRIME_1 = 31;
@@ -47,7 +47,7 @@ public class TestContextItem008 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem008() {
+ public TestContextDateItem() {
this(new Date(System.currentTimeMillis()));
}
@@ -56,7 +56,7 @@ public class TestContextItem008 implements Serializable {
*
* @param dateValue the date value
*/
- public TestContextItem008(final Date dateValue) {
+ public TestContextDateItem(final Date dateValue) {
setDateValue(dateValue.getTime());
}
@@ -65,7 +65,7 @@ public class TestContextItem008 implements Serializable {
*
* @param time the time
*/
- public TestContextItem008(final long time) {
+ public TestContextDateItem(final long time) {
setDateValue(time);
}
@@ -217,7 +217,7 @@ public class TestContextItem008 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem008 other = (TestContextItem008) obj;
+ final TestContextDateItem other = (TestContextDateItem) obj;
if (day != other.day) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00A.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
index db380cc7a..0c94bcb1d 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00A.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
@@ -27,14 +27,14 @@ import java.util.TimeZone;
/**
* The Class TestContextItem00A.
*/
-public class TestContextItem00A implements Serializable {
+public class TestContextDateLocaleItem implements Serializable {
private static final long serialVersionUID = -6579903685538233754L;
private static final int HASH_PRIME_1 = 31;
private static final int HASH_PRIME_2 = 1231;
private static final int HASH_PRIME_3 = 1237;
- private TestContextItem008 dateValue = new TestContextItem008(System.currentTimeMillis());
+ private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
private boolean dst = false;
private int utcOffset = 0;
@@ -44,7 +44,7 @@ public class TestContextItem00A implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem00A() {}
+ public TestContextDateLocaleItem() {}
/**
* The Constructor.
@@ -56,7 +56,7 @@ public class TestContextItem00A implements Serializable {
* @param language the language
* @param country the country
*/
- public TestContextItem00A(final TestContextItem008 dateValue, final String tzValue, final boolean dst,
+ public TestContextDateLocaleItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst,
final int utcOffset, final String language, final String country) {
this.dateValue = dateValue;
this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
@@ -73,7 +73,7 @@ public class TestContextItem00A implements Serializable {
*
* @param original the original
*/
- public TestContextItem00A(final TestContextItem00A original) {
+ public TestContextDateLocaleItem(final TestContextDateLocaleItem original) {
this.dateValue = original.dateValue;
this.timeZoneString = TimeZone.getTimeZone(original.timeZoneString).getDisplayName();
this.dst = original.dst;
@@ -89,7 +89,7 @@ public class TestContextItem00A implements Serializable {
*
* @return the date value
*/
- public TestContextItem008 getDateValue() {
+ public TestContextDateItem getDateValue() {
return dateValue;
}
@@ -98,7 +98,7 @@ public class TestContextItem00A implements Serializable {
*
* @param dateValue the date value
*/
- public void setDateValue(final TestContextItem008 dateValue) {
+ public void setDateValue(final TestContextDateItem dateValue) {
this.dateValue = dateValue;
}
@@ -209,7 +209,7 @@ public class TestContextItem00A implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem00A other = (TestContextItem00A) obj;
+ final TestContextDateLocaleItem other = (TestContextDateLocaleItem) obj;
if (dateValue == null) {
if (other.dateValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem009.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
index f3e89535f..7d3ed80d5 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem009.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
@@ -26,21 +26,21 @@ import java.util.TimeZone;
/**
* The Class TestContextItem009.
*/
-public class TestContextItem009 implements Serializable {
+public class TestContextDateTzItem implements Serializable {
private static final long serialVersionUID = 5604426823170331706L;
private static final int HASH_PRIME_1 = 31;
private static final int HASH_PRIME_2 = 1231;
private static final int HASH_PRIME_3 = 1237;
- private TestContextItem008 dateValue = new TestContextItem008(System.currentTimeMillis());
+ private TestContextDateItem dateValue = new TestContextDateItem(System.currentTimeMillis());
private String timeZoneString = TimeZone.getTimeZone("Europe/Dublin").getDisplayName();
private boolean dst = false;
/**
* The Constructor.
*/
- public TestContextItem009() {
+ public TestContextDateTzItem() {
dst = true;
}
@@ -51,7 +51,7 @@ public class TestContextItem009 implements Serializable {
* @param tzValue the tz value
* @param dst the dst
*/
- public TestContextItem009(final TestContextItem008 dateValue, final String tzValue, final boolean dst) {
+ public TestContextDateTzItem(final TestContextDateItem dateValue, final String tzValue, final boolean dst) {
this.dateValue = dateValue;
this.timeZoneString = TimeZone.getTimeZone(tzValue).getDisplayName();
this.dst = dst;
@@ -62,7 +62,7 @@ public class TestContextItem009 implements Serializable {
*
* @param original the original
*/
- public TestContextItem009(final TestContextItem009 original) {
+ public TestContextDateTzItem(final TestContextDateTzItem original) {
this.dateValue = original.dateValue;
this.timeZoneString = original.timeZoneString;
this.dst = original.dst;
@@ -73,7 +73,7 @@ public class TestContextItem009 implements Serializable {
*
* @return the date value
*/
- public TestContextItem008 getDateValue() {
+ public TestContextDateItem getDateValue() {
return dateValue;
}
@@ -82,7 +82,7 @@ public class TestContextItem009 implements Serializable {
*
* @param dateValue the date value
*/
- public void setDateValue(final TestContextItem008 dateValue) {
+ public void setDateValue(final TestContextDateItem dateValue) {
this.dateValue = dateValue;
}
@@ -153,7 +153,7 @@ public class TestContextItem009 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem009 other = (TestContextItem009) obj;
+ final TestContextDateTzItem other = (TestContextDateTzItem) obj;
if (dateValue == null) {
if (other.dateValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem005.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
index d8a3352ce..ac4f5069f 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem005.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem005.
*/
-public class TestContextItem005 implements Serializable {
+public class TestContextDoubleItem implements Serializable {
private static final long serialVersionUID = -2958758261076734821L;
private static final int HASH_PRIME_1 = 31;
@@ -36,14 +36,14 @@ public class TestContextItem005 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem005() {}
+ public TestContextDoubleItem() {}
/**
* The Constructor.
*
* @param doubleValue the double value
*/
- public TestContextItem005(final Double doubleValue) {
+ public TestContextDoubleItem(final Double doubleValue) {
this.doubleValue = doubleValue;
}
@@ -96,7 +96,7 @@ public class TestContextItem005 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem005 other = (TestContextItem005) obj;
+ final TestContextDoubleItem other = (TestContextDoubleItem) obj;
if (Double.doubleToLongBits(doubleValue) != Double.doubleToLongBits(other.doubleValue)) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem004.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
index 1370db17f..cd8165251 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem004.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem004.
*/
-public class TestContextItem004 implements Serializable {
+public class TestContextFloatItem implements Serializable {
private static final long serialVersionUID = -3359180576903272400L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@ public class TestContextItem004 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem004() {}
+ public TestContextFloatItem() {}
/**
* The Constructor.
*
* @param floatValue the float value
*/
- public TestContextItem004(final Float floatValue) {
+ public TestContextFloatItem(final Float floatValue) {
this.floatValue = floatValue;
}
@@ -93,7 +93,7 @@ public class TestContextItem004 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem004 other = (TestContextItem004) obj;
+ final TestContextFloatItem other = (TestContextFloatItem) obj;
if (Float.floatToIntBits(floatValue) != Float.floatToIntBits(other.floatValue)) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem002.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
index 3b5242f6b..898302716 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem002.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem002.
*/
-public class TestContextItem002 implements Serializable {
+public class TestContextIntItem implements Serializable {
private static final long serialVersionUID = -8978435658277900984L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@ public class TestContextItem002 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem002() {}
+ public TestContextIntItem() {}
/**
* The Constructor.
*
* @param intValue the int value
*/
- public TestContextItem002(final Integer intValue) {
+ public TestContextIntItem(final Integer intValue) {
this.intValue = intValue;
}
@@ -51,7 +51,7 @@ public class TestContextItem002 implements Serializable {
*
* @param original the original
*/
- public TestContextItem002(final TestContextItem002 original) {
+ public TestContextIntItem(final TestContextIntItem original) {
this.intValue = original.intValue;
}
@@ -102,7 +102,7 @@ public class TestContextItem002 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem002 other = (TestContextItem002) obj;
+ final TestContextIntItem other = (TestContextIntItem) obj;
if (intValue != other.intValue) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem003.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
index e7532ecd8..be3ee60f8 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem003.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem003.
*/
-public class TestContextItem003 implements Serializable {
+public class TestContextLongItem implements Serializable {
private static final long serialVersionUID = 3599267534512489386L;
private static final int HASH_PRIME_1 = 31;
@@ -36,14 +36,14 @@ public class TestContextItem003 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem003() {}
+ public TestContextLongItem() {}
/**
* The Constructor.
*
* @param longValue the long value
*/
- public TestContextItem003(final Long longValue) {
+ public TestContextLongItem(final Long longValue) {
this.longValue = longValue;
}
@@ -94,7 +94,7 @@ public class TestContextItem003 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem003 other = (TestContextItem003) obj;
+ final TestContextLongItem other = (TestContextLongItem) obj;
if (longValue != other.longValue) {
return false;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem007.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
index 21c6f8cdf..215868d11 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem007.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem007.
*/
-public class TestContextItem007 implements Serializable {
+public class TestContextLongObjectItem implements Serializable {
private static final long serialVersionUID = -1029406737866392421L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@ public class TestContextItem007 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem007() {}
+ public TestContextLongObjectItem() {}
/**
* The Constructor.
*
* @param longValue the long value
*/
- public TestContextItem007(final Long longValue) {
+ public TestContextLongObjectItem(final Long longValue) {
this.longValue = longValue;
}
@@ -93,7 +93,7 @@ public class TestContextItem007 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem007 other = (TestContextItem007) obj;
+ final TestContextLongObjectItem other = (TestContextLongObjectItem) obj;
if (longValue == null) {
if (other.longValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem006.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
index 5fd2f9d6b..6c9fcb412 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem006.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* The Class TestContextItem006.
*/
-public class TestContextItem006 implements Serializable {
+public class TestContextStringItem implements Serializable {
private static final long serialVersionUID = -1074772190611125121L;
private static final int HASH_PRIME_1 = 31;
@@ -35,14 +35,14 @@ public class TestContextItem006 implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem006() {}
+ public TestContextStringItem() {}
/**
* The Constructor.
*
* @param stringValue the string value
*/
- public TestContextItem006(final String stringValue) {
+ public TestContextStringItem(final String stringValue) {
this.stringValue = stringValue;
}
@@ -93,7 +93,7 @@ public class TestContextItem006 implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem006 other = (TestContextItem006) obj;
+ final TestContextStringItem other = (TestContextStringItem) obj;
if (stringValue == null) {
if (other.stringValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00C.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
index 6c912977a..eed0c1a2f 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00C.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
@@ -27,7 +27,7 @@ import java.util.TreeMap;
/**
* The Class TestContextItem00C.
*/
-public class TestContextItem00C implements Serializable {
+public class TestContextTreeMapItem implements Serializable {
private static final long serialVersionUID = -7497746259264651884L;
private static final int HASH_PRIME_1 = 31;
@@ -37,14 +37,14 @@ public class TestContextItem00C implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem00C() {}
+ public TestContextTreeMapItem() {}
/**
* The Constructor.
*
* @param mapValue the map value
*/
- public TestContextItem00C(final Map<String, String> mapValue) {
+ public TestContextTreeMapItem(final Map<String, String> mapValue) {
this.mapValue = mapValue;
}
@@ -98,7 +98,7 @@ public class TestContextItem00C implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem00C other = (TestContextItem00C) obj;
+ final TestContextTreeMapItem other = (TestContextTreeMapItem) obj;
if (mapValue == null) {
if (other.mapValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00B.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
index 4990b1b9e..fe47c1af0 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextItem00B.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
@@ -27,7 +27,7 @@ import java.util.TreeSet;
/**
* The Class TestContextItem00B.
*/
-public class TestContextItem00B implements Serializable {
+public class TestContextTreeSetItem implements Serializable {
private static final long serialVersionUID = 1254589722957250388L;
private static final int HASH_PRIME_1 = 31;
@@ -37,21 +37,21 @@ public class TestContextItem00B implements Serializable {
/**
* The Constructor.
*/
- public TestContextItem00B() {}
+ public TestContextTreeSetItem() {}
/**
* The Constructor.
*
* @param setArray the set array
*/
- public TestContextItem00B(final String[] setArray) {}
+ public TestContextTreeSetItem(final String[] setArray) {}
/**
* The Constructor.
*
* @param setValue the set value
*/
- public TestContextItem00B(final TreeSet<String> setValue) {
+ public TestContextTreeSetItem(final TreeSet<String> setValue) {
this.setValue = setValue;
}
@@ -105,7 +105,7 @@ public class TestContextItem00B implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- final TestContextItem00B other = (TestContextItem00B) obj;
+ final TestContextTreeSetItem other = (TestContextTreeSetItem) obj;
if (setValue == null) {
if (other.setValue != null) {
return false;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
index 11a1af1e3..5c63c2ecb 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
@@ -30,26 +30,26 @@ public class TestExternalContextItem implements Serializable {
private static final int HASH_PRIME_1 = 31;
- private TestContextItem000 testExternalContextItem000;
- private TestContextItem001 testExternalContextItem001;
- private TestContextItem002 testExternalContextItem002;
- private TestContextItem003 testExternalContextItem003;
- private TestContextItem004 testExternalContextItem004;
- private TestContextItem005 testExternalContextItem005;
- private TestContextItem006 testExternalContextItem006;
- private TestContextItem007 testExternalContextItem007;
- private TestContextItem008 testExternalContextItem008;
- private TestContextItem009 testExternalContextItem009;
- private TestContextItem00A testExternalContextItem00A;
- private TestContextItem00B testExternalContextItem00B;
- private TestContextItem00C testExternalContextItem00C;
+ private TestContextBooleanItem testExternalContextItem000;
+ private TestContextByteItem testExternalContextItem001;
+ private TestContextIntItem testExternalContextItem002;
+ private TestContextLongItem testExternalContextItem003;
+ private TestContextFloatItem testExternalContextItem004;
+ private TestContextDoubleItem testExternalContextItem005;
+ private TestContextStringItem testExternalContextItem006;
+ private TestContextLongObjectItem testExternalContextItem007;
+ private TestContextDateItem testExternalContextItem008;
+ private TestContextDateTzItem testExternalContextItem009;
+ private TestContextDateLocaleItem testExternalContextItem00A;
+ private TestContextTreeSetItem testExternalContextItem00B;
+ private TestContextTreeMapItem testExternalContextItem00C;
/**
* Gets the test external context item 000.
*
* @return the test external context item 000
*/
- public TestContextItem000 getTestExternalContextItem000() {
+ public TestContextBooleanItem getTestExternalContextItem000() {
return testExternalContextItem000;
}
@@ -58,7 +58,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem000 the test external context item 000
*/
- public void setTestExternalContextItem000(final TestContextItem000 testExternalContextItem000) {
+ public void setTestExternalContextItem000(final TestContextBooleanItem testExternalContextItem000) {
this.testExternalContextItem000 = testExternalContextItem000;
}
@@ -67,7 +67,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 001
*/
- public TestContextItem001 getTestExternalContextItem001() {
+ public TestContextByteItem getTestExternalContextItem001() {
return testExternalContextItem001;
}
@@ -76,7 +76,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem001 the test external context item 001
*/
- public void setTestExternalContextItem001(final TestContextItem001 testExternalContextItem001) {
+ public void setTestExternalContextItem001(final TestContextByteItem testExternalContextItem001) {
this.testExternalContextItem001 = testExternalContextItem001;
}
@@ -85,7 +85,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 002
*/
- public TestContextItem002 getTestExternalContextItem002() {
+ public TestContextIntItem getTestExternalContextItem002() {
return testExternalContextItem002;
}
@@ -94,7 +94,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem002 the test external context item 002
*/
- public void setTestExternalContextItem002(final TestContextItem002 testExternalContextItem002) {
+ public void setTestExternalContextItem002(final TestContextIntItem testExternalContextItem002) {
this.testExternalContextItem002 = testExternalContextItem002;
}
@@ -103,7 +103,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 003
*/
- public TestContextItem003 getTestExternalContextItem003() {
+ public TestContextLongItem getTestExternalContextItem003() {
return testExternalContextItem003;
}
@@ -112,7 +112,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem003 the test external context item 003
*/
- public void setTestExternalContextItem003(final TestContextItem003 testExternalContextItem003) {
+ public void setTestExternalContextItem003(final TestContextLongItem testExternalContextItem003) {
this.testExternalContextItem003 = testExternalContextItem003;
}
@@ -121,7 +121,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 004
*/
- public TestContextItem004 getTestExternalContextItem004() {
+ public TestContextFloatItem getTestExternalContextItem004() {
return testExternalContextItem004;
}
@@ -130,7 +130,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem004 the test external context item 004
*/
- public void setTestExternalContextItem004(final TestContextItem004 testExternalContextItem004) {
+ public void setTestExternalContextItem004(final TestContextFloatItem testExternalContextItem004) {
this.testExternalContextItem004 = testExternalContextItem004;
}
@@ -139,7 +139,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 005
*/
- public TestContextItem005 getTestExternalContextItem005() {
+ public TestContextDoubleItem getTestExternalContextItem005() {
return testExternalContextItem005;
}
@@ -148,7 +148,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem005 the test external context item 005
*/
- public void setTestExternalContextItem005(final TestContextItem005 testExternalContextItem005) {
+ public void setTestExternalContextItem005(final TestContextDoubleItem testExternalContextItem005) {
this.testExternalContextItem005 = testExternalContextItem005;
}
@@ -157,7 +157,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 006
*/
- public TestContextItem006 getTestExternalContextItem006() {
+ public TestContextStringItem getTestExternalContextItem006() {
return testExternalContextItem006;
}
@@ -166,7 +166,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem006 the test external context item 006
*/
- public void setTestExternalContextItem006(final TestContextItem006 testExternalContextItem006) {
+ public void setTestExternalContextItem006(final TestContextStringItem testExternalContextItem006) {
this.testExternalContextItem006 = testExternalContextItem006;
}
@@ -175,7 +175,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 007
*/
- public TestContextItem007 getTestExternalContextItem007() {
+ public TestContextLongObjectItem getTestExternalContextItem007() {
return testExternalContextItem007;
}
@@ -184,7 +184,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem007 the test external context item 007
*/
- public void setTestExternalContextItem007(final TestContextItem007 testExternalContextItem007) {
+ public void setTestExternalContextItem007(final TestContextLongObjectItem testExternalContextItem007) {
this.testExternalContextItem007 = testExternalContextItem007;
}
@@ -193,7 +193,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 008
*/
- public TestContextItem008 getTestExternalContextItem008() {
+ public TestContextDateItem getTestExternalContextItem008() {
return testExternalContextItem008;
}
@@ -202,7 +202,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem008 the test external context item 008
*/
- public void setTestExternalContextItem008(final TestContextItem008 testExternalContextItem008) {
+ public void setTestExternalContextItem008(final TestContextDateItem testExternalContextItem008) {
this.testExternalContextItem008 = testExternalContextItem008;
}
@@ -211,7 +211,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 009
*/
- public TestContextItem009 getTestExternalContextItem009() {
+ public TestContextDateTzItem getTestExternalContextItem009() {
return testExternalContextItem009;
}
@@ -220,7 +220,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem009 the test external context item 009
*/
- public void setTestExternalContextItem009(final TestContextItem009 testExternalContextItem009) {
+ public void setTestExternalContextItem009(final TestContextDateTzItem testExternalContextItem009) {
this.testExternalContextItem009 = testExternalContextItem009;
}
@@ -229,7 +229,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 00 A
*/
- public TestContextItem00A getTestExternalContextItem00A() {
+ public TestContextDateLocaleItem getTestExternalContextItem00A() {
return testExternalContextItem00A;
}
@@ -238,7 +238,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem00A the test external context item 00 A
*/
- public void setTestExternalContextItem00A(final TestContextItem00A testExternalContextItem00A) {
+ public void setTestExternalContextItem00A(final TestContextDateLocaleItem testExternalContextItem00A) {
this.testExternalContextItem00A = testExternalContextItem00A;
}
@@ -247,7 +247,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 00 B
*/
- public TestContextItem00B getTestExternalContextItem00B() {
+ public TestContextTreeSetItem getTestExternalContextItem00B() {
return testExternalContextItem00B;
}
@@ -256,7 +256,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem00B the test external context item 00 B
*/
- public void setTestExternalContextItem00B(final TestContextItem00B testExternalContextItem00B) {
+ public void setTestExternalContextItem00B(final TestContextTreeSetItem testExternalContextItem00B) {
this.testExternalContextItem00B = testExternalContextItem00B;
}
@@ -265,7 +265,7 @@ public class TestExternalContextItem implements Serializable {
*
* @return the test external context item 00 C
*/
- public TestContextItem00C getTestExternalContextItem00C() {
+ public TestContextTreeMapItem getTestExternalContextItem00C() {
return testExternalContextItem00C;
}
@@ -274,7 +274,7 @@ public class TestExternalContextItem implements Serializable {
*
* @param testExternalContextItem00C the test external context item 00 C
*/
- public void setTestExternalContextItem00C(final TestContextItem00C testExternalContextItem00C) {
+ public void setTestExternalContextItem00C(final TestContextTreeMapItem testExternalContextItem00C) {
this.testExternalContextItem00C = testExternalContextItem00C;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
index 2e893d980..9953a1a95 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
@@ -30,26 +30,26 @@ public class TestGlobalContextItem implements Serializable {
private static final int HASH_PRIME_1 = 31;
- private TestContextItem000 testGlobalContextItem000;
- private TestContextItem001 testGlobalContextItem001;
- private TestContextItem002 testGlobalContextItem002;
- private TestContextItem003 testGlobalContextItem003;
- private TestContextItem004 testGlobalContextItem004;
- private TestContextItem005 testGlobalContextItem005;
- private TestContextItem006 testGlobalContextItem006;
- private TestContextItem007 testGlobalContextItem007;
- private TestContextItem008 testGlobalContextItem008;
- private TestContextItem009 testGlobalContextItem009;
- private TestContextItem00A testGlobalContextItem00A;
- private TestContextItem00B testGlobalContextItem00B;
- private TestContextItem00C testGlobalContextItem00C;
+ private TestContextBooleanItem testGlobalContextItem000;
+ private TestContextByteItem testGlobalContextItem001;
+ private TestContextIntItem testGlobalContextItem002;
+ private TestContextLongItem testGlobalContextItem003;
+ private TestContextFloatItem testGlobalContextItem004;
+ private TestContextDoubleItem testGlobalContextItem005;
+ private TestContextStringItem testGlobalContextItem006;
+ private TestContextLongObjectItem testGlobalContextItem007;
+ private TestContextDateItem testGlobalContextItem008;
+ private TestContextDateTzItem testGlobalContextItem009;
+ private TestContextDateLocaleItem testGlobalContextItem00A;
+ private TestContextTreeSetItem testGlobalContextItem00B;
+ private TestContextTreeMapItem testGlobalContextItem00C;
/**
* Gets the test global context item 000.
*
* @return the test global context item 000
*/
- public TestContextItem000 getTestGlobalContextItem000() {
+ public TestContextBooleanItem getTestGlobalContextItem000() {
return testGlobalContextItem000;
}
@@ -58,7 +58,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem000 the test global context item 000
*/
- public void setTestGlobalContextItem000(final TestContextItem000 testGlobalContextItem000) {
+ public void setTestGlobalContextItem000(final TestContextBooleanItem testGlobalContextItem000) {
this.testGlobalContextItem000 = testGlobalContextItem000;
}
@@ -67,7 +67,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 001
*/
- public TestContextItem001 getTestGlobalContextItem001() {
+ public TestContextByteItem getTestGlobalContextItem001() {
return testGlobalContextItem001;
}
@@ -76,7 +76,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem001 the test global context item 001
*/
- public void setTestGlobalContextItem001(final TestContextItem001 testGlobalContextItem001) {
+ public void setTestGlobalContextItem001(final TestContextByteItem testGlobalContextItem001) {
this.testGlobalContextItem001 = testGlobalContextItem001;
}
@@ -85,7 +85,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 002
*/
- public TestContextItem002 getTestGlobalContextItem002() {
+ public TestContextIntItem getTestGlobalContextItem002() {
return testGlobalContextItem002;
}
@@ -94,7 +94,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem002 the test global context item 002
*/
- public void setTestGlobalContextItem002(final TestContextItem002 testGlobalContextItem002) {
+ public void setTestGlobalContextItem002(final TestContextIntItem testGlobalContextItem002) {
this.testGlobalContextItem002 = testGlobalContextItem002;
}
@@ -103,7 +103,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 003
*/
- public TestContextItem003 getTestGlobalContextItem003() {
+ public TestContextLongItem getTestGlobalContextItem003() {
return testGlobalContextItem003;
}
@@ -112,7 +112,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem003 the test global context item 003
*/
- public void setTestGlobalContextItem003(final TestContextItem003 testGlobalContextItem003) {
+ public void setTestGlobalContextItem003(final TestContextLongItem testGlobalContextItem003) {
this.testGlobalContextItem003 = testGlobalContextItem003;
}
@@ -121,7 +121,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 004
*/
- public TestContextItem004 getTestGlobalContextItem004() {
+ public TestContextFloatItem getTestGlobalContextItem004() {
return testGlobalContextItem004;
}
@@ -130,7 +130,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem004 the test global context item 004
*/
- public void setTestGlobalContextItem004(final TestContextItem004 testGlobalContextItem004) {
+ public void setTestGlobalContextItem004(final TestContextFloatItem testGlobalContextItem004) {
this.testGlobalContextItem004 = testGlobalContextItem004;
}
@@ -139,7 +139,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 005
*/
- public TestContextItem005 getTestGlobalContextItem005() {
+ public TestContextDoubleItem getTestGlobalContextItem005() {
return testGlobalContextItem005;
}
@@ -148,7 +148,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem005 the test global context item 005
*/
- public void setTestGlobalContextItem005(final TestContextItem005 testGlobalContextItem005) {
+ public void setTestGlobalContextItem005(final TestContextDoubleItem testGlobalContextItem005) {
this.testGlobalContextItem005 = testGlobalContextItem005;
}
@@ -157,7 +157,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 006
*/
- public TestContextItem006 getTestGlobalContextItem006() {
+ public TestContextStringItem getTestGlobalContextItem006() {
return testGlobalContextItem006;
}
@@ -166,7 +166,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem006 the test global context item 006
*/
- public void setTestGlobalContextItem006(final TestContextItem006 testGlobalContextItem006) {
+ public void setTestGlobalContextItem006(final TestContextStringItem testGlobalContextItem006) {
this.testGlobalContextItem006 = testGlobalContextItem006;
}
@@ -175,7 +175,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 007
*/
- public TestContextItem007 getTestGlobalContextItem007() {
+ public TestContextLongObjectItem getTestGlobalContextItem007() {
return testGlobalContextItem007;
}
@@ -184,7 +184,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem007 the test global context item 007
*/
- public void setTestGlobalContextItem007(final TestContextItem007 testGlobalContextItem007) {
+ public void setTestGlobalContextItem007(final TestContextLongObjectItem testGlobalContextItem007) {
this.testGlobalContextItem007 = testGlobalContextItem007;
}
@@ -193,7 +193,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 008
*/
- public TestContextItem008 getTestGlobalContextItem008() {
+ public TestContextDateItem getTestGlobalContextItem008() {
return testGlobalContextItem008;
}
@@ -202,7 +202,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem008 the test global context item 008
*/
- public void setTestGlobalContextItem008(final TestContextItem008 testGlobalContextItem008) {
+ public void setTestGlobalContextItem008(final TestContextDateItem testGlobalContextItem008) {
this.testGlobalContextItem008 = testGlobalContextItem008;
}
@@ -211,7 +211,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 009
*/
- public TestContextItem009 getTestGlobalContextItem009() {
+ public TestContextDateTzItem getTestGlobalContextItem009() {
return testGlobalContextItem009;
}
@@ -220,7 +220,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem009 the test global context item 009
*/
- public void setTestGlobalContextItem009(final TestContextItem009 testGlobalContextItem009) {
+ public void setTestGlobalContextItem009(final TestContextDateTzItem testGlobalContextItem009) {
this.testGlobalContextItem009 = testGlobalContextItem009;
}
@@ -229,7 +229,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 00 A
*/
- public TestContextItem00A getTestGlobalContextItem00A() {
+ public TestContextDateLocaleItem getTestGlobalContextItem00A() {
return testGlobalContextItem00A;
}
@@ -238,7 +238,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem00A the test global context item 00 A
*/
- public void setTestGlobalContextItem00A(final TestContextItem00A testGlobalContextItem00A) {
+ public void setTestGlobalContextItem00A(final TestContextDateLocaleItem testGlobalContextItem00A) {
this.testGlobalContextItem00A = testGlobalContextItem00A;
}
@@ -247,7 +247,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 00 B
*/
- public TestContextItem00B getTestGlobalContextItem00B() {
+ public TestContextTreeSetItem getTestGlobalContextItem00B() {
return testGlobalContextItem00B;
}
@@ -256,7 +256,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem00B the test global context item 00 B
*/
- public void setTestGlobalContextItem00B(final TestContextItem00B testGlobalContextItem00B) {
+ public void setTestGlobalContextItem00B(final TestContextTreeSetItem testGlobalContextItem00B) {
this.testGlobalContextItem00B = testGlobalContextItem00B;
}
@@ -265,7 +265,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @return the test global context item 00 C
*/
- public TestContextItem00C getTestGlobalContextItem00C() {
+ public TestContextTreeMapItem getTestGlobalContextItem00C() {
return testGlobalContextItem00C;
}
@@ -274,7 +274,7 @@ public class TestGlobalContextItem implements Serializable {
*
* @param testGlobalContextItem00C the test global context item 00 C
*/
- public void setTestGlobalContextItem00C(final TestContextItem00C testGlobalContextItem00C) {
+ public void setTestGlobalContextItem00C(final TestContextTreeMapItem testGlobalContextItem00C) {
this.testGlobalContextItem00C = testGlobalContextItem00C;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
index e9381ded4..fc728a7ae 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
@@ -30,19 +30,19 @@ public class TestPolicyContextItem implements Serializable {
private static final int HASH_PRIME_1 = 31;
- private TestContextItem006 testPolicyContextItem000;
- private TestContextItem003 testPolicyContextItem001;
- private TestContextItem005 testPolicyContextItem002;
- private TestContextItem000 testPolicyContextItem003;
- private TestContextItem003 testPolicyContextItem004;
- private TestContextItem00C testPolicyContextItem005;
+ private TestContextStringItem testPolicyContextItem000;
+ private TestContextLongItem testPolicyContextItem001;
+ private TestContextDoubleItem testPolicyContextItem002;
+ private TestContextBooleanItem testPolicyContextItem003;
+ private TestContextLongItem testPolicyContextItem004;
+ private TestContextTreeMapItem testPolicyContextItem005;
/**
* Gets the test policy context item 000.
*
* @return the test policy context item 000
*/
- public TestContextItem006 getTestPolicyContextItem000() {
+ public TestContextStringItem getTestPolicyContextItem000() {
return testPolicyContextItem000;
}
@@ -51,7 +51,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @param testPolicyContextItem000 the test policy context item 000
*/
- public void setTestPolicyContextItem000(final TestContextItem006 testPolicyContextItem000) {
+ public void setTestPolicyContextItem000(final TestContextStringItem testPolicyContextItem000) {
this.testPolicyContextItem000 = testPolicyContextItem000;
}
@@ -60,7 +60,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @return the test policy context item 001
*/
- public TestContextItem003 getTestPolicyContextItem001() {
+ public TestContextLongItem getTestPolicyContextItem001() {
return testPolicyContextItem001;
}
@@ -69,7 +69,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @param testPolicyContextItem001 the test policy context item 001
*/
- public void setTestPolicyContextItem001(final TestContextItem003 testPolicyContextItem001) {
+ public void setTestPolicyContextItem001(final TestContextLongItem testPolicyContextItem001) {
this.testPolicyContextItem001 = testPolicyContextItem001;
}
@@ -78,7 +78,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @return the test policy context item 002
*/
- public TestContextItem005 getTestPolicyContextItem002() {
+ public TestContextDoubleItem getTestPolicyContextItem002() {
return testPolicyContextItem002;
}
@@ -87,7 +87,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @param testPolicyContextItem002 the test policy context item 002
*/
- public void setTestPolicyContextItem002(final TestContextItem005 testPolicyContextItem002) {
+ public void setTestPolicyContextItem002(final TestContextDoubleItem testPolicyContextItem002) {
this.testPolicyContextItem002 = testPolicyContextItem002;
}
@@ -96,7 +96,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @return the test policy context item 003
*/
- public TestContextItem000 getTestPolicyContextItem003() {
+ public TestContextBooleanItem getTestPolicyContextItem003() {
return testPolicyContextItem003;
}
@@ -105,7 +105,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @param testPolicyContextItem003 the test policy context item 003
*/
- public void setTestPolicyContextItem003(final TestContextItem000 testPolicyContextItem003) {
+ public void setTestPolicyContextItem003(final TestContextBooleanItem testPolicyContextItem003) {
this.testPolicyContextItem003 = testPolicyContextItem003;
}
@@ -114,7 +114,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @return the test policy context item 004
*/
- public TestContextItem003 getTestPolicyContextItem004() {
+ public TestContextLongItem getTestPolicyContextItem004() {
return testPolicyContextItem004;
}
@@ -123,7 +123,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @param testPolicyContextItem004 the test policy context item 004
*/
- public void setTestPolicyContextItem004(final TestContextItem003 testPolicyContextItem004) {
+ public void setTestPolicyContextItem004(final TestContextLongItem testPolicyContextItem004) {
this.testPolicyContextItem004 = testPolicyContextItem004;
}
@@ -132,7 +132,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @return the test policy context item 005
*/
- public TestContextItem00C getTestPolicyContextItem005() {
+ public TestContextTreeMapItem getTestPolicyContextItem005() {
return testPolicyContextItem005;
}
@@ -141,7 +141,7 @@ public class TestPolicyContextItem implements Serializable {
*
* @param testPolicyContextItem005 the test policy context item 005
*/
- public void setTestPolicyContextItem005(final TestContextItem00C testPolicyContextItem005) {
+ public void setTestPolicyContextItem005(final TestContextTreeMapItem testPolicyContextItem005) {
this.testPolicyContextItem005 = testPolicyContextItem005;
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
index d57b3fda3..d57b3fda3 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
index ae0fea7ea..189208fd5 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
@@ -20,6 +20,11 @@
package org.onap.policy.apex.context.test.distribution;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.onap.policy.apex.context.test.utils.Constants.APEX_DISTRIBUTOR;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
import java.io.IOException;
import org.onap.policy.apex.context.ContextAlbum;
@@ -40,7 +45,6 @@ import org.slf4j.ext.XLoggerFactory;
* The Class ContextAlbumUpdate is used to test Context Album updates.
*/
public class ContextAlbumUpdate {
- // Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextAlbumUpdate.class);
/**
@@ -53,21 +57,22 @@ public class ContextAlbumUpdate {
public void testContextAlbumUpdate() throws ApexModelException, IOException, ApexException {
LOGGER.debug("Running TestContextAlbumUpdate test . . .");
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
+ final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
final AxContextModel longModel = TestContextAlbumFactory.createLongContextModel();
contextDistributor.registerModel(longModel);
- final AxContextAlbum longAlbum1Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum1", "0.0.1"));
+ final AxContextAlbum longAlbum1Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum1", VERSION));
final ContextAlbum longAlbum1 = contextDistributor.createContextAlbum(longAlbum1Def.getKey());
- assert (longAlbum1 != null);
- final AxContextAlbum longAlbum2Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum2", "0.0.1"));
+ assertNotNull(longAlbum1);
+
+ final AxContextAlbum longAlbum2Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum2", VERSION));
final ContextAlbum longAlbum2 = contextDistributor.createContextAlbum(longAlbum2Def.getKey());
- assert (longAlbum2 != null);
- // CHECKSTYLE:OFF: checkstyle:magicNumber
+ assertNotNull(longAlbum2);
+
longAlbum1.put("0", (long) 0);
longAlbum1.put("1", (long) 1);
longAlbum1.put("2", (long) 2);
@@ -76,20 +81,21 @@ public class ContextAlbumUpdate {
final KeyedMapDifference<String, Object> result0 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (0 == result0.getDifferentValues().size());
- assert (0 == result0.getIdenticalValues().size());
- assert (0 == result0.getRightOnly().size());
- assert (4 == result0.getLeftOnly().size());
+ assertEquals(0, result0.getDifferentValues().size());
+ assertEquals(0, result0.getIdenticalValues().size());
+ assertEquals(0, result0.getRightOnly().size());
+ assertEquals(4, result0.getLeftOnly().size());
longAlbum2.putAll(longAlbum1);
final KeyedMapDifference<String, Object> result1 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (0 == result1.getDifferentValues().size());
- assert (4 == result1.getIdenticalValues().size());
- assert (0 == result1.getRightOnly().size());
- assert (0 == result1.getLeftOnly().size());
+
+ assertEquals(0, result1.getDifferentValues().size());
+ assertEquals(4, result1.getIdenticalValues().size());
+ assertEquals(0, result1.getRightOnly().size());
+ assertEquals(0, result1.getLeftOnly().size());
longAlbum1.put("4", (long) 4);
longAlbum2.put("5", (long) 5);
@@ -99,23 +105,21 @@ public class ContextAlbumUpdate {
final KeyedMapDifference<String, Object> result2 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (1 == result2.getDifferentValues().size());
- assert (4 == result2.getIdenticalValues().size());
- assert (1 == result2.getRightOnly().size());
- assert (1 == result2.getLeftOnly().size());
+ assertEquals(1, result2.getDifferentValues().size());
+ assertEquals(4, result2.getIdenticalValues().size());
+ assertEquals(1, result2.getRightOnly().size());
+ assertEquals(1, result2.getLeftOnly().size());
longAlbum1.remove("0");
longAlbum2.remove("3");
- // CHECKSTYLE:ON: checkstyle:magicNumber
final KeyedMapDifference<String, Object> result3 =
new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
- assert (1 == result3.getDifferentValues().size());
- assert (2 == result3.getIdenticalValues().size());
- assert (2 == result3.getRightOnly().size());
- assert (2 == result3.getLeftOnly().size());
-
+ assertEquals(1, result3.getDifferentValues().size());
+ assertEquals(2, result3.getIdenticalValues().size());
+ assertEquals(2, result3.getRightOnly().size());
+ assertEquals(2, result3.getLeftOnly().size());
contextDistributor.clear();
}
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
new file mode 100644
index 000000000..03ef650da
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
@@ -0,0 +1,552 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.test.distribution;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.onap.policy.apex.context.test.factory.TestContextAlbumFactory.createPolicyContextModel;
+import static org.onap.policy.apex.context.test.utils.Constants.BYTE_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAGE;
+import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT;
+import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.FLOAT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_KEY;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL_2;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL_3;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.PI_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.POLICY_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_EXT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_GLOBAL_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.TEST_POLICY_CONTEXT_ITEM;
+import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
+import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.ContextRuntimeException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextBooleanItem;
+import org.onap.policy.apex.context.test.concepts.TestContextByteItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateTzItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDoubleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextFloatItem;
+import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
+import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeSetItem;
+import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
+import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestContextInstantiation is used to test Apex context insitiation is correct.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class ContextInstantiation {
+
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
+
+ private final static TreeSet<String> TEST_TREE_SET = new TreeSet<>();
+ private final static Map<String, String> TEST_HASH_MAP = new HashMap<>();
+
+ static {
+ TEST_TREE_SET.add("one hundred");
+ TEST_TREE_SET.add("one hundred and one");
+ TEST_TREE_SET.add("one hundred and two");
+ TEST_TREE_SET.add("one hundred and three");
+ TEST_TREE_SET.add("one hundred and four");
+
+ TEST_HASH_MAP.put("0", "zero");
+ TEST_HASH_MAP.put("1", "one");
+ TEST_HASH_MAP.put("2", "two");
+ TEST_HASH_MAP.put("3", "three");
+ TEST_HASH_MAP.put("4", "four");
+
+ }
+
+ /**
+ * Test context instantiation.
+ *
+ * @throws ContextException the context exception
+ */
+ public void testContextInstantiation() throws ContextException {
+ LOGGER.debug("Running TestContextInstantiation test . . .");
+
+ final Distributor contextDistributor = getDistributor();
+
+ try {
+
+ final ContextAlbum policyContextAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION));
+
+ assertNotNull(policyContextAlbum);
+ policyContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+
+ final Date testDate = new Date();
+
+ final TestContextDateTzItem tci9 = getTestContextDateTzItem(testDate);
+ final TestContextDateLocaleItem tciA = getTestContextDateLocaleItem(testDate);
+
+ final TestPolicyContextItem policyContext = getTestPolicyContextItem(policyContextAlbum, testDate);
+
+ final Map<String, Object> valueMap0 = new HashMap<>();
+ valueMap0.put(TEST_POLICY_CONTEXT_ITEM, policyContext);
+
+ policyContextAlbum.putAll(valueMap0);
+
+ final TestPolicyContextItem contextItem =
+ (TestPolicyContextItem) policyContextAlbum.get(TEST_POLICY_CONTEXT_ITEM);
+ assertEquals(STRING_VAL, contextItem.getTestPolicyContextItem000().getStringValue());
+
+ assertEquals(LONG_VAL, contextItem.getTestPolicyContextItem001().getLongValue());
+ assertDouble(contextItem.getTestPolicyContextItem002().getDoubleValue(), PI_VAL);
+ assertTrue(contextItem.getTestPolicyContextItem003().getFlag());
+ assertEquals(contextItem.getTestPolicyContextItem004().getLongValue(), testDate.getTime());
+ assertEquals(contextItem.getTestPolicyContextItem005().getMapValue(), TEST_HASH_MAP);
+
+ final TestGlobalContextItem globalContext =
+ getTestGlobalContextItem(contextDistributor, testDate, tci9, tciA);
+
+ final Map<String, Object> valueMap1 = new HashMap<>();
+ valueMap1.put(GLOBAL_CONTEXT_KEY, globalContext);
+
+ final ContextAlbum globalContextAlbum = getContextAlbum(contextDistributor);
+
+ globalContextAlbum.putAll(valueMap1);
+
+ final TestGlobalContextItem globalContextItem =
+ (TestGlobalContextItem) globalContextAlbum.get(GLOBAL_CONTEXT_KEY);
+
+ assertFalse(globalContextItem.getTestGlobalContextItem000().getFlag());
+
+ assertEquals(BYTE_VAL, globalContextItem.getTestGlobalContextItem001().getByteValue());
+
+ assertEquals(INT_VAL, globalContextItem.getTestGlobalContextItem002().getIntValue());
+ assertEquals(LONG_VAL, globalContextItem.getTestGlobalContextItem003().getLongValue());
+ assertFloat(FLOAT_VAL, globalContextItem.getTestGlobalContextItem004().getFloatValue());
+
+ assertDouble(PI_VAL, globalContextItem.getTestGlobalContextItem005().getDoubleValue());
+ assertEquals(STRING_GLOBAL_VAL, globalContextItem.getTestGlobalContextItem006().getStringValue());
+
+ assertEquals(new Long(testDate.getTime()), globalContextItem.getTestGlobalContextItem007().getLongValue());
+ assertEquals(testDate, globalContextItem.getTestGlobalContextItem008().getDateValue());
+ assertEquals(tci9.getDateValue().getTime(),
+ globalContextItem.getTestGlobalContextItem009().getDateValue().getTime());
+
+ assertEquals(tciA.getDateValue().getTime(),
+ globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime());
+
+ assertEquals(TEST_TREE_SET, globalContextItem.getTestGlobalContextItem00B().getSetValue());
+ assertEquals(TEST_HASH_MAP, globalContextItem.getTestGlobalContextItem00C().getMapValue());
+
+ final AxContextModel externalContextModel = TestContextAlbumFactory.createExternalContextModel();
+
+ final TestContextDateTzItem tci9A = new TestContextDateTzItem(tci9);
+ final TestContextDateLocaleItem tciAA = new TestContextDateLocaleItem(tciA);
+ final TestExternalContextItem externalContext = getTestExternalContextItem(testDate, tci9A, tciAA);
+
+ final Map<String, Object> valueMap2 = new HashMap<>();
+ valueMap2.put(EXTERNAL_CONTEXT, externalContext);
+
+ contextDistributor.clear();
+ contextDistributor.init(new AxArtifactKey("ClearedandInittedDistributor", VERSION));
+ contextDistributor.registerModel(externalContextModel);
+
+ final AxArtifactKey axContextAlbumKey = new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION);
+ final ContextAlbum externalContextAlbum = contextDistributor.createContextAlbum(axContextAlbumKey);
+ assertNotNull(externalContextAlbum);
+ externalContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+
+ externalContextAlbum.putAll(valueMap2);
+ externalContextAlbum.getAlbumDefinition().setWritable(false);
+
+ TestExternalContextItem externalContextItem =
+ (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+
+ assertFalse(externalContextItem.getTestExternalContextItem000().getFlag());
+ assertEquals(BYTE_VAL, externalContextItem.getTestExternalContextItem001().getByteValue());
+ assertEquals(INT_VAL, externalContextItem.getTestExternalContextItem002().getIntValue());
+
+ assertFloat(LONG_VAL, externalContextItem.getTestExternalContextItem003().getLongValue());
+ assertFloat(FLOAT_VAL, externalContextItem.getTestExternalContextItem004().getFloatValue());
+
+ assertDouble(PI_VAL, externalContextItem.getTestExternalContextItem005().getDoubleValue());
+ assertEquals(STRING_EXT_VAL, externalContextItem.getTestExternalContextItem006().getStringValue());
+ assertEquals(new Long(testDate.getTime()),
+ externalContextItem.getTestExternalContextItem007().getLongValue());
+ assertEquals(testDate, externalContextItem.getTestExternalContextItem008().getDateValue());
+ assertEquals(tci9A.getDateValue().getTime(),
+ externalContextItem.getTestExternalContextItem009().getDateValue().getTime());
+
+ assertEquals(tciAA.getDateValue().getTime(),
+ externalContextItem.getTestExternalContextItem00A().getDateValue().getTime());
+ assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue());
+ assertEquals(TEST_HASH_MAP, externalContextItem.getTestExternalContextItem00C().getMapValue());
+
+ final Collection<Object> mapValues = externalContextAlbum.values();
+ assertTrue(externalContextAlbum.values().containsAll(mapValues));
+
+ // Check that clearing does not work
+ try {
+ externalContextAlbum.clear();
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"ExternalContextAlbum:0.0.1\" clear() not allowed on read only albums",
+ e.getMessage());
+ }
+
+ assertEquals(1, externalContextAlbum.size());
+
+ assertContextAlbumContains(externalContext, externalContextAlbum);
+
+ final Set<Entry<String, Object>> entrySet = externalContextAlbum.entrySet();
+ assertEquals(1, entrySet.size());
+
+ try {
+ externalContextAlbum.get(null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for get()",
+ e.getMessage());
+
+ }
+
+ final Object aObject = externalContextAlbum.get(EXTERNAL_CONTEXT);
+ assertEquals(aObject, externalContext);
+
+ // put null keys should fail, throws a runtime exception
+ try {
+ externalContextAlbum.put(null, null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()",
+ e.getMessage());
+ }
+
+ try {
+ externalContextAlbum.put("TestExternalContextItem00A", null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()",
+ e.getMessage());
+ }
+ assertEquals(tciAA, externalContextItem.getTestExternalContextItem00A());
+
+ // Should return the hash set
+ assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue());
+
+ assertTrue(externalContextAlbum.values().containsAll(mapValues));
+
+ // Set the write flag back as it should be
+ externalContextAlbum.getAlbumDefinition().setWritable(true);
+
+ // Put should return the previous contextItem
+ final TestExternalContextItem externalContextOther = new TestExternalContextItem();
+ externalContextOther.setTestExternalContextItem002(new TestContextIntItem());
+ externalContextOther.getTestExternalContextItem002().setIntValue(INT_VAL_2);
+
+ assertTrue(externalContextAlbum.put(EXTERNAL_CONTEXT, externalContextOther).equals(externalContext));
+ externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+ assertEquals(INT_VAL_2, externalContextItem.getTestExternalContextItem002().getIntValue());
+ assertTrue(externalContextAlbum.put(EXTERNAL_CONTEXT, externalContext).equals(externalContextOther));
+ externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+ assertEquals(INT_VAL_3, externalContextItem.getTestExternalContextItem002().getIntValue());
+
+ try {
+ externalContextAlbum.put("TestExternalContextItem00A", null);
+ } catch (final ContextRuntimeException e) {
+ assert (e.getMessage().equals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()"));
+ }
+ assertTrue(externalContextAlbum.get(EXTERNAL_CONTEXT).equals(externalContext));
+
+ try {
+ externalContextAlbum.put("TestExternalContextItemFFF", null);
+ } catch (final ContextRuntimeException e) {
+ assert (e.getMessage().equals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()"));
+ }
+ assertEquals(1, externalContextAlbum.size());
+
+ try {
+ externalContextAlbum.put("TestExternalContextItemFFF", null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()",
+ e.getMessage());
+ }
+ assertEquals(1, externalContextAlbum.size());
+
+ // Should ignore remove
+ externalContextAlbum.remove("TestExternalContextItem017");
+ assertEquals(1, externalContextAlbum.size());
+ assertEquals(1, externalContextAlbum.values().size());
+ assertTrue(externalContextAlbum.values().containsAll(mapValues));
+ } catch (final Exception exception) {
+ LOGGER.error("Unexpected Error:", exception);
+ throw exception;
+ } finally {
+ contextDistributor.clear();
+ }
+
+ }
+
+ private void assertContextAlbumContains(final TestExternalContextItem externalContext,
+ final ContextAlbum externalContextAlbum) {
+ try {
+ externalContextAlbum.containsKey(null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("null values are illegal on method parameter \"key\"", e.getMessage());
+ }
+
+ assertTrue(externalContextAlbum.containsKey(EXTERNAL_CONTEXT));
+ assertTrue(!externalContextAlbum.containsKey(GLOBAL_CONTEXT_KEY));
+
+ try {
+ externalContextAlbum.containsValue(null);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("null values are illegal on method parameter \"value\"", e.getMessage());
+ }
+
+ assertTrue(externalContextAlbum.containsValue(externalContext));
+ assertFalse(externalContextAlbum.containsValue("Hello"));
+ }
+
+ private ContextAlbum getContextAlbum(final Distributor contextDistributor) throws ContextException {
+ final ContextAlbum globalContextAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION));
+ assertNotNull(globalContextAlbum);
+ globalContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ return globalContextAlbum;
+ }
+
+ private TestGlobalContextItem getTestGlobalContextItem(final Distributor contextDistributor, final Date testDate,
+ final TestContextDateTzItem tci9, final TestContextDateLocaleItem tciA) throws ContextException {
+ final AxContextModel globalContextModel = TestContextAlbumFactory.createGlobalContextModel();
+ final TestGlobalContextItem globalContext = getTestGlobalContextItem(testDate, tci9, tciA);
+ contextDistributor.registerModel(globalContextModel);
+ return globalContext;
+ }
+
+ private TestPolicyContextItem getTestPolicyContextItem(final ContextAlbum policyContextAlbum, final Date testDate) {
+ final TestContextStringItem contextStringItem = new TestContextStringItem(STRING_VAL);
+ final TestContextLongItem contextLongItem = new TestContextLongItem(LONG_VAL);
+ final TestContextDoubleItem contextDoubleItem = new TestContextDoubleItem(PI_VAL);
+ final TestContextBooleanItem contextBooleanItem = new TestContextBooleanItem(true);
+ final TestContextLongItem contextLongItem2 = new TestContextLongItem(testDate.getTime());
+ final TestContextTreeMapItem contextTreeMapItem = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+ final Map<String, Object> valueMapA = new LinkedHashMap<>();
+ valueMapA.put("TestPolicyContextItem001", contextLongItem);
+ valueMapA.put("TestPolicyContextItem002", contextDoubleItem);
+ valueMapA.put("TestPolicyContextItem003", contextBooleanItem);
+ valueMapA.put("TestPolicyContextItem004", contextLongItem2);
+ valueMapA.put("TestPolicyContextItem005", contextTreeMapItem);
+ valueMapA.put("TestPolicyContextItem000", contextStringItem);
+
+ assertPutMethods(policyContextAlbum, contextStringItem, valueMapA);
+
+ final TestPolicyContextItem policyContext = new TestPolicyContextItem();
+
+ LOGGER.debug(policyContextAlbum.toString());
+
+ policyContext.setTestPolicyContextItem000(contextStringItem);
+ policyContext.setTestPolicyContextItem001(contextLongItem);
+ policyContext.setTestPolicyContextItem002(contextDoubleItem);
+ policyContext.setTestPolicyContextItem003(contextBooleanItem);
+ policyContext.setTestPolicyContextItem004(contextLongItem2);
+ policyContext.setTestPolicyContextItem005(contextTreeMapItem);
+ return policyContext;
+ }
+
+ private void assertPutMethods(final ContextAlbum policyContextAlbum, final TestContextStringItem contextStringItem,
+ final Map<String, Object> valueMapA) {
+ try {
+ policyContextAlbum.put("TestPolicyContextItem000", contextStringItem);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ getMessage("TestPolicyContextItem000", "TestContextItem006",
+ TestContextStringItem.class.getCanonicalName(), "stringValue=" + STRING_VAL),
+ e.getMessage());
+ }
+
+ try {
+ policyContextAlbum.putAll(valueMapA);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(getMessage("TestPolicyContextItem001", "TestContextItem003",
+ TestContextLongItem.class.getCanonicalName(), "longValue=" + INT_VAL_3), e.getMessage());
+ }
+ }
+
+ private AxContextModel getAxContextModel() {
+ final AxContextModel policyContextModel = createPolicyContextModel();
+ final AxValidationResult result = new AxValidationResult();
+ policyContextModel.validate(result);
+ LOGGER.debug(result.toString());
+
+ assertTrue(result.isValid());
+ return policyContextModel;
+ }
+
+ private TestContextDateLocaleItem getTestContextDateLocaleItem(final Date testDate) {
+ final TestContextDateLocaleItem tciA = new TestContextDateLocaleItem();
+ tciA.setDateValue(new TestContextDateItem(testDate));
+ tciA.setTZValue(TIME_ZONE.getDisplayName());
+ tciA.setDST(true);
+ tciA.setUTCOffset(-600);
+ tciA.setLocale(Locale.ENGLISH);
+ return tciA;
+ }
+
+ private TestContextDateTzItem getTestContextDateTzItem(final Date testDate) {
+ final TestContextDateTzItem tci9 = new TestContextDateTzItem();
+ tci9.setDateValue(new TestContextDateItem(testDate));
+ tci9.setTZValue(TIME_ZONE.getDisplayName());
+ tci9.setDST(true);
+ return tci9;
+ }
+
+ private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
+ final TestContextDateLocaleItem tciA) {
+ final TestGlobalContextItem globalContext = new TestGlobalContextItem();
+
+ final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
+ final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
+ final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
+ final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
+ final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
+ final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
+ final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
+ final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
+
+ final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate);
+ final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
+ final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+
+ globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
+ globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
+ globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
+ globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
+ globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
+ globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
+ globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
+ globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
+ globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
+ globalContext.setTestGlobalContextItem009(tci9);
+ globalContext.setTestGlobalContextItem00A(tciA);
+ globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
+ globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
+ return globalContext;
+ }
+
+ private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A,
+ final TestContextDateLocaleItem tciAA) {
+ final TestExternalContextItem externalContext = new TestExternalContextItem();
+
+ final TestContextBooleanItem testExternalContextItem000 = new TestContextBooleanItem(false);
+ final TestContextByteItem testExternalContextItem001 = new TestContextByteItem(BYTE_VAL);
+ final TestContextIntItem testExternalContextItem002 = new TestContextIntItem(INT_VAL);
+ final TestContextLongItem testExternalContextItem003 = new TestContextLongItem(LONG_VAL);
+ final TestContextFloatItem testExternalContextItem004 = new TestContextFloatItem(new Float(3.14159265359));
+ final TestContextDoubleItem testExternalContextItem005 = new TestContextDoubleItem(PI_VAL);
+ final TestContextStringItem testExternalContextItem006 = new TestContextStringItem(STRING_EXT_VAL);
+ final TestContextLongObjectItem testExternalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
+ final TestContextDateItem testExternalContextItem008 = new TestContextDateItem(testDate);
+ final TestContextTreeSetItem testExternalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
+ final TestContextTreeMapItem testExternalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+
+ externalContext.setTestExternalContextItem000(testExternalContextItem000);
+ externalContext.setTestExternalContextItem001(testExternalContextItem001);
+ externalContext.setTestExternalContextItem002(testExternalContextItem002);
+ externalContext.setTestExternalContextItem003(testExternalContextItem003);
+ externalContext.setTestExternalContextItem004(testExternalContextItem004);
+ externalContext.setTestExternalContextItem005(testExternalContextItem005);
+ externalContext.setTestExternalContextItem006(testExternalContextItem006);
+ externalContext.setTestExternalContextItem007(testExternalContextItem007);
+ externalContext.setTestExternalContextItem008(testExternalContextItem008);
+ externalContext.setTestExternalContextItem009(tci9A);
+ externalContext.setTestExternalContextItem00A(tciAA);
+ externalContext.setTestExternalContextItem00B(testExternalContextItem00B);
+ externalContext.setTestExternalContextItem00C(testExternalContextItem00C);
+ return externalContext;
+ }
+
+ private String getMessage(final String key, final String objName, final String clazzName, final String valString) {
+ return getMessage(key, objName, clazzName, valString, TestPolicyContextItem.class.getCanonicalName());
+ }
+
+ private String getMessage(final String key, final String objName, final String clazzName, final String valString,
+ final String compatibleClazzName) {
+ return "Failed to set context value for key \"" + key + "\" in album \"PolicyContextAlbum:0.0.1\": "
+ + "PolicyContextAlbum:0.0.1: object \"" + objName + " [" + valString + "]\" " + "of class \""
+ + clazzName + "\"" + " not compatible with class \"" + compatibleClazzName + "\"";
+ }
+
+ private void assertFloat(final float actual, final float expected) {
+ assertTrue(Float.compare(actual, expected) == 0);
+ }
+
+ private void assertDouble(final double actual, final double expected) {
+ assertTrue(Double.compare(actual, expected) == 0);
+ }
+
+
+ private Distributor getDistributor() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributorInit", VERSION);
+ final Distributor distributor = new DistributorFactory().getDistributor(distributorKey);
+ final AxContextModel policyContextModel = getAxContextModel();
+ distributor.registerModel(policyContextModel);
+ return distributor;
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
new file mode 100644
index 000000000..75d559724
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.test.distribution;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.onap.policy.apex.context.test.utils.Constants.APEX_DISTRIBUTOR;
+import static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAGE;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.MAP_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
+import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.ContextRuntimeException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestContextUpdate checks context updates.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class ContextUpdate {
+ private static final String ZERO = "zero";
+ private static final String _0 = "0";
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextUpdate.class);
+
+ /**
+ * Test context update.
+ *
+ * @throws ApexModelException the apex model exception
+ * @throws IOException the IO exception
+ * @throws ApexException the apex exception
+ */
+ public void testContextUpdate() throws ApexModelException, IOException, ApexException {
+ LOGGER.debug("Running TestContextUpdate test . . .");
+
+ final Distributor contextDistributor = getDistributor();
+
+ final ContextAlbum longContextAlbum = getContextAlbum(LONG_CONTEXT_ALBUM, contextDistributor);
+ final ContextAlbum dateContextAlbum = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+ final ContextAlbum mapContextAlbum = getContextAlbum(MAP_CONTEXT_ALBUM, contextDistributor);
+
+ final TestContextDateLocaleItem tciA = getTestContextDateLocaleItem();
+ final TestContextTreeMapItem tciC = getTestContextTreeMapItem();
+
+ longContextAlbum.put(_0, (long) 0);
+ longContextAlbum.put(_0, 0);
+ longContextAlbum.put(_0, _0);
+
+ try {
+ longContextAlbum.put(_0, ZERO);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
+ e.getMessage());
+ }
+
+ try {
+ longContextAlbum.put(_0, "");
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals(
+ "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
+ e.getMessage());
+ }
+
+ try {
+ longContextAlbum.put(_0, null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()",
+ e.getMessage());
+ }
+
+ try {
+ longContextAlbum.put(null, null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final ContextRuntimeException e) {
+ assertEquals("album \"LongContextAlbum:0.0.1\" null keys are illegal on keys for put()", e.getMessage());
+ }
+
+ assertNull(dateContextAlbum.put("date0", tciA));
+ assertTrue(dateContextAlbum.put("date0", tciA).equals(tciA));
+
+
+ assertNull(mapContextAlbum.put("map0", tciC));
+ assertTrue(mapContextAlbum.put("map0", tciC).equals(tciC));
+
+ contextDistributor.clear();
+ }
+
+ private TestContextTreeMapItem getTestContextTreeMapItem() {
+ final Map<String, String> testHashMap = new HashMap<>();
+ testHashMap.put(_0, ZERO);
+ testHashMap.put("1", "one");
+ testHashMap.put("2", "two");
+ testHashMap.put("3", "three");
+ testHashMap.put("4", "four");
+
+ final TestContextTreeMapItem tciC = new TestContextTreeMapItem(testHashMap);
+ return tciC;
+ }
+
+ private TestContextDateLocaleItem getTestContextDateLocaleItem() {
+ final TestContextDateLocaleItem tciA = new TestContextDateLocaleItem();
+ tciA.setDateValue(new TestContextDateItem(new Date()));
+ tciA.setTZValue(TIME_ZONE.getDisplayName());
+ tciA.setDST(true);
+ tciA.setUTCOffset(-600);
+ tciA.setLocale(Locale.ENGLISH);
+ return tciA;
+ }
+
+ private ContextAlbum getContextAlbum(final String albumKey, final Distributor contextDistributor)
+ throws ContextException {
+ final ContextAlbum longContextAlbum =
+ contextDistributor.createContextAlbum(new AxArtifactKey(albumKey, VERSION));
+ assertNotNull(longContextAlbum);
+ longContextAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ return longContextAlbum;
+ }
+
+ private Distributor getDistributor() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
+ final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
+
+
+ final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
+ contextDistributor.registerModel(multiModel);
+ return contextDistributor;
+ }
+}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
new file mode 100644
index 000000000..e789ae90c
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
@@ -0,0 +1,364 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.test.distribution;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.onap.policy.apex.context.test.factory.TestContextAlbumFactory.createMultiAlbumsContextModel;
+import static org.onap.policy.apex.context.test.utils.Constants.APEX_DISTRIBUTOR;
+import static org.onap.policy.apex.context.test.utils.Constants.BYTE_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.EXCEPTION_MESSAGE;
+import static org.onap.policy.apex.context.test.utils.Constants.FLOAT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.INT_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.PI_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.STRING_GLOBAL_VAL;
+import static org.onap.policy.apex.context.test.utils.Constants.TIME_ZONE;
+import static org.onap.policy.apex.context.test.utils.Constants.USED_ARTIFACT_STACK_ARRAY;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TimeZone;
+
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextBooleanItem;
+import org.onap.policy.apex.context.test.concepts.TestContextByteItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateTzItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDoubleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextFloatItem;
+import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
+import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+
+
+/**
+ * The Class SequentialContextInstantiation checks sequential initiation of context.
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class SequentialContextInstantiation {
+ private static final String DV1 = "dv1";
+ private static final String DV0 = "dv0";
+ // Logger for this class
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(SequentialContextInstantiation.class);
+
+ /**
+ * Test sequential context instantiation.
+ *
+ * @throws ContextException the context exception
+ */
+ public void testSequentialContextInstantiation() throws ContextException {
+ LOGGER.debug("Running TestContextInstantiation test . . .");
+
+ final Distributor contextDistributor = getDistributor();
+
+ try {
+ final ContextAlbum dateAlbum = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+ final Date testDate = new Date();
+ final TestContextDateLocaleItem tciA00 = getTestContextDateLocaleItem();
+
+ dateAlbum.put(DV0, tciA00);
+ assertEquals(tciA00, dateAlbum.get(DV0));
+
+ dateAlbum.put(DV1, tciA00);
+ assertEquals(tciA00, dateAlbum.get(DV1));
+
+ final TestContextDateTzItem tci9 = getTestContextDateTzItem(testDate);
+
+ try {
+ dateAlbum.put("tci9", tci9);
+ } catch (final Exception e) {
+ final String message = "class \"" + TestContextDateTzItem.class.getCanonicalName()
+ + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName() + "\"";
+ assertTrue(e.getMessage().contains(message));
+ }
+
+ final TestContextDateLocaleItem tciA01 = new TestContextDateLocaleItem(tciA00);
+ final TestContextDateLocaleItem tciA02 = new TestContextDateLocaleItem(tciA00);
+ final TestContextDateLocaleItem tciA03 = new TestContextDateLocaleItem(tciA00);
+
+ final Map<String, Object> valueMap0 = new HashMap<>();
+ valueMap0.put("Item01", tciA01);
+ valueMap0.put("Item02", tciA02);
+ valueMap0.put("Item03", tciA03);
+
+ dateAlbum.putAll(valueMap0);
+ assertEquals(5, dateAlbum.size());
+ assertEquals(tciA01, dateAlbum.get("Item01"));
+ assertEquals(tciA02, dateAlbum.get("Item02"));
+ assertEquals(tciA03, dateAlbum.get("Item03"));
+
+ final Map<String, Object> valueMap1 = getMap(testDate, tciA00, tci9);
+
+ // Get another reference to the album
+ final ContextAlbum dateAlbum1 = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+
+ try {
+ dateAlbum1.putAll(valueMap1);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().endsWith(
+ "not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName() + "\""));
+ }
+ assertEquals(5, dateAlbum1.size());
+
+ valueMap1.clear();
+ valueMap1.put("Item00_2", tciA00);
+ dateAlbum1.putAll(valueMap1);
+ assertEquals(6, dateAlbum1.size());
+
+ assertEquals(tciA00, dateAlbum1.get("Item00_2"));
+ dateAlbum.remove("Item00_2");
+ assertEquals(5, dateAlbum1.size());
+
+ final ContextAlbum dateAlbumCopy = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
+
+ final Map<String, Object> valueMap2 = new HashMap<>();
+ valueMap2.put("Item04", tciA01);
+ valueMap2.put("Item05", tciA02);
+ valueMap2.put("Item06", tciA03);
+
+ dateAlbumCopy.putAll(valueMap2);
+ assertEquals(8, dateAlbumCopy.size());
+
+ assertEquals(tciA03, dateAlbumCopy.get("Item06"));
+
+ final Collection<Object> mapValues = dateAlbum.values();
+ assertTrue(dateAlbumCopy.values().containsAll(mapValues));
+
+ // Check that clearing works
+ dateAlbum1.clear();
+ assertTrue(dateAlbum1.isEmpty());
+
+
+ dateAlbum.put("Item00", tciA00);
+ final Map<String, Object> valueMap3 = new HashMap<>();
+ valueMap3.put("Item01", tciA01);
+ valueMap3.put("Item02", tciA02);
+ valueMap3.put("Item03", tciA03);
+ dateAlbum.putAll(valueMap3);
+
+ final Map<String, Object> valueMap4 = new HashMap<>();
+ valueMap4.put("Item04", tciA01);
+ valueMap4.put("Item05", tciA02);
+ valueMap4.put("Item06", tciA03);
+
+ dateAlbumCopy.putAll(valueMap4);
+
+ assertContains(dateAlbum, tciA01);
+
+ final Set<Entry<String, Object>> entrySet = dateAlbum.entrySet();
+ assertEquals(7, entrySet.size());
+
+ assertAlbumGetAndPutMethods(dateAlbum, tciA03, tciA00);
+
+ // Should do removes
+ dateAlbum.remove("TestAA");
+ dateAlbum.remove("TestAB");
+ dateAlbum.remove("ItemNull");
+ assertEquals(7, entrySet.size());
+ assertTrue(dateAlbumCopy.values().containsAll(mapValues));
+ // CHECKSTYLE:ON: checkstyle:magicNumber
+ } finally {
+ contextDistributor.clear();
+ }
+ }
+
+ private void assertContains(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA01) {
+ try {
+ dateAlbum.containsKey(null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("null values are illegal on method parameter \"key\"", e.getMessage());
+ }
+
+ assertTrue(dateAlbum.containsKey("Item05"));
+ assertTrue(!dateAlbum.containsKey("Item07"));
+
+ try {
+ dateAlbum.containsValue(null);
+ } catch (final Exception e) {
+ assertEquals("null values are illegal on method parameter \"value\"", e.getMessage());
+
+ }
+
+ assertTrue(dateAlbum.containsValue(tciA01));
+ assertTrue(!dateAlbum.containsValue("Hello"));
+ }
+
+ private void assertAlbumGetAndPutMethods(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA03,
+ final TestContextDateLocaleItem tciA00) {
+ try {
+ dateAlbum.get(null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()", e.getMessage());
+ }
+
+ final Object aObject = dateAlbum.get("Item03");
+ assertEquals(tciA03, aObject);
+ try {
+ dateAlbum.put(null, null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()", e.getMessage());
+ }
+
+ // Put null ContextItem should work (return null)
+ try {
+ dateAlbum.put("ItemNull", null);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()",
+ e.getMessage());
+ }
+
+ // Should return null
+ assertNull(dateAlbum.get("ItemNull"));
+ // Put should return the previous contextItem
+ tciA00.setDST(false);
+ final TestContextDateLocaleItem tciA03_clone = new TestContextDateLocaleItem(tciA03);
+ tciA03_clone.setDST(true);
+ TestContextDateLocaleItem retItem = (TestContextDateLocaleItem) dateAlbum.put("Item03", tciA03_clone);
+ assertEquals(tciA03, retItem);
+ retItem = (TestContextDateLocaleItem) dateAlbum.put("Item03", tciA03);
+ assertEquals(tciA03_clone, retItem);
+
+ try {
+ dateAlbum.put("ItemNull", null);
+ fail(EXCEPTION_MESSAGE);
+
+ } catch (final Exception e) {
+ assert (e.getMessage()
+ .equals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
+ }
+
+ dateAlbum.put("TestAA", tciA00);
+ assertEquals(tciA00, dateAlbum.get("TestAA"));
+
+ // Should print warning
+ try {
+ dateAlbum.put("TestAA", null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" for put()",
+ e.getMessage());
+ }
+ assertEquals(8, dateAlbum.size());
+ try {
+ dateAlbum.put("TestAB", null);
+ fail(EXCEPTION_MESSAGE);
+ } catch (final Exception e) {
+ assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" for put()",
+ e.getMessage());
+ }
+ assertEquals(8, dateAlbum.size());
+ }
+
+ private Map<String, Object> getMap(final Date testDate, final TestContextDateLocaleItem tciA00,
+ final TestContextDateTzItem tci9) {
+ final TestContextBooleanItem testBadItem000 = new TestContextBooleanItem();
+ final TestContextByteItem testBadItem001 = new TestContextByteItem();
+ final TestContextIntItem testBadItem002 = new TestContextIntItem();
+ final TestContextLongItem testBadItem003 = new TestContextLongItem();
+ final TestContextFloatItem testBadItem004 = new TestContextFloatItem();
+ final TestContextDoubleItem testBadItem005 = new TestContextDoubleItem();
+ final TestContextStringItem testBadItem006 = new TestContextStringItem();
+ final TestContextLongObjectItem testBadItem007 = new TestContextLongObjectItem();
+ final TestContextDateItem testBadItem008 = new TestContextDateItem();
+
+ testBadItem000.setFlag(false);
+ testBadItem001.setByteValue(BYTE_VAL);
+ testBadItem002.setIntValue(INT_VAL);
+ testBadItem003.setLongValue(LONG_VAL);
+ testBadItem004.setFloatValue(new Float(FLOAT_VAL));
+ testBadItem005.setDoubleValue(PI_VAL);
+ testBadItem006.setStringValue(STRING_GLOBAL_VAL);
+ testBadItem007.setLongValue(testDate.getTime());
+ testBadItem008.setDateValue(testDate);
+
+ final Map<String, Object> values = new HashMap<>();
+ values.put("TestBadItem000", testBadItem000);
+ values.put("TestBadItem001", testBadItem001);
+ values.put("TestBadItem002", testBadItem002);
+ values.put("TestBadItem003", testBadItem003);
+ values.put("TestBadItem004", testBadItem004);
+ values.put("TestBadItem005", testBadItem005);
+ values.put("TestBadItem006", testBadItem006);
+ values.put("TestBadItem007", testBadItem007);
+ values.put("TestBadItem008", testBadItem008);
+ values.put("TestBadItem009", tci9);
+ values.put("Item00_2", tciA00);
+ return values;
+ }
+
+ private TestContextDateTzItem getTestContextDateTzItem(final Date testDate) {
+ final TestContextDateTzItem tci9 = new TestContextDateTzItem();
+ tci9.setDateValue(new TestContextDateItem(testDate));
+ tci9.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
+ tci9.setDST(true);
+ return tci9;
+ }
+
+ private TestContextDateLocaleItem getTestContextDateLocaleItem() {
+ final TestContextDateLocaleItem tciA00 = new TestContextDateLocaleItem();
+ tciA00.setDateValue(new TestContextDateItem(new Date()));
+ tciA00.setTZValue(TIME_ZONE.getDisplayName());
+ tciA00.setDST(true);
+ tciA00.setUTCOffset(-600);
+ tciA00.setLocale(Locale.ENGLISH);
+ return tciA00;
+ }
+
+ private ContextAlbum getContextAlbum(final String albumName, final Distributor contextDistributor)
+ throws ContextException {
+ final ContextAlbum dateAlbum = contextDistributor.createContextAlbum(new AxArtifactKey(albumName, VERSION));
+ assertNotNull(dateAlbum);
+ dateAlbum.setUserArtifactStack(USED_ARTIFACT_STACK_ARRAY);
+ return dateAlbum;
+ }
+
+ private Distributor getDistributor() throws ContextException {
+ final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
+ final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
+ contextDistributor.registerModel(createMultiAlbumsContextModel());
+ return contextDistributor;
+ }
+}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
index 148c8cac4..148c8cac4 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/package-info.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
index 64de009d5..3003344b3 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
@@ -20,6 +20,20 @@
package org.onap.policy.apex.context.test.factory;
+import static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.LONG_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.MAP_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.POLICY_CONTEXT_ALBUM;
+import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
+
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
@@ -34,6 +48,11 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class TestContextAlbumFactory {
+
+ private static final String APPLICATION = "APPLICATION";
+ private static final String JAVA_LONG = Long.class.getCanonicalName();
+ private static final String JAVA_FLAVOUR = "Java";
+
/**
* Default constructor to prevent sub-classing.
*/
@@ -45,19 +64,19 @@ public final class TestContextAlbumFactory {
* @return the ax context model
*/
public static AxContextModel createPolicyContextModel() {
- final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestPolicyContextItem");
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("PolicyContextAlbum", "0.0.1"),
- "APPLICATION", true, policySchema.getKey());
+ final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", VERSION),
+ JAVA_FLAVOUR, TestPolicyContextItem.class.getCanonicalName());
+ final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, policySchema.getKey());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("PolicyContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -70,19 +89,19 @@ public final class TestContextAlbumFactory {
* @return the ax context model
*/
public static AxContextModel createGlobalContextModel() {
- final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestGlobalContextItem");
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
+ final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", VERSION),
+ JAVA_FLAVOUR, TestGlobalContextItem.class.getCanonicalName());
+ final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
"GLOBAL", true, globalSchema.getKey());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("GlobalContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -95,19 +114,19 @@ public final class TestContextAlbumFactory {
* @return the ax context model
*/
public static AxContextModel createExternalContextModel() {
- final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestExternalContextItem");
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"),
+ final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", VERSION),
+ JAVA_FLAVOUR, TestExternalContextItem.class.getCanonicalName());
+ final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
"EXTERNAL", true, externalSchema.getKey());
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("ExternalContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -120,22 +139,26 @@ public final class TestContextAlbumFactory {
* @return the ax context model
*/
public static AxContextModel createLongContextModel() {
- final AxContextSchema longSchema =
- new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
- final AxContextAlbum albumDefinition1 = new AxContextAlbum(new AxArtifactKey("LongContextAlbum1", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
- final AxContextAlbum albumDefinition2 = new AxContextAlbum(new AxArtifactKey("LongContextAlbum2", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
+ final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
+ final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ final AxArtifactKey longContextAlbumKey = new AxArtifactKey("LongContextAlbum1", VERSION);
+ final AxContextAlbum albumDefinition1 =
+ new AxContextAlbum(longContextAlbumKey, APPLICATION, true, longSchema.getKey());
+
+ final AxArtifactKey longContextAlbumKey2 = new AxArtifactKey("LongContextAlbum2", VERSION);
+ final AxContextAlbum albumDefinition2 =
+ new AxContextAlbum(longContextAlbumKey2, APPLICATION, true, longSchema.getKey());
+
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("LongContextModel", "0.0.1"), schemas, albums, keyInformation);
+ new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
@@ -149,41 +172,42 @@ public final class TestContextAlbumFactory {
*/
public static AxContextModel createMultiAlbumsContextModel() {
final AxContextSchema longSchema =
- new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
- final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestContextItem003");
- final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestContextItem00A");
- final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", "0.0.1"), "Java",
- "org.onap.policy.apex.context.test.concepts.TestContextItem00C");
-
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
+ new AxContextSchema(new AxArtifactKey("LongSchema", VERSION), JAVA_FLAVOUR, JAVA_LONG);
+ final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", VERSION), JAVA_FLAVOUR,
+ TestContextLongItem.class.getCanonicalName());
+ final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", VERSION), JAVA_FLAVOUR,
+ TestContextDateLocaleItem.class.getCanonicalName());
+ final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
+ TestContextTreeMapItem.class.getCanonicalName());
+
+ final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
schemas.getSchemasMap().put(mapSchema.getKey(), mapSchema);
- final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"),
- "APPLICATION", true, longSchema.getKey());
- final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"),
- "APPLICATION", true, lTypeSchema.getKey());
- final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"),
- "APPLICATION", true, dateSchema.getKey());
- final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey("MapContextAlbum", "0.0.1"),
- "APPLICATION", true, mapSchema.getKey());
+ final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey(LONG_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, longSchema.getKey());
+ final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", VERSION),
+ APPLICATION, true, lTypeSchema.getKey());
+ final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey(DATE_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, dateSchema.getKey());
+ final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey(MAP_CONTEXT_ALBUM, VERSION),
+ APPLICATION, true, mapSchema.getKey());
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
+ final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", "0.0.1"),
+ final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+ final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
schemas, albums, keyInformation);
contextModel.setKeyInformation(keyInformation);
keyInformation.generateKeyInfo(contextModel);
return contextModel;
}
+
}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
index ea70ce2a8..ea70ce2a8 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/package-info.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
index 35db5ddf6..2eea957c6 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
@@ -26,7 +26,7 @@ import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -141,28 +141,28 @@ public class ConcurrentContext {
lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
// CHECKSTYLE:OFF: checkstyle:magicNumber
- lTypeAlbum.put("lTypeValue0", new TestContextItem003(0xFFFFFFFFFFFFFFFFL));
- lTypeAlbum.put("lTypeValue1", new TestContextItem003(0xFFFFFFFFFFFFFFFEL));
- lTypeAlbum.put("lTypeValue2", new TestContextItem003(0xFFFFFFFFFFFFFFFDL));
- lTypeAlbum.put("lTypeValue3", new TestContextItem003(0xFFFFFFFFFFFFFFFCL));
- lTypeAlbum.put("lTypeValue4", new TestContextItem003(0xFFFFFFFFFFFFFFFBL));
- lTypeAlbum.put("lTypeValue5", new TestContextItem003(0xFFFFFFFFFFFFFFFAL));
- lTypeAlbum.put("lTypeValue6", new TestContextItem003(0xFFFFFFFFFFFFFFF9L));
- lTypeAlbum.put("lTypeValue7", new TestContextItem003(0xFFFFFFFFFFFFFFF8L));
- lTypeAlbum.put("lTypeValue8", new TestContextItem003(0xFFFFFFFFFFFFFFF7L));
- lTypeAlbum.put("lTypeValue9", new TestContextItem003(0xFFFFFFFFFFFFFFF6L));
- lTypeAlbum.put("lTypeValueA", new TestContextItem003(0xFFFFFFFFFFFFFFF5L));
- lTypeAlbum.put("lTypeValueB", new TestContextItem003(0xFFFFFFFFFFFFFFF4L));
- lTypeAlbum.put("lTypeValueC", new TestContextItem003(0xFFFFFFFFFFFFFFF3L));
- lTypeAlbum.put("lTypeValueD", new TestContextItem003(0xFFFFFFFFFFFFFFF2L));
- lTypeAlbum.put("lTypeValueE", new TestContextItem003(0xFFFFFFFFFFFFFFF1L));
- lTypeAlbum.put("lTypeValueF", new TestContextItem003(0xFFFFFFFFFFFFFFF0L));
+ lTypeAlbum.put("lTypeValue0", new TestContextLongItem(0xFFFFFFFFFFFFFFFFL));
+ lTypeAlbum.put("lTypeValue1", new TestContextLongItem(0xFFFFFFFFFFFFFFFEL));
+ lTypeAlbum.put("lTypeValue2", new TestContextLongItem(0xFFFFFFFFFFFFFFFDL));
+ lTypeAlbum.put("lTypeValue3", new TestContextLongItem(0xFFFFFFFFFFFFFFFCL));
+ lTypeAlbum.put("lTypeValue4", new TestContextLongItem(0xFFFFFFFFFFFFFFFBL));
+ lTypeAlbum.put("lTypeValue5", new TestContextLongItem(0xFFFFFFFFFFFFFFFAL));
+ lTypeAlbum.put("lTypeValue6", new TestContextLongItem(0xFFFFFFFFFFFFFFF9L));
+ lTypeAlbum.put("lTypeValue7", new TestContextLongItem(0xFFFFFFFFFFFFFFF8L));
+ lTypeAlbum.put("lTypeValue8", new TestContextLongItem(0xFFFFFFFFFFFFFFF7L));
+ lTypeAlbum.put("lTypeValue9", new TestContextLongItem(0xFFFFFFFFFFFFFFF6L));
+ lTypeAlbum.put("lTypeValueA", new TestContextLongItem(0xFFFFFFFFFFFFFFF5L));
+ lTypeAlbum.put("lTypeValueB", new TestContextLongItem(0xFFFFFFFFFFFFFFF4L));
+ lTypeAlbum.put("lTypeValueC", new TestContextLongItem(0xFFFFFFFFFFFFFFF3L));
+ lTypeAlbum.put("lTypeValueD", new TestContextLongItem(0xFFFFFFFFFFFFFFF2L));
+ lTypeAlbum.put("lTypeValueE", new TestContextLongItem(0xFFFFFFFFFFFFFFF1L));
+ lTypeAlbum.put("lTypeValueF", new TestContextLongItem(0xFFFFFFFFFFFFFFF0L));
LOGGER.debug(lTypeAlbum.toString());
assert (lTypeAlbum.size() >= 16);
// CHECKSTYLE:ON: checkstyle:magicNumber
// The initial value for concurrent testing
- final TestContextItem003 item = new TestContextItem003(0L);
+ final TestContextLongItem item = new TestContextLongItem(0L);
lTypeAlbum.put("testValue", item);
}
@@ -180,11 +180,11 @@ public class ConcurrentContext {
throws ContextException {
try {
LOGGER.debug("threads finished, end value is {}",
- ((TestContextItem003) lTypeAlbum.get("testValue")).getLongValue());
+ ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue());
} catch (final Exception exception) {
LOGGER.error("Error: ", exception);
}
- final long total = ((TestContextItem003) lTypeAlbum.get("testValue")).getLongValue();
+ final long total = ((TestContextLongItem) lTypeAlbum.get("testValue")).getLongValue();
contextDistributor.clear();
contextDistributor = null;
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
index 0145bd161..0145bd161 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
index 020eed898..da2741f7b 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
@@ -79,7 +79,7 @@ public class ConcurrentContextJVMThread implements Runnable {
+ System.getProperty("file.separator") + "java");
commandList.add("-cp");
commandList.add(System.getProperty("java.class.path"));
- commandList.add("org.onap.policy.apex.context.test.locking.ConcurrentContextJVM");
+ commandList.add(ConcurrentContextJVM.class.getCanonicalName());
commandList.add(testType);
commandList.add(new Integer(jvm).toString());
commandList.add(new Integer(threadCount).toString());
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
index 42e3e0978..554c3d005 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
@@ -25,7 +25,7 @@ import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -109,7 +109,7 @@ public class ConcurrentContextThread implements Runnable {
try {
lTypeAlbum.lockForWriting("testValue");
- final TestContextItem003 item = (TestContextItem003) lTypeAlbum.get("testValue");
+ final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
final long value = item.getLongValue();
LOGGER.info("completed TestConcurrentContextThread_" + jvm + "_" + instance + ", value=" + value);
} catch (final Exception e) {
@@ -130,12 +130,12 @@ public class ConcurrentContextThread implements Runnable {
for (int i = 0; i < threadLoops; i++) {
try {
lTypeAlbum.lockForWriting("testValue");
- TestContextItem003 item = (TestContextItem003) lTypeAlbum.get("testValue");
+ TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
if (item != null) {
long value = item.getLongValue();
item.setLongValue(++value);
} else {
- item = new TestContextItem003(0L);
+ item = new TestContextLongItem(0L);
}
lTypeAlbum.put("testValue", item);
} finally {
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
index 0e80e611d..0e80e611d 100644
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/package-info.java
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
new file mode 100644
index 000000000..90e586e72
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.apex.context.test.utils;
+
+import java.util.TimeZone;
+
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+public class Constants {
+ public static final String MAP_CONTEXT_ALBUM = "MapContextAlbum";
+ public static final String LONG_CONTEXT_ALBUM = "LongContextAlbum";
+ public static final String DATE_CONTEXT_ALBUM = "DateContextAlbum";
+
+ public static final String EXTERNAL_CONTEXT_ALBUM = "ExternalContextAlbum";
+ public static final String GLOBAL_CONTEXT_ALBUM = "GlobalContextAlbum";
+ public static final String POLICY_CONTEXT_ALBUM = "PolicyContextAlbum";
+
+ public static final String APEX_DISTRIBUTOR = "ApexDistributor";
+ public static final String VERSION = "0.0.1";
+ public static final int INT_VAL = 0xFFFFFFFF;
+ public static final int INT_VAL_2 = 2000;
+ public static final int INT_VAL_3 = -1;
+ public static final String EXCEPTION_MESSAGE = "Test should throw an exception";
+ public static final byte BYTE_VAL = (byte) 0xFF;
+ public static final double PI_VAL = Math.PI;
+ public static final float FLOAT_VAL = 3.14159265359f;
+ public static final String EXTERNAL_CONTEXT = "externalContext";
+ public static final String GLOBAL_CONTEXT_KEY = "globalContext";
+ public static final String STRING_GLOBAL_VAL = "This is a global context string";
+ public static final String STRING_VAL = "This is a policy context string";
+ public static final String STRING_EXT_VAL = "This is an external context string";
+ public static final long LONG_VAL = 0xFFFFFFFFFFFFFFFFL;
+ public static final String TEST_POLICY_CONTEXT_ITEM = TestPolicyContextItem.class.getName();
+ public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("Europe/Dublin");
+
+ public static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = {new AxArtifactKey("testC-top", VERSION),
+ new AxArtifactKey("testC-next", VERSION), new AxArtifactKey("testC-bot", VERSION)};
+
+ private Constants() {}
+
+}
diff --git a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
index 7d5693d5a..105b59e8e 100644
--- a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import org.junit.After;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -40,8 +41,7 @@ public class TestContextAlbumUpdate {
logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateJVMLocalVarSet test");
diff --git a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
index f640b339e..565a39f97 100644
--- a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -55,8 +56,7 @@ public class TestContextInstantiation {
logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationJVMLocalVarSet test");
diff --git a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
index d140b0da1..1a9bc29f1 100644
--- a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
@@ -23,6 +23,7 @@ package org.onap.policy.apex.context.test.distribution;
import java.io.IOException;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -43,8 +44,7 @@ public class TestContextUpdate {
logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateJVMLocalVarSet test");
diff --git a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
index 27987595c..28bd7eb01 100644
--- a/context/context-test/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -53,8 +54,7 @@ public class TestSequentialContextInstantiation {
logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new SequentialContextInstantiation().testSequentialContextInstantiation();
logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test");
diff --git a/context/context-test/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
index 0f6626ff1..7788fb411 100644
--- a/context/context-test/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -53,8 +55,7 @@ public class TestConcurrentContext {
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
+ contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("JVMLocalVarSet", TEST_JVM_COUNT_SINGLE_JVM,
TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -81,10 +82,8 @@ public class TestConcurrentContext {
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor");
- contextParameters.getLockManagerParameters()
- .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
+ contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+ contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final long result = new ConcurrentContext().testConcurrentContext("testConcurrentContextMultiJVMNoLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
diff --git a/context/context-test/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
index db1ac47fe..a05928591 100644
--- a/context/context-test/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
@@ -40,10 +40,10 @@ import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.PersistorParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00C;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -61,7 +61,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
*/
public class TestPersistentContextInstantiation {
// Logger for this class
- // private static final XLogger logger = XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
+ // private static final XLogger logger =
+ // XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
private Connection connection;
@@ -89,8 +90,8 @@ public class TestPersistentContextInstantiation {
final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1");
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- final AxArtifactKey[] usedArtifactStackArray = { new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1") };
+ final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"),
+ new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
final DAOParameters daoParameters = new DAOParameters();
daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
@@ -113,11 +114,11 @@ public class TestPersistentContextInstantiation {
testMap.put("key", "This is a policy context string");
final Map<String, Object> valueMap0 = new HashMap<String, Object>();
- valueMap0.put("TestPolicyContextItem000", new TestContextItem00C(testMap));
+ valueMap0.put("TestPolicyContextItem000", new TestContextTreeMapItem(testMap));
contextAlbumForMap.putAll(valueMap0);
- assertEquals(((TestContextItem00C) contextAlbumForMap.get("TestPolicyContextItem000")).getMapValue().get("key"),
+ assertEquals(((TestContextTreeMapItem) contextAlbumForMap.get("TestPolicyContextItem000")).getMapValue().get("key"),
"This is a policy context string");
contextAlbumForMap.flush();
@@ -131,8 +132,8 @@ public class TestPersistentContextInstantiation {
assertNotNull(contextAlbumForDate);
contextAlbumForDate.setUserArtifactStack(usedArtifactStackArray);
- final TestContextItem008 testDate = new TestContextItem008(new Date());
- final TestContextItem00A tci00A = new TestContextItem00A();
+ final TestContextDateItem testDate = new TestContextDateItem(new Date());
+ final TestContextDateLocaleItem tci00A = new TestContextDateLocaleItem();
tci00A.setDateValue(testDate);
tci00A.setTZValue(TimeZone.getTimeZone("Europe/Dublin").toString());
tci00A.setDST(true);
@@ -142,9 +143,9 @@ public class TestPersistentContextInstantiation {
contextAlbumForDate.putAll(valueMap1);
- assertEquals(((TestContextItem00A) contextAlbumForDate.get("TestPolicyContextItem00A")).getDateValue(),
+ assertEquals(((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDateValue(),
testDate);
- assertEquals(((TestContextItem00A) contextAlbumForDate.get("TestPolicyContextItem00A")).getDST(), true);
+ assertEquals(((TestContextDateLocaleItem) contextAlbumForDate.get("TestPolicyContextItem00A")).getDST(), true);
contextAlbumForDate.flush();
@@ -158,23 +159,23 @@ public class TestPersistentContextInstantiation {
contextAlbumForLong.setUserArtifactStack(usedArtifactStackArray);
final Map<String, Object> valueMap2 = new HashMap<String, Object>();
- valueMap2.put("TestPolicyContextItem0031", new TestContextItem003(0xFFFFFFFFFFFFFFFFL));
- valueMap2.put("TestPolicyContextItem0032", new TestContextItem003(0xFFFFFFFFFFFFFFFEL));
- valueMap2.put("TestPolicyContextItem0033", new TestContextItem003(0xFFFFFFFFFFFFFFFDL));
- valueMap2.put("TestPolicyContextItem0034", new TestContextItem003(0xFFFFFFFFFFFFFFFCL));
- valueMap2.put("TestPolicyContextItem0035", new TestContextItem003(0xFFFFFFFFFFFFFFFBL));
+ valueMap2.put("TestPolicyContextItem0031", new TestContextLongItem(0xFFFFFFFFFFFFFFFFL));
+ valueMap2.put("TestPolicyContextItem0032", new TestContextLongItem(0xFFFFFFFFFFFFFFFEL));
+ valueMap2.put("TestPolicyContextItem0033", new TestContextLongItem(0xFFFFFFFFFFFFFFFDL));
+ valueMap2.put("TestPolicyContextItem0034", new TestContextLongItem(0xFFFFFFFFFFFFFFFCL));
+ valueMap2.put("TestPolicyContextItem0035", new TestContextLongItem(0xFFFFFFFFFFFFFFFBL));
contextAlbumForLong.putAll(valueMap2);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0031")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0031")).getLongValue(),
0xFFFFFFFFFFFFFFFFL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0032")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0032")).getLongValue(),
0xFFFFFFFFFFFFFFFEL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0033")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0033")).getLongValue(),
0xFFFFFFFFFFFFFFFDL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0034")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0034")).getLongValue(),
0xFFFFFFFFFFFFFFFCL);
- assertEquals(((TestContextItem003) contextAlbumForLong.get("TestPolicyContextItem0035")).getLongValue(),
+ assertEquals(((TestContextLongItem) contextAlbumForLong.get("TestPolicyContextItem0035")).getLongValue(),
0xFFFFFFFFFFFFFFFBL);
contextAlbumForLong.flush();
diff --git a/context/context-test/src/test/resources/META-INF/persistence.xml b/context/context-test-utils/src/test/resources/META-INF/persistence.xml
index ec9357851..ec9357851 100644
--- a/context/context-test/src/test/resources/META-INF/persistence.xml
+++ b/context/context-test-utils/src/test/resources/META-INF/persistence.xml
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
deleted file mode 100644
index 4b47c63db..000000000
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.TreeSet;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.ContextRuntimeException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem000;
-import org.onap.policy.apex.context.test.concepts.TestContextItem001;
-import org.onap.policy.apex.context.test.concepts.TestContextItem002;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
-import org.onap.policy.apex.context.test.concepts.TestContextItem004;
-import org.onap.policy.apex.context.test.concepts.TestContextItem005;
-import org.onap.policy.apex.context.test.concepts.TestContextItem006;
-import org.onap.policy.apex.context.test.concepts.TestContextItem007;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem009;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00B;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00C;
-import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
-import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
-import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextInstantiation is used to test Apex context insitiation is correct.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class ContextInstantiation {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
-
- /**
- * Test context instantiation.
- *
- * @throws ContextException the context exception
- */
- // CHECKSTYLE:OFF: checkstyle:MaximumMethodLength
- public void testContextInstantiation() throws ContextException {
- // CHECKSTYLE:ON: checkstyle:MaximumMethodLength
- LOGGER.debug("Running TestContextInstantiation test . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributorInit", "0.0.1");
- Distributor contextDistributor = null;
- try {
- contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- } catch (final Exception exception) {
- LOGGER.error("Error occured while Instantiating Distributor for : {}", distributorKey, exception);
- return;
- }
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"), new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- try {
- // CHECKSTYLE:OFF: checkstyle:magicNumber
- final AxContextModel policyContextModel = TestContextAlbumFactory.createPolicyContextModel();
- final AxValidationResult result = new AxValidationResult();
- policyContextModel.validate(result);
- LOGGER.debug(result.toString());
- assert (result.isValid());
-
- contextDistributor.registerModel(policyContextModel);
-
- final ContextAlbum policyContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("PolicyContextAlbum", "0.0.1"));
- assert (policyContextAlbum != null);
- policyContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final Float testFloat = new Float(3.14159265359);
- final Date testDate = new Date();
-
- final TestContextItem009 tci9 = new TestContextItem009();
- tci9.setDateValue(new TestContextItem008(testDate));
- tci9.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tci9.setDST(true);
-
- final TestContextItem00A tciA = new TestContextItem00A();
- tciA.setDateValue(new TestContextItem008(testDate));
- tciA.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tciA.setDST(true);
- tciA.setUTCOffset(-600);
- tciA.setLocale(Locale.ENGLISH);
-
- final TreeSet<String> testTreeSet = new TreeSet<>();
- testTreeSet.add("one hundred");
- testTreeSet.add("one hundred and one");
- testTreeSet.add("one hundred and two");
- testTreeSet.add("one hundred and three");
- testTreeSet.add("one hundred and four");
-
- final Map<String, String> testHashMap = new HashMap<>();
- testHashMap.put("0", "zero");
- testHashMap.put("1", "one");
- testHashMap.put("2", "two");
- testHashMap.put("3", "three");
- testHashMap.put("4", "four");
-
- final TestContextItem006 testPolicyContextItem000 =
- new TestContextItem006("This is a policy context string");
- final TestContextItem003 testPolicyContextItem001 = new TestContextItem003(0xFFFFFFFFFFFFFFFFL);
- final TestContextItem005 testPolicyContextItem002 = new TestContextItem005(Math.PI);
- final TestContextItem000 testPolicyContextItem003 = new TestContextItem000(true);
- final TestContextItem003 testPolicyContextItem004 = new TestContextItem003(testDate.getTime());
- final TestContextItem00C testPolicyContextItem005 = new TestContextItem00C(testHashMap);
-
- final Map<String, Object> valueMapA = new LinkedHashMap<>();
- valueMapA.put("TestPolicyContextItem001", testPolicyContextItem001);
- valueMapA.put("TestPolicyContextItem002", testPolicyContextItem002);
- valueMapA.put("TestPolicyContextItem003", testPolicyContextItem003);
- valueMapA.put("TestPolicyContextItem004", testPolicyContextItem004);
- valueMapA.put("TestPolicyContextItem005", testPolicyContextItem005);
- valueMapA.put("TestPolicyContextItem000", testPolicyContextItem000);
-
- try {
- policyContextAlbum.put("TestPolicyContextItem000", testPolicyContextItem000);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("Failed to set context value for key \"TestPolicyContextItem000\" in album \"PolicyContextAlbum:0.0.1\": "
- + "PolicyContextAlbum:0.0.1: object \"TestContextItem006 [stringValue=This is a policy context string]\" "
- + "of class \"org.onap.policy.apex.context.test.concepts.TestContextItem006\""
- + " not compatible with class \"org.onap.policy.apex.context.test.concepts.TestPolicyContextItem\""));
- }
-
- try {
- policyContextAlbum.putAll(valueMapA);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("Failed to set context value for key \"TestPolicyContextItem001\" in album \"PolicyContextAlbum:0.0.1\": "
- + "PolicyContextAlbum:0.0.1: object \"TestContextItem003 [longValue=-1]\" "
- + "of class \"org.onap.policy.apex.context.test.concepts.TestContextItem003\""
- + " not compatible with class \"org.onap.policy.apex.context.test.concepts.TestPolicyContextItem\""));
- }
-
- final TestPolicyContextItem policyContext = new TestPolicyContextItem();
-
- LOGGER.debug(policyContextAlbum.toString());
-
- policyContext.setTestPolicyContextItem000(testPolicyContextItem000);
- policyContext.setTestPolicyContextItem001(testPolicyContextItem001);
- policyContext.setTestPolicyContextItem002(testPolicyContextItem002);
- policyContext.setTestPolicyContextItem003(testPolicyContextItem003);
- policyContext.setTestPolicyContextItem004(testPolicyContextItem004);
- policyContext.setTestPolicyContextItem005(testPolicyContextItem005);
-
- final Map<String, Object> valueMap0 = new HashMap<>();
- valueMap0.put("TestPolicyContextItem", policyContext);
-
- policyContextAlbum.putAll(valueMap0);
-
- final TestPolicyContextItem contextItem =
- (TestPolicyContextItem) policyContextAlbum.get("TestPolicyContextItem");
- assert (contextItem.getTestPolicyContextItem000().getStringValue()
- .equals("This is a policy context string"));
- assert (contextItem.getTestPolicyContextItem001().getLongValue() == 0xFFFFFFFFFFFFFFFFL);
- assert (Double.compare(contextItem.getTestPolicyContextItem002().getDoubleValue(), Math.PI) == 0);
- assert (contextItem.getTestPolicyContextItem003().getFlag());
- assert (contextItem.getTestPolicyContextItem004().getLongValue() == testDate.getTime());
- assert (contextItem.getTestPolicyContextItem005().getMapValue().equals(testHashMap));
-
- final AxContextModel globalContextModel = TestContextAlbumFactory.createGlobalContextModel();
-
- final TestContextItem000 testGlobalContextItem000 = new TestContextItem000(false);
- final TestContextItem001 testGlobalContextItem001 = new TestContextItem001((byte) 0xFF);
- final TestContextItem002 testGlobalContextItem002 = new TestContextItem002(0xFFFFFFFF);
- final TestContextItem003 testGlobalContextItem003 = new TestContextItem003(0xFFFFFFFFFFFFFFFFL);
- final TestContextItem004 testGlobalContextItem004 = new TestContextItem004(testFloat);
- final TestContextItem005 testGlobalContextItem005 = new TestContextItem005(Math.PI);
- final TestContextItem006 testGlobalContextItem006 =
- new TestContextItem006("This is a global context string");
- final TestContextItem007 testGlobalContextItem007 = new TestContextItem007(testDate.getTime());
- final TestContextItem008 testGlobalContextItem008 = new TestContextItem008(testDate);
- final TestContextItem00B testGlobalContextItem00B = new TestContextItem00B(testTreeSet);
- final TestContextItem00C testGlobalContextItem00C = new TestContextItem00C(testHashMap);
-
- final TestGlobalContextItem globalContext = new TestGlobalContextItem();
-
- globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
- globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
- globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
- globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
- globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
- globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
- globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
- globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
- globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
- globalContext.setTestGlobalContextItem009(tci9);
- globalContext.setTestGlobalContextItem00A(tciA);
- globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
- globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
- final Map<String, Object> valueMap1 = new HashMap<>();
- valueMap1.put("globalContext", globalContext);
-
- try {
- contextDistributor.registerModel(globalContextModel);
- } catch (final ContextException e) {
- assert (e.getMessage().equals(
- "active context albums found in distributor, clear the distributor before registering models"));
- }
-
- contextDistributor.registerModel(globalContextModel);
-
- final ContextAlbum globalContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"));
- assert (globalContextAlbum != null);
- globalContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- globalContextAlbum.putAll(valueMap1);
-
- final TestGlobalContextItem globalContextItem =
- (TestGlobalContextItem) globalContextAlbum.get("globalContext");
- assert (!globalContextItem.getTestGlobalContextItem000().getFlag());
- assert (globalContextItem.getTestGlobalContextItem001().getByteValue() == (byte) 0xFF);
- assert (globalContextItem.getTestGlobalContextItem002().getIntValue() == 0xFFFFFFFF);
- assert (globalContextItem.getTestGlobalContextItem003().getLongValue() == 0xFFFFFFFFFFFFFFFFL);
- assert (Float.compare(globalContextItem.getTestGlobalContextItem004().getFloatValue(), testFloat) == 0);
- assert (Double.compare(globalContextItem.getTestGlobalContextItem005().getDoubleValue(), Math.PI) == 0);
- assert (globalContextItem.getTestGlobalContextItem006().getStringValue()
- .equals("This is a global context string"));
- assert (globalContextItem.getTestGlobalContextItem007().getLongValue() == testDate.getTime());
- assert (globalContextItem.getTestGlobalContextItem008().getDateValue().equals(testDate));
- assert (globalContextItem.getTestGlobalContextItem009().getDateValue().getTime() == tci9.getDateValue()
- .getTime());
- assert (globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime() == tciA.getDateValue()
- .getTime());
- assert (globalContextItem.getTestGlobalContextItem00B().getSetValue().equals(testTreeSet));
- assert (globalContextItem.getTestGlobalContextItem00C().getMapValue().equals(testHashMap));
-
- final AxContextModel externalContextModel = TestContextAlbumFactory.createExternalContextModel();
-
- final TestExternalContextItem externalContext = new TestExternalContextItem();
-
- final TestContextItem000 testExternalContextItem000 = new TestContextItem000(false);
- final TestContextItem001 testExternalContextItem001 = new TestContextItem001((byte) 0xFF);
- final TestContextItem002 testExternalContextItem002 = new TestContextItem002(0xFFFFFFFF);
- final TestContextItem003 testExternalContextItem003 = new TestContextItem003(0xFFFFFFFFFFFFFFFFL);
- final TestContextItem004 testExternalContextItem004 = new TestContextItem004(testFloat);
- final TestContextItem005 testExternalContextItem005 = new TestContextItem005(Math.PI);
- final TestContextItem006 testExternalContextItem006 =
- new TestContextItem006("This is an external context string");
- final TestContextItem007 testExternalContextItem007 = new TestContextItem007(testDate.getTime());
- final TestContextItem008 testExternalContextItem008 = new TestContextItem008(testDate);
- final TestContextItem00B testExternalContextItem00B = new TestContextItem00B(testTreeSet);
- final TestContextItem00C testExternalContextItem00C = new TestContextItem00C(testHashMap);
-
- final TestContextItem009 tci9A = new TestContextItem009(tci9);
- final TestContextItem00A tciAA = new TestContextItem00A(tciA);
-
- externalContext.setTestExternalContextItem000(testExternalContextItem000);
- externalContext.setTestExternalContextItem001(testExternalContextItem001);
- externalContext.setTestExternalContextItem002(testExternalContextItem002);
- externalContext.setTestExternalContextItem003(testExternalContextItem003);
- externalContext.setTestExternalContextItem004(testExternalContextItem004);
- externalContext.setTestExternalContextItem005(testExternalContextItem005);
- externalContext.setTestExternalContextItem006(testExternalContextItem006);
- externalContext.setTestExternalContextItem007(testExternalContextItem007);
- externalContext.setTestExternalContextItem008(testExternalContextItem008);
- externalContext.setTestExternalContextItem009(tci9A);
- externalContext.setTestExternalContextItem00A(tciAA);
- externalContext.setTestExternalContextItem00B(testExternalContextItem00B);
- externalContext.setTestExternalContextItem00C(testExternalContextItem00C);
-
- final Map<String, Object> valueMap2 = new HashMap<>();
- valueMap2.put("externalContext", externalContext);
-
- contextDistributor.clear();
- contextDistributor.init(new AxArtifactKey("ClearedandInittedDistributor", "0.0.1"));
- contextDistributor.registerModel(externalContextModel);
-
- final ContextAlbum externalContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"));
- assert (externalContextAlbum != null);
- externalContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- externalContextAlbum.putAll(valueMap2);
- externalContextAlbum.getAlbumDefinition().setWritable(false);
-
- final TestExternalContextItem externalContextItem =
- (TestExternalContextItem) externalContextAlbum.get("externalContext");
-
- assert (!externalContextItem.getTestExternalContextItem000().getFlag());
- assert (externalContextItem.getTestExternalContextItem001().getByteValue() == (byte) 0xFF);
- assert (externalContextItem.getTestExternalContextItem002().getIntValue() == 0xFFFFFFFF);
- assert (externalContextItem.getTestExternalContextItem003().getLongValue() == 0xFFFFFFFFFFFFFFFFL);
- assert (Float.compare(externalContextItem.getTestExternalContextItem004().getFloatValue(), testFloat) == 0);
- assert (Double.compare(externalContextItem.getTestExternalContextItem005().getDoubleValue(), Math.PI) == 0);
- assert (externalContextItem.getTestExternalContextItem006().getStringValue()
- .equals("This is an external context string"));
- assert (externalContextItem.getTestExternalContextItem007().getLongValue() == testDate.getTime());
- assert (externalContextItem.getTestExternalContextItem008().getDateValue().equals(testDate));
- assert (externalContextItem.getTestExternalContextItem009().getDateValue().getTime() == tci9A.getDateValue()
- .getTime());
- assert (externalContextItem.getTestExternalContextItem00A().getDateValue().getTime() == tciAA.getDateValue()
- .getTime());
- assert (externalContextItem.getTestExternalContextItem00B().getSetValue().equals(testTreeSet));
- assert (externalContextItem.getTestExternalContextItem00C().getMapValue().equals(testHashMap));
-
- final Collection<Object> mapValues = externalContextAlbum.values();
- assert (externalContextAlbum.values().containsAll(mapValues));
-
- // Check that clearing does not work
- try {
- externalContextAlbum.clear();
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"ExternalContextAlbum:0.0.1\" clear() not allowed on read only albums"));
- }
-
- assert (externalContextAlbum.size() == 1);
-
- try {
- externalContextAlbum.containsKey(null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"key\""));
- }
-
- assert (externalContextAlbum.containsKey("externalContext"));
- assert (!externalContextAlbum.containsKey("globalContext"));
-
- try {
- externalContextAlbum.containsValue(null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"value\""));
- }
-
- assert (externalContextAlbum.containsValue(externalContext));
- assert (!externalContextAlbum.containsValue(new String("Hello")));
-
- final Set<Entry<String, Object>> entrySet = externalContextAlbum.entrySet();
- assert (entrySet.size() == 1);
-
- try {
- externalContextAlbum.get(null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for get()"));
- }
-
- final Object aObject = externalContextAlbum.get("externalContext");
- assert (aObject.equals(externalContext));
-
- // put null keys should fail, throws a runtime exception
- try {
- externalContextAlbum.put(null, null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()"));
- }
-
- try {
- externalContextAlbum.put("TestExternalContextItem00A", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()"));
- }
- assert (externalContextItem.getTestExternalContextItem00A().equals(tciAA));
-
- // Should return the hash set
- assert (externalContextItem.getTestExternalContextItem00B().getSetValue().equals(testTreeSet));
-
- assert (externalContextAlbum.values().containsAll(mapValues));
-
- // Set the write flag back as it should be
- externalContextAlbum.getAlbumDefinition().setWritable(true);
-
- // Put should return the previous contextItem
- final TestExternalContextItem externalContextOther = new TestExternalContextItem();
- externalContextOther.setTestExternalContextItem002(new TestContextItem002());
- externalContextOther.getTestExternalContextItem002().setIntValue(2000);
-
- final Object object = externalContextAlbum.put("externalContext", externalContextOther);
- assert (object.equals(externalContext));
-
- final TestExternalContextItem item = (TestExternalContextItem) externalContextAlbum.get("externalContext");
- assert (item.getTestExternalContextItem002().getIntValue() == 2000);
- final Object actualExternalContext = externalContextAlbum.put("externalContext", externalContext);
- assert (actualExternalContext.equals(externalContextOther));
- assert (externalContextItem.getTestExternalContextItem002().getIntValue() == -1);
-
- try {
- externalContextAlbum.put("TestExternalContextItem00A", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItem00A\" for put()"));
- }
- assert (externalContextAlbum.get("externalContext").equals(externalContext));
-
- try {
- externalContextAlbum.put("TestExternalContextItemFFF", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()"));
- }
- assert (externalContextAlbum.size() == 1);
-
- try {
- externalContextAlbum.put("TestExternalContextItemFFF", null);
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key \"TestExternalContextItemFFF\" for put()"));
- }
- assert (externalContextAlbum.size() == 1);
-
- // Should ignore remove
- externalContextAlbum.remove("TestExternalContextItem017");
- assert (externalContextAlbum.size() == 1);
-
- assert (externalContextAlbum.values().size() == 1);
- assert (externalContextAlbum.values().containsAll(mapValues));
- // CHECKSTYLE:ON: checkstyle:magicNumber
- } catch (final Exception exception) {
- LOGGER.error("Error: ", exception);
- contextDistributor.clear();
- assert ("Test has failed".equals(""));
- }
-
- try {
- contextDistributor.clear();
- } catch (final Exception exception) {
- LOGGER.error("Error occured while clearing context distributor: ", exception);
- assert ("Test has failed".equals(""));
- }
- }
-}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java b/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
deleted file mode 100644
index d104900c9..000000000
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextRuntimeException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00C;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestContextUpdate checks context updates.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class ContextUpdate {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextUpdate.class);
-
- /**
- * Test context update.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException the IO exception
- * @throws ApexException the apex exception
- */
- public void testContextUpdate() throws ApexModelException, IOException, ApexException {
- LOGGER.debug("Running TestContextUpdate test . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- // CHECKSTYLE:OFF: checkstyle:magicNumber
-
- final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- contextDistributor.registerModel(multiModel);
-
- final ContextAlbum longContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"));
- assert (longContextAlbum != null);
- longContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final ContextAlbum dateContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateContextAlbum != null);
- longContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final ContextAlbum mapContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("MapContextAlbum", "0.0.1"));
- assert (mapContextAlbum != null);
- mapContextAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final TestContextItem00A tciA = new TestContextItem00A();
- tciA.setDateValue(new TestContextItem008(new Date()));
- tciA.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tciA.setDST(true);
- tciA.setUTCOffset(-600);
- tciA.setLocale(Locale.ENGLISH);
-
- final Map<String, String> testHashMap = new HashMap<>();
- testHashMap.put("0", "zero");
- testHashMap.put("1", "one");
- testHashMap.put("2", "two");
- testHashMap.put("3", "three");
- testHashMap.put("4", "four");
-
- final TestContextItem00C tciC = new TestContextItem00C(testHashMap);
-
- longContextAlbum.put("0", (long) 0);
- longContextAlbum.put("0", 0);
- longContextAlbum.put("0", "0");
-
- try {
- longContextAlbum.put("0", "zero");
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\""));
- }
-
- try {
- longContextAlbum.put("0", "");
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals(
- "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum:0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\""));
- }
-
- try {
- longContextAlbum.put("0", null);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage()
- .equals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()"));
- }
-
- try {
- longContextAlbum.put(null, null);
- assert ("Test should throw an exception".equals(""));
- } catch (final ContextRuntimeException e) {
- assert (e.getMessage().equals("album \"LongContextAlbum:0.0.1\" null keys are illegal on keys for put()"));
- }
-
- Object object = dateContextAlbum.put("date0", tciA);
- assert (object == null);
- object = dateContextAlbum.put("date0", tciA);
- assert (object.equals(tciA));
-
- object = mapContextAlbum.put("map0", tciC);
- assert (object == null);
- object = mapContextAlbum.put("map0", tciC);
- assert (object.equals(tciC));
-
- contextDistributor.clear();
- // CHECKSTYLE:ON: checkstyle:magicNumber
- }
-}
diff --git a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java b/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
deleted file mode 100644
index e22321cdf..000000000
--- a/context/context-test/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.context.test.distribution;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TimeZone;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.context.test.concepts.TestContextItem000;
-import org.onap.policy.apex.context.test.concepts.TestContextItem001;
-import org.onap.policy.apex.context.test.concepts.TestContextItem002;
-import org.onap.policy.apex.context.test.concepts.TestContextItem003;
-import org.onap.policy.apex.context.test.concepts.TestContextItem004;
-import org.onap.policy.apex.context.test.concepts.TestContextItem005;
-import org.onap.policy.apex.context.test.concepts.TestContextItem006;
-import org.onap.policy.apex.context.test.concepts.TestContextItem007;
-import org.onap.policy.apex.context.test.concepts.TestContextItem008;
-import org.onap.policy.apex.context.test.concepts.TestContextItem009;
-import org.onap.policy.apex.context.test.concepts.TestContextItem00A;
-import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class SequentialContextInstantiation checks sequential initiation of context.
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class SequentialContextInstantiation {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(SequentialContextInstantiation.class);
-
- /**
- * Test sequential context instantiation.
- *
- * @throws ContextException the context exception
- */
- // CHECKSTYLE:OFF: checkstyle:MaximumMethodLength
- public void testSequentialContextInstantiation() throws ContextException {
- // CHECKSTYLE:ON: MaximumMethodLength
- LOGGER.debug("Running TestContextInstantiation test . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- Distributor contextDistributor = null;
- try {
- contextDistributor = new DistributorFactory().getDistributor(distributorKey);
- } catch (final Exception exception) {
- LOGGER.error("Error occured while Instantiating Distributor for : {}", distributorKey, exception);
- assert ("Test has failed".equals(""));
- return;
- }
-
- // @formatter:off
- final AxArtifactKey[] usedArtifactStackArray = {
- new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"),
- new AxArtifactKey("testC-bot", "0.0.1")
- };
- // @formatter:on
-
- try {
- // CHECKSTYLE:OFF: checkstyle:magicNumber
- final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- contextDistributor.registerModel(multiModel);
-
- final ContextAlbum dateAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateAlbum != null);
- dateAlbum.setUserArtifactStack(usedArtifactStackArray);
-
- final Date testDate = new Date();
-
- final TestContextItem00A tciA00 = new TestContextItem00A();
- tciA00.setDateValue(new TestContextItem008(new Date()));
- tciA00.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tciA00.setDST(true);
- tciA00.setUTCOffset(-600);
- tciA00.setLocale(Locale.ENGLISH);
-
- dateAlbum.put("dv0", tciA00);
- assert (tciA00.equals(dateAlbum.get("dv0")));
-
- dateAlbum.put("dv1", tciA00);
- assert (tciA00.equals(dateAlbum.get("dv1")));
-
- final TestContextItem009 tci9 = new TestContextItem009();
- tci9.setDateValue(new TestContextItem008(testDate));
- tci9.setTZValue(TimeZone.getTimeZone("Europe/Dublin").getDisplayName());
- tci9.setDST(true);
-
- try {
- dateAlbum.put("tci9", tci9);
- } catch (final Exception e) {
- assert (e.getMessage().contains(
- "class \"org.onap.policy.apex.context.test.concepts.TestContextItem009\" not compatible with class \"org.onap.policy.apex.context.test.concepts.TestContextItem00A\""));
- }
-
- final TestContextItem00A tciA01 = new TestContextItem00A(tciA00);
- final TestContextItem00A tciA02 = new TestContextItem00A(tciA00);
- final TestContextItem00A tciA03 = new TestContextItem00A(tciA00);
-
- final Map<String, Object> valueMap0 = new HashMap<>();
- valueMap0.put("Item01", tciA01);
- valueMap0.put("Item02", tciA02);
- valueMap0.put("Item03", tciA03);
-
- dateAlbum.putAll(valueMap0);
- assert (dateAlbum.size() == 5);
- assert (tciA01.equals(dateAlbum.get("Item01")));
- assert (tciA02.equals(dateAlbum.get("Item02")));
- assert (tciA03.equals(dateAlbum.get("Item03")));
-
- final Float testFloat = new Float(3.14159265359);
-
- final TestContextItem000 testBadItem000 = new TestContextItem000();
- final TestContextItem001 testBadItem001 = new TestContextItem001();
- final TestContextItem002 testBadItem002 = new TestContextItem002();
- final TestContextItem003 testBadItem003 = new TestContextItem003();
- final TestContextItem004 testBadItem004 = new TestContextItem004();
- final TestContextItem005 testBadItem005 = new TestContextItem005();
- final TestContextItem006 testBadItem006 = new TestContextItem006();
- final TestContextItem007 testBadItem007 = new TestContextItem007();
- final TestContextItem008 testBadItem008 = new TestContextItem008();
-
- testBadItem000.setFlag(false);
- testBadItem001.setByteValue((byte) 0xFF);
- testBadItem002.setIntValue(0xFFFFFFFF);
- testBadItem003.setLongValue(0xFFFFFFFFFFFFFFFFL);
- testBadItem004.setFloatValue(testFloat);
- testBadItem005.setDoubleValue(Math.PI);
- testBadItem006.setStringValue("This is a global context string");
- testBadItem007.setLongValue(testDate.getTime());
- testBadItem008.setDateValue(testDate);
-
- final Map<String, Object> valueMap1 = new HashMap<>();
- valueMap1.put("TestBadItem000", testBadItem000);
- valueMap1.put("TestBadItem001", testBadItem001);
- valueMap1.put("TestBadItem002", testBadItem002);
- valueMap1.put("TestBadItem003", testBadItem003);
- valueMap1.put("TestBadItem004", testBadItem004);
- valueMap1.put("TestBadItem005", testBadItem005);
- valueMap1.put("TestBadItem006", testBadItem006);
- valueMap1.put("TestBadItem007", testBadItem007);
- valueMap1.put("TestBadItem008", testBadItem008);
- valueMap1.put("TestBadItem009", tci9);
- valueMap1.put("Item00_2", tciA00);
-
- // Get another reference to the album
- final ContextAlbum dateAlbum1 =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateAlbum1 != null);
- dateAlbum1.setUserArtifactStack(usedArtifactStackArray);
-
- try {
- dateAlbum1.putAll(valueMap1);
- } catch (final Exception e) {
- assert (e.getMessage().endsWith(
- "not compatible with class \"org.onap.policy.apex.context.test.concepts.TestContextItem00A\""));
- }
- assert (dateAlbum1.size() == 5);
-
- valueMap1.clear();
- valueMap1.put("Item00_2", tciA00);
- dateAlbum1.putAll(valueMap1);
- assert (dateAlbum1.size() == 6);
-
- assert (tciA00.equals(dateAlbum1.get("Item00_2")));
- dateAlbum.remove("Item00_2");
- assert (5 == dateAlbum1.size());
-
- final ContextAlbum dateAlbumCopy =
- contextDistributor.createContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"));
- assert (dateAlbumCopy != null);
- dateAlbumCopy.setUserArtifactStack(usedArtifactStackArray);
-
- final Map<String, Object> valueMap2 = new HashMap<>();
- valueMap2.put("Item04", tciA01);
- valueMap2.put("Item05", tciA02);
- valueMap2.put("Item06", tciA03);
-
- dateAlbumCopy.putAll(valueMap2);
- assert (8 == dateAlbumCopy.size());
- assert (tciA03.equals(dateAlbumCopy.get("Item06")));
-
- final Collection<Object> mapValues = dateAlbum.values();
- assert (dateAlbumCopy.values().containsAll(mapValues));
-
- // Check that clearing works
- dateAlbum1.clear();
- assert (dateAlbum1.size() == 0);
-
- dateAlbum.put("Item00", tciA00);
- final Map<String, Object> valueMap3 = new HashMap<>();
- valueMap3.put("Item01", tciA01);
- valueMap3.put("Item02", tciA02);
- valueMap3.put("Item03", tciA03);
- dateAlbum.putAll(valueMap3);
-
- final Map<String, Object> valueMap4 = new HashMap<>();
- valueMap4.put("Item04", tciA01);
- valueMap4.put("Item05", tciA02);
- valueMap4.put("Item06", tciA03);
-
- dateAlbumCopy.putAll(valueMap4);
-
- try {
- dateAlbum.containsKey(null);
- } catch (final Exception e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"key\""));
- }
-
- for (final Entry<String, Object> entry : dateAlbum.entrySet()) {
- System.out.println(entry.getKey() + "->" + entry.getValue());
- }
- assert (dateAlbum.containsKey("Item05"));
- assert (!dateAlbum.containsKey("Item07"));
-
- try {
- dateAlbum.containsValue(null);
- } catch (final Exception e) {
- assert (e.getMessage().equals("null values are illegal on method parameter \"value\""));
- }
-
- assert (dateAlbum.containsValue(tciA01));
- assert (!dateAlbum.containsValue(new String("Hello")));
-
- final Set<Entry<String, Object>> entrySet = dateAlbum.entrySet();
- assert (entrySet.size() == 7);
-
- try {
- assert (dateAlbum.get(null) == null);
- } catch (final Exception e) {
- assert (e.getMessage()
- .equals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()"));
- }
-
- final Object aObject = dateAlbum.get("Item03");
- assert (aObject.equals(tciA03));
-
- try {
- final Object object = dateAlbum.put(null, null);
- assert (object == null);
- } catch (final Exception e) {
- assert (e.getMessage()
- .equals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()"));
- }
-
- // Put null ContextItem should work (return null)
- try {
- dateAlbum.put("ItemNull", null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
- }
-
- // Should return null
- assert (dateAlbum.get("ItemNull") == null);
-
- // Put should return the previous contextItem
- tciA00.setDST(false);
- final TestContextItem00A tciA03_clone = new TestContextItem00A(tciA03);
- tciA03_clone.setDST(true);
- TestContextItem00A retItem = (TestContextItem00A) dateAlbum.put("Item03", tciA03_clone);
- assert (retItem.equals(tciA03));
- retItem = (TestContextItem00A) dateAlbum.put("Item03", tciA03);
- assert (retItem.equals(tciA03_clone));
-
- try {
- dateAlbum.put("ItemNull", null);
- assert (dateAlbum.get("ItemNull") == null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
- }
-
- dateAlbum.put("TestAA", tciA00);
- assert (dateAlbum.get("TestAA").equals(tciA00));
-
- // Should print warning
- try {
- dateAlbum.put("TestAA", null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" for put()"));
- }
- assert (dateAlbum.size() == 8);
- try {
- dateAlbum.put("TestAB", null);
- } catch (final Exception e) {
- assert (e.getMessage().equals(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" for put()"));
- }
- assert (dateAlbum.size() == 8);
-
- // Should do removes
- dateAlbum.remove("TestAA");
- dateAlbum.remove("TestAB");
- dateAlbum.remove("ItemNull");
- assert (dateAlbum.size() == 7);
- assert (dateAlbumCopy.values().containsAll(mapValues));
- // CHECKSTYLE:ON: checkstyle:magicNumber
- } catch (final Exception exception) {
- LOGGER.error("Error: ", exception);
- contextDistributor.clear();
- assert ("Test has failed".equals(""));
- }
-
- try {
- contextDistributor.clear();
- } catch (final Exception exception) {
- LOGGER.error("Error occured while clearing context distributor", exception);
- assert ("Test has failed".equals(""));
- }
- }
-}
diff --git a/context/pom.xml b/context/pom.xml
index dad850230..9fa599a39 100644
--- a/context/pom.xml
+++ b/context/pom.xml
@@ -35,6 +35,6 @@
<modules>
<module>context-management</module>
- <module>context-test</module>
+ <module>context-test-utils</module>
</modules>
</project> \ No newline at end of file