aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INFO.yaml14
-rw-r--r--auth/cli-codegen/pom.xml2
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java15
-rw-r--r--auth/cli-editor/pom.xml2
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java41
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java34
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java38
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java2
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java2
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineParametersTest.java61
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java3
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java17
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java7
-rw-r--r--auth/pom.xml2
-rw-r--r--context/context-management/pom.xml2
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java55
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java7
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java46
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java46
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/LockManagerTest.java75
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/PersistorTest.java84
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java17
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/DistributorTest.java132
-rw-r--r--context/pom.xml2
-rw-r--r--core/pom.xml2
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java2
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java11
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/infrastructure/threading/MessageExceptionTest.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/package-info.java)28
-rw-r--r--examples/examples-aadm/pom.xml2
-rw-r--r--examples/examples-acm/pom.xml2
-rw-r--r--examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestRestDmaapEndpoint.java97
-rw-r--r--examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java64
-rw-r--r--examples/examples-acm/src/main/resources/examples/config/apexACM/ApexConfig.json32
-rw-r--r--examples/examples-acm/src/test/java/org/onap/policy/apex/examples/acm/TestApexAcmExample.java36
-rw-r--r--examples/examples-adaptive/pom.xml2
-rw-r--r--examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java41
-rw-r--r--examples/examples-decisionmaker-sharedcontext/pom.xml2
-rw-r--r--examples/examples-decisionmaker/pom.xml2
-rw-r--r--examples/examples-grpc/pom.xml2
-rw-r--r--examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestRestSimEndpoint.java11
-rw-r--r--examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java8
-rw-r--r--examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java21
-rw-r--r--examples/examples-myfirstpolicy/pom.xml2
-rw-r--r--examples/examples-onap-bbs/pom.xml2
-rw-r--r--examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java7
-rw-r--r--examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java22
-rw-r--r--examples/examples-onap-vcpe/pom.xml2
-rw-r--r--examples/examples-periodic/pom.xml2
-rw-r--r--examples/examples-servlet/pom.xml2
-rw-r--r--examples/pom.xml2
-rw-r--r--model/pom.xml2
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java11
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java61
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java29
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java48
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java154
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java301
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java97
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java135
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReader.java41
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java16
-rw-r--r--packages/apex-pdp-docker/pom.xml2
-rw-r--r--packages/apex-pdp-docker/src/main/docker/Dockerfile2
-rw-r--r--packages/apex-pdp-package-full/pom.xml2
-rw-r--r--packages/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-distribution/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-locking/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/pom.xml2
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/pom.xml8
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/main/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelper.java49
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java4
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java10
-rw-r--r--plugins/plugins-context/plugins-context-schema/pom.xml2
-rw-r--r--plugins/plugins-context/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/pom.xml4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/pom.xml2
-rw-r--r--plugins/plugins-event/plugins-event-protocol/pom.xml2
-rw-r--r--plugins/plugins-event/pom.xml2
-rw-r--r--plugins/plugins-executor/plugins-executor-java/pom.xml2
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/pom.xml2
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/pom.xml2
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/pom.xml2
-rw-r--r--plugins/plugins-executor/pom.xml2
-rw-r--r--plugins/pom.xml2
-rw-r--r--pom.xml19
-rw-r--r--releases/4.0.0-container.yaml8
-rw-r--r--releases/4.0.0.yaml5
-rw-r--r--services/pom.xml2
-rw-r--r--services/services-engine/pom.xml2
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java3
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java3
-rw-r--r--services/services-onappf/pom.xml2
-rw-r--r--testsuites/apex-pdp-stability/pom.xml2
-rw-r--r--testsuites/integration/integration-common/pom.xml2
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/concepts/ConceptsTest.java183
-rw-r--r--testsuites/integration/integration-context-test/pom.xml74
-rw-r--r--testsuites/integration/integration-context-test/pom.xml.versionsBackup74
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java507
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextAlbumUpdate.java121
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java496
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java147
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java135
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java153
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java329
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java146
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java146
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/package-info.java27
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java216
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/package-info.java28
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/AlbumModifier.java43
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/LockType.java102
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java52
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java67
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java72
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java69
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/package-info.java26
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java165
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvm.java231
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvmThread.java132
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextThread.java92
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/package-info.java28
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProvider.java145
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java176
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java79
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/IntegrationThreadFactory.java59
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java65
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ZooKeeperServerServiceProvider.java105
-rwxr-xr-xtestsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/package-info.java28
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml63
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml76
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml87
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml35
-rw-r--r--testsuites/integration/integration-executor-test/pom.xml2
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java25
-rw-r--r--testsuites/integration/integration-uservice-test/pom.xml3
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/TestEventBase.java4
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java4
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java6
-rw-r--r--testsuites/integration/pom.xml18
-rw-r--r--testsuites/performance/performance-benchmark-test/pom.xml2
-rw-r--r--testsuites/performance/pom.xml2
-rw-r--r--testsuites/pom.xml2
-rw-r--r--tools/model-generator/pom.xml2
-rw-r--r--tools/pom.xml2
-rw-r--r--tools/simple-wsclient/pom.xml2
-rw-r--r--tools/tools-common/pom.xml2
-rw-r--r--tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java5
-rw-r--r--version.properties2
165 files changed, 1467 insertions, 5631 deletions
diff --git a/INFO.yaml b/INFO.yaml
index 9e9b959e4..eed863e86 100644
--- a/INFO.yaml
+++ b/INFO.yaml
@@ -31,11 +31,6 @@ repositories:
- 'policy/apex-pdp'
committers:
- <<: *onap_releng_ptl
- - name: 'Pamela Dragosh'
- email: 'pd1248@att.com'
- company: 'ATT'
- id: 'pdragosh'
- timezone: 'America/New_York'
- name: 'Jorge Hernandez'
email: 'jorge.hernandez-herrero@att.com'
company: 'ATT'
@@ -46,6 +41,11 @@ committers:
company: 'Bell Canada'
id: 'ramverma'
timezone: 'America/Montreal'
+ - name: 'Liam Fallon'
+ email: 'liam.fallon@est.tech'
+ id: 'liamfallon'
+ company: 'Ericsson'
+ timezone: 'Europe/Ireland'
- name: 'Ramesh Murugan Iyer'
email: 'ramesh.murugan.iyer@est.tech'
company: 'Ericsson'
@@ -89,3 +89,7 @@ tsc:
- type: 'Addition'
name: 'Adheli Tavares'
link: https://lists.onap.org/g/onap-tsc/message/9296
+ #Stepped Down
+ - type: 'Removal'
+ name: 'Pamela Dragosh'
+ link: https://lists.onap.org/g/onap-tsc/message/9550
diff --git a/auth/cli-codegen/pom.xml b/auth/cli-codegen/pom.xml
index 020f08614..af9cb36f3 100644
--- a/auth/cli-codegen/pom.xml
+++ b/auth/cli-codegen/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.auth</groupId>
<artifactId>auth</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>cli-codegen</artifactId>
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
index 1b44f66e7..54e50b5ab 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
@@ -25,6 +25,7 @@
package org.onap.policy.apex.auth.clicodegen;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.FileInputStream;
@@ -81,6 +82,20 @@ class CodeGeneratorCliEditorTest {
assertEquals(0, generateCli(codeGen, apexPolicyModel));
}
+ @Test
+ void testTaskDefFields() {
+ CodeGeneratorCliEditor editor = new CodeGeneratorCliEditor();
+ var st = editor.createTaskDefinitionInfields("InFieldTask", "1.0.0", "field1", "schema", "1.0.1");
+ assertNotNull(st);
+
+ var st2 = editor.createTaskDefinitionOutfields("OutFieldTask", "1.0.0", "field2", "schema", "1.0.1");
+ assertNotNull(st2);
+
+ var st3 = editor.createPolicyStateDefFinalizerLogic("dummy", "1.0.0", "dummyState",
+ "logicName", "flavor", "logic");
+ assertNotNull(st3);
+ }
+
/**
* Generate the CLI from the model.
*
diff --git a/auth/cli-editor/pom.xml b/auth/cli-editor/pom.xml
index 7250cb72a..0091de604 100644
--- a/auth/cli-editor/pom.xml
+++ b/auth/cli-editor/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.auth</groupId>
<artifactId>auth</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>cli-editor</artifactId>
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
index dfb3a3865..23820207f 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public class ApexModelHandler {
/**
* Create the Apex Model with the properties specified and load it from a file.
*
- * @param properties The properties of the Apex model
+ * @param properties The properties of the Apex model
* @param modelFileName The name of the model file to edit
*/
public ApexModelHandler(final Properties properties, final String modelFileName) {
@@ -72,13 +72,14 @@ public class ApexModelHandler {
/**
* Execute a command on the Apex model.
*
- * @param command The command to execute
+ * @param command The command to execute
* @param argumentValues Arguments of the command
- * @param writer A writer to which to write output
+ * @param writer A writer to which to write output
* @return the result of the executed command
*/
public Result executeCommand(final CommandLineCommand command,
- final SortedMap<String, CommandLineArgumentValue> argumentValues, final PrintWriter writer) {
+ final SortedMap<String, CommandLineArgumentValue> argumentValues,
+ final PrintWriter writer) {
// Get the method
final var apiMethod = getCommandMethod(command);
@@ -88,27 +89,26 @@ public class ApexModelHandler {
try {
final var returnObject = apiMethod.invoke(apexModel, parameterArray);
- if (returnObject instanceof ApexApiResult) {
- final ApexApiResult result = (ApexApiResult) returnObject;
+ if (returnObject instanceof ApexApiResult result) {
writer.println(result);
return result.getResult();
} else {
throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod()
- + FAILED_FOR_COMMAND + command.getName()
- + "\" the returned object is not an instance of ApexAPIResult");
+ + FAILED_FOR_COMMAND + command.getName()
+ + "\" the returned object is not an instance of ApexAPIResult");
}
} catch (IllegalAccessException | IllegalArgumentException e) {
writer.println(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\"");
+ + command.getName() + "\"");
e.printStackTrace(writer);
throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\"", e);
+ + command.getName() + "\"", e);
} catch (final InvocationTargetException e) {
writer.println(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\"");
+ + command.getName() + "\"");
e.getCause().printStackTrace(writer);
throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\"", e);
+ + command.getName() + "\"", e);
}
}
@@ -130,30 +130,31 @@ public class ApexModelHandler {
}
}
throw new CommandLineException("specified method \"" + command.getApiMethod()
- + "\" not found for command \"" + command.getName() + "\"");
+ + "\" not found for command \"" + command.getName() + "\"");
} catch (final ClassNotFoundException e) {
throw new CommandLineException("specified class \"" + command.getApiMethod() + "\" not found for command \""
- + command.getName() + "\"", e);
+ + command.getName() + "\"", e);
}
}
/**
* Get the arguments of the command as an ordered array of objects ready for the method.
*
- * @param command the command that invoked the method
+ * @param command the command that invoked the method
* @param argumentValues the argument values for the method
- * @param apiMethod the method itself
+ * @param apiMethod the method itself
* @return the argument list
*/
private Object[] getParameterArray(final CommandLineCommand command,
- final SortedMap<String, CommandLineArgumentValue> argumentValues, final Method apiMethod) {
+ final SortedMap<String, CommandLineArgumentValue> argumentValues,
+ final Method apiMethod) {
final var parameterArray = new Object[argumentValues.size()];
var item = 0;
try {
for (final Class<?> parametertype : apiMethod.getParameterTypes()) {
final String parameterValue = argumentValues.get(command.getArgumentList().get(item).getArgumentName())
- .getValue();
+ .getValue();
if (parametertype.equals(boolean.class)) {
parameterArray[item] = Boolean.valueOf(parameterValue);
@@ -164,7 +165,7 @@ public class ApexModelHandler {
}
} catch (final Exception e) {
throw new CommandLineException("number of argument mismatch on method \"" + command.getApiMethod()
- + "\" for command \"" + command.getName() + "\"", e);
+ + "\" for command \"" + command.getName() + "\"", e);
}
return parameterArray;
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java
index fcbf571ca..2910c041e 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,15 +42,15 @@ public class CommandLineParser {
*
* <p>Examples entity create name=hello description="description of hello" help entity list
*
- * @param line The line to parse
+ * @param line The line to parse
* @param logicBlock A block of logic code to be taken literally
* @return the string array list
*/
public List<String> parse(final String line, final String logicBlock) {
return checkFormat(
- mergeArguments(mergeEquals(splitOnEquals(
- stripAndSplitWords(mergeQuotes(splitOnChar(stripComments(line), '\"')))))),
- logicBlock);
+ mergeArguments(mergeEquals(splitOnEquals(
+ stripAndSplitWords(mergeQuotes(splitOnChar(stripComments(line), '\"')))))),
+ logicBlock);
}
/**
@@ -90,13 +90,13 @@ public class CommandLineParser {
/**
* This method merges the next set of quotes.
*
- * @param wordsSplitOnQuotes the words split on quotes
+ * @param wordsSplitOnQuotes the words split on quotes
* @param wordsWithQuotesMerged the merged words
- * @param wordIndex the current word index
+ * @param wordIndex the current word index
* @return the next word index
*/
private int mergeQuote(final ArrayList<String> wordsSplitOnQuotes, final ArrayList<String> wordsWithQuotesMerged,
- int wordIndex) {
+ int wordIndex) {
if ("\"".equals(wordsSplitOnQuotes.get(wordIndex))) {
var quotedWord = new StringBuilder(wordsSplitOnQuotes.get(wordIndex++));
@@ -167,9 +167,9 @@ public class CommandLineParser {
if ("=".equals(wordsSplitOnEquals.get(wordIndex))) {
if (wordIndex < wordsSplitOnEquals.size() - 1
- && !wordsSplitOnEquals.get(wordIndex + 1).startsWith("=")) {
+ && !wordsSplitOnEquals.get(wordIndex + 1).startsWith("=")) {
wordsWithEqualsMerged.add(
- wordsSplitOnEquals.get(wordIndex) + wordsSplitOnEquals.get(wordIndex + 1));
+ wordsSplitOnEquals.get(wordIndex) + wordsSplitOnEquals.get(wordIndex + 1));
wordIndex += 2;
} else {
wordsWithEqualsMerged.add(wordsSplitOnEquals.get(wordIndex++));
@@ -243,14 +243,14 @@ public class CommandLineParser {
* @param word the word to split
* @return the array of split words
*/
- private Collection<? extends String> stripAndSplitWord(final String word) {
+ private Collection<String> stripAndSplitWord(final String word) {
final ArrayList<String> strippedAndSplitWords = new ArrayList<>();
// Strip white space by replacing all white space with blanks and then removing leading
// and trailing blanks
String singleSpaceWord = word.replaceAll("\\s+", " ").trim();
- if (singleSpaceWord.length() == 0) {
+ if (singleSpaceWord.isEmpty()) {
return strippedAndSplitWords;
}
@@ -267,7 +267,7 @@ public class CommandLineParser {
* Dumpty had ""a "great" fall becomes [Humpty ],["],[Dumpty sat on the wall],["],[, Humpty Dumpty had ],["],["],a
* ["],[great],["],[ fall].
*
- * @param line the input line
+ * @param line the input line
* @param splitChar the split char
* @return the split array list
*/
@@ -300,7 +300,7 @@ public class CommandLineParser {
* This method checks that an array list containing a command is in the correct format.
*
* @param commandWords the command words
- * @param logicBlock A block of logic code to be taken literally
+ * @param logicBlock A block of logic code to be taken literally
* @return the checked array list
*/
private ArrayList<String> checkFormat(final ArrayList<String> commandWords, final String logicBlock) {
@@ -312,7 +312,7 @@ public class CommandLineParser {
// The first word must be alphanumeric, that is a command
if (!commandWords.get(0).matches("^[a-zA-Z0-9]*$")) {
throw new CommandLineException(
- "first command word is not alphanumeric or is not a command: " + commandWords.get(0));
+ "first command word is not alphanumeric or is not a command: " + commandWords.get(0));
}
// Now check that we have a sequence of commands at the beginning
@@ -330,12 +330,12 @@ public class CommandLineParser {
commandWords.set(currentWordPos, commandWords.get(currentWordPos) + logicBlock);
} else {
throw new CommandLineException(
- "command argument is not properly formed: " + commandWords.get(currentWordPos));
+ "command argument is not properly formed: " + commandWords.get(currentWordPos));
}
} else if (!commandWords.get(currentWordPos).matches("^[a-zA-Z0-9]+=[a-zA-Z0-9/\"].*$")) {
// Not a last command, or the last command, but there is no logic block - wrong pattern
throw new CommandLineException(
- "command argument is not properly formed: " + commandWords.get(currentWordPos));
+ "command argument is not properly formed: " + commandWords.get(currentWordPos));
}
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
index 5028abd31..ad606153a 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
@@ -24,10 +24,14 @@ package org.onap.policy.apex.auth.clieditor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
+import java.util.Properties;
+import java.util.SortedMap;
+import java.util.TreeMap;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -136,4 +140,38 @@ class CommandLineCommandTest {
otherCommand.getKeywordlist().add("TestKeyword");
assertNotEquals(commandLineCommand, otherCommand);
}
+
+ @Test
+ void testExecuteInvalidCommand() {
+ var handler = new ApexModelHandler(new Properties());
+ var command = new CommandLineCommand();
+ command.setApiMethod("java.invalid"); // invalid class
+ assertThrows(CommandLineException.class, () -> handler.executeCommand(command, null, null));
+
+ command.setApiMethod("org.onap.policy.apex.model.modelapi.ApexModel.invalid"); //invalid method
+ assertThrows(CommandLineException.class, () -> handler.executeCommand(command, null, null));
+
+ command.setApiMethod("org.onap.policy.apex.model.modelapi.ApexModel.saveToFile");
+ SortedMap<String, CommandLineArgumentValue> map = new TreeMap<>();
+ map.put("key", new CommandLineArgumentValue(null));
+ assertThrows(CommandLineException.class, () -> handler.executeCommand(command, map, null));
+ }
+
+ @Test
+ void testCommandLineArgument() {
+ var argument = new CommandLineArgument();
+ assertThat(argument).isEqualByComparingTo(argument);
+ var otherArgument = new CommandLineArgument("otherArgument");
+ assertThat(argument).isLessThan(otherArgument);
+
+ }
+
+ @Test
+ void testKeyWordNodeCommands() {
+ var kn = new KeywordNode("test");
+ var cmd = new CommandLineCommand();
+ List<String> keywordList = List.of("key1", "key2");
+ kn.processKeywords(keywordList, cmd);
+ assertNotNull(kn.getCommands());
+ }
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java
index dfdb4c2a3..eb31d15fb 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java
@@ -257,8 +257,8 @@ class CommandLineEditorOptionsTest {
assertEquals(3336, tempModelFileOutCharCount);
assertTrue(tempLogFileIn.delete());
- assertTrue(tempModelFileIn.delete());
assertTrue(tempLogFileOut.delete());
assertTrue(tempModelFileOut.delete());
+ tempModelFileIn.delete();
}
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java
index 395f4c6bf..2e98fcf45 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java
@@ -72,8 +72,8 @@ class CommandLineEditorScriptingTest {
*/
@AfterEach
public void removeGeneratedFiles() {
- assertTrue(tempModelFile.delete());
assertTrue(tempLogFile.delete());
+ tempModelFile.delete();
}
/**
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineParametersTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineParametersTest.java
new file mode 100644
index 000000000..b979d73df
--- /dev/null
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineParametersTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation. 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.auth.clieditor;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
+
+class CommandLineParametersTest {
+
+ @Test
+ void testMetadataFile() {
+ var clParameters = new CommandLineParameters();
+ assertNotNull(clParameters.getMetadataLocation());
+ assertFalse(clParameters.checkSetMetadataFileName());
+ clParameters.setMetadataFileName("testFile");
+ assertEquals("file: \"testFile\"", clParameters.getMetadataLocation());
+ assertTrue(clParameters.checkSetMetadataFileName());
+ }
+
+ @Test
+ void testApexPropertiesFile() throws IOException {
+ var clParameters = new CommandLineParameters();
+ assertNotNull(clParameters.getApexPropertiesLocation());
+ assertNotNull(clParameters.getApexPropertiesStream());
+ assertFalse(clParameters.checkSetApexPropertiesFileName());
+ clParameters.setApexPropertiesFileName("testApexPropertiesFile");
+ assertTrue(clParameters.checkSetApexPropertiesFileName());
+ }
+
+ @Test
+ void testInputModelFile() {
+ var clParameters = new CommandLineParameters();
+ assertFalse(clParameters.checkSetInputModelFileName());
+ assertFalse(clParameters.checkSetLogFileName());
+ clParameters.validate();
+ }
+}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java
index 6984b6701..e9ac89ae0 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.auth.clieditor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -62,7 +61,7 @@ class ContextAlbumsTest {
*/
@AfterEach
void removeGeneratedModels() {
- assertTrue(tempModelFile.delete());
+ tempModelFile.delete();
}
/**
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java
index d407e5a4e..aecc3a066 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java
@@ -22,7 +22,6 @@
package org.onap.policy.apex.auth.clieditor;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -46,6 +45,8 @@ class FileMacroTest {
private File tempModelFile;
private File tempLogFile;
+ private static final String WHITESPACE_REGEX = "(\\s+){1,4}";
+
/**
* Creates the temp files.
*
@@ -65,7 +66,7 @@ class FileMacroTest {
*/
@AfterEach
void removeGeneratedModels() {
- assertTrue(tempModelFile.delete());
+ tempModelFile.delete();
}
/**
@@ -95,19 +96,25 @@ class FileMacroTest {
writtenModel.getKeyInformation().getKeyInfoMap().clear();
compareModel.getKeyInformation().getKeyInfoMap().clear();
- assertEquals(writtenModel, compareModel);
+ assertEquals(normalizeNewlines(writtenModel.toString()), normalizeNewlines(compareModel.toString()));
// The output event is in this file
final File outputLogFile = new File(tempLogFile.getCanonicalPath());
final String outputLogString = TextFileUtils.getTextFileAsString(outputLogFile.getCanonicalPath())
- .replace(Paths.get("").toAbsolutePath() + File.separator, "").replaceAll("\\s+", "");
+ .replace(Paths.get("").toAbsolutePath() + File.separator, "")
+ .replaceAll(WHITESPACE_REGEX, "");
// We compare the log to what we expect to get
final String outputLogCompareString = TextFileUtils
- .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log").replaceAll("\\s+", "");
+ .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log")
+ .replaceAll(WHITESPACE_REGEX, "");
// Check what we got is what we expected to get
assertEquals(outputLogCompareString, outputLogString);
}
+
+ private String normalizeNewlines(String input) {
+ return input.replace("\r\n", "\n");
+ }
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java
index e30780ca0..111215b26 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java
@@ -22,7 +22,6 @@
package org.onap.policy.apex.auth.clieditor;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -67,8 +66,8 @@ class LogicBlockTest {
*/
@AfterEach
void removeTempFiles() {
- assertTrue(tempLogicModelFile.delete());
- assertTrue(tempAvroModelFile.delete());
+ tempLogicModelFile.delete();
+ tempAvroModelFile.delete();
}
/**
@@ -96,7 +95,7 @@ class LogicBlockTest {
writtenModel.getKeyInformation().getKeyInfoMap().clear();
compareModel.getKeyInformation().getKeyInfoMap().clear();
- assertEquals(writtenModel, compareModel);
+ assertEquals(compareModel, writtenModel);
}
/**
diff --git a/auth/pom.xml b/auth/pom.xml
index 88540c5b9..2ddfa11ca 100644
--- a/auth/pom.xml
+++ b/auth/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.auth</groupId>
diff --git a/context/context-management/pom.xml b/context/context-management/pom.xml
index 4754ff8dc..472bcfd35 100644
--- a/context/context-management/pom.xml
+++ b/context/context-management/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.context</groupId>
<artifactId>context</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>context-management</artifactId>
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java
index e45c47952..096e68889 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Set;
import lombok.EqualsAndHashCode;
import lombok.Getter;
+import lombok.NonNull;
import lombok.Setter;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
@@ -88,12 +89,12 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
* Constructor, instantiate the context album.
*
* @param albumDefinition The model definition of this context album
- * @param distributor The context distributor passed to us to distribute context across ContextAlbum instances
- * @param albumMap the album map
+ * @param distributor The context distributor passed to us to distribute context across ContextAlbum instances
+ * @param albumMap the album map
* @throws ContextException on errors creating context albums
*/
public ContextAlbumImpl(final AxContextAlbum albumDefinition, final Distributor distributor,
- final Map<String, Object> albumMap) throws ContextException {
+ final Map<String, Object> albumMap) throws ContextException {
Assertions.argumentNotNull(albumDefinition, "Context album definition may not be null");
Assertions.argumentNotNull(distributor, "Distributor may not be null");
Assertions.argumentNotNull(albumMap, "Album map may not be null");
@@ -109,7 +110,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
try {
// Get a schema helper to manage the translations between objects on the album map for this album
schemaHelper = new SchemaHelperFactory().createSchemaHelper(albumDefinition.getKey(),
- albumDefinition.getItemSchema());
+ albumDefinition.getItemSchema());
} catch (final ContextRuntimeException e) {
final var resultString = "could not initiate schema management for context album " + albumDefinition;
LOGGER.warn(resultString, e);
@@ -144,7 +145,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public void lockForReading(final String keyOnAlbum) throws ContextException {
distributor.lockForReading(albumDefinition.getKey(), keyOnAlbum);
monitor.monitorReadLock(albumDefinition.getKey(), albumDefinition.getItemSchema(), keyOnAlbum,
- userArtifactStack);
+ userArtifactStack);
}
/**
@@ -154,7 +155,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public void lockForWriting(final String keyOnAlbum) throws ContextException {
distributor.lockForWriting(albumDefinition.getKey(), keyOnAlbum);
monitor.monitorWriteLock(albumDefinition.getKey(), albumDefinition.getItemSchema(), keyOnAlbum,
- userArtifactStack);
+ userArtifactStack);
}
/**
@@ -164,7 +165,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public void unlockForReading(final String keyOnAlbum) throws ContextException {
distributor.unlockForReading(albumDefinition.getKey(), keyOnAlbum);
monitor.monitorReadUnlock(albumDefinition.getKey(), albumDefinition.getItemSchema(), keyOnAlbum,
- userArtifactStack);
+ userArtifactStack);
}
/**
@@ -174,7 +175,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public void unlockForWriting(final String keyOnAlbum) throws ContextException {
distributor.unlockForWriting(albumDefinition.getKey(), keyOnAlbum);
monitor.monitorWriteUnlock(albumDefinition.getKey(), albumDefinition.getItemSchema(), keyOnAlbum,
- userArtifactStack);
+ userArtifactStack);
}
/**
@@ -238,7 +239,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public Object get(final Object key) {
if (key == null) {
final var returnString =
- ALBUM + albumDefinition.getId() + "\" null keys are illegal on keys for get()";
+ ALBUM + albumDefinition.getId() + "\" null keys are illegal on keys for get()";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
@@ -250,7 +251,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
// Get the context value and monitor it
monitor.monitorGet(albumDefinition.getKey(), albumDefinition.getItemSchema(), key.toString(), item,
- userArtifactStack);
+ userArtifactStack);
return item;
}
@@ -273,7 +274,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
for (final Entry<String, Object> contextAlbumEntry : albumMap.entrySet()) {
final Object item = contextAlbumEntry.getValue();
monitor.monitorGet(albumDefinition.getKey(), albumDefinition.getItemSchema(), contextAlbumEntry.getKey(),
- item, userArtifactStack);
+ item, userArtifactStack);
valueList.add(contextAlbumEntry.getValue());
}
@@ -291,7 +292,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
for (final Entry<String, Object> contextAlbumEntry : albumMap.entrySet()) {
final Object item = contextAlbumEntry.getValue();
monitor.monitorGet(albumDefinition.getKey(), albumDefinition.getItemSchema(), contextAlbumEntry.getKey(),
- item, userArtifactStack);
+ item, userArtifactStack);
entrySet.add(new SimpleEntry<>(contextAlbumEntry.getKey(), contextAlbumEntry.getValue()));
}
@@ -305,21 +306,21 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public Object put(final String key, final Object incomingValue) {
if (key == null) {
final var returnString =
- ALBUM + albumDefinition.getId() + "\" null keys are illegal on keys for put()";
+ ALBUM + albumDefinition.getId() + "\" null keys are illegal on keys for put()";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
if (incomingValue == null) {
final var returnString = ALBUM + albumDefinition.getId() + "\" null values are illegal on key \""
- + key + "\" for put()";
+ + key + "\" for put()";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
if (!albumDefinition.isWritable()) {
final var returnString = ALBUM + albumDefinition.getId()
- + "\" put() not allowed on read only albums for key=\"" + key + "\", value=\"" + incomingValue;
+ + "\" put() not allowed on read only albums for key=\"" + key + "\", value=\"" + incomingValue;
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
@@ -332,18 +333,18 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
if (albumMap.containsKey(key)) {
// Update the value in the context item and in the context value map
monitor.monitorSet(albumDefinition.getKey(), albumDefinition.getItemSchema(), key, incomingValue,
- userArtifactStack);
+ userArtifactStack);
} else {
// Update the value in the context item and in the context value map
monitor.monitorInit(albumDefinition.getKey(), albumDefinition.getItemSchema(), key, incomingValue,
- userArtifactStack);
+ userArtifactStack);
}
// Put the translated value on the map and return the old map value
return albumMap.put(key, valueToPut);
} catch (final ContextRuntimeException e) {
final var returnString = "Failed to set context value for key \"" + key + "\" in album \""
- + albumDefinition.getId() + "\": " + e.getMessage();
+ + albumDefinition.getId() + "\": " + e.getMessage();
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString, e);
}
@@ -353,17 +354,17 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
* {@inheritDoc}.
*/
@Override
- public void putAll(final Map<? extends String, ? extends Object> incomingContextAlbum) {
+ public void putAll(@NonNull final Map<? extends String, ?> incomingContextAlbum) {
if (!albumDefinition.isWritable()) {
final var returnString =
- ALBUM + albumDefinition.getId() + "\" putAll() not allowed on read only albums";
+ ALBUM + albumDefinition.getId() + "\" putAll() not allowed on read only albums";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
// Sanity check on incoming context
Assertions.argumentOfClassNotNull(incomingContextAlbum, ContextRuntimeException.class,
- "cannot update context, context album is null");
+ "cannot update context, context album is null");
// Iterate over the incoming context
for (final Entry<String, Object> entry : albumMap.entrySet()) {
@@ -378,7 +379,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
}
// Put all the objects on the context album
- for (final Entry<? extends String, ? extends Object> incomingMapEntry : incomingContextAlbum.entrySet()) {
+ for (final Entry<? extends String, ?> incomingMapEntry : incomingContextAlbum.entrySet()) { // NOSONAR
// Put the entry on the map
this.put(incomingMapEntry.getKey(), incomingMapEntry.getValue());
}
@@ -391,7 +392,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public Object remove(final Object key) {
if (!albumDefinition.isWritable()) {
final var returnString = ALBUM + albumDefinition.getId()
- + "\" remove() not allowed on read only albums for key=\"" + key + "\"";
+ + "\" remove() not allowed on read only albums for key=\"" + key + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
@@ -404,7 +405,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
// Delete the item
final Object removedValue = albumMap.remove(key);
monitor.monitorDelete(albumDefinition.getKey(), albumDefinition.getItemSchema(), key.toString(), removedValue,
- userArtifactStack);
+ userArtifactStack);
// Return the value of the deleted item
return removedValue;
@@ -417,7 +418,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
public void clear() {
if (!albumDefinition.isWritable()) {
final var returnString =
- ALBUM + albumDefinition.getId() + "\" clear() not allowed on read only albums";
+ ALBUM + albumDefinition.getId() + "\" clear() not allowed on read only albums";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
@@ -426,7 +427,7 @@ public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextA
for (final Entry<String, Object> contextAlbumEntry : albumMap.entrySet()) {
final Object item = contextAlbumEntry.getValue();
monitor.monitorDelete(albumDefinition.getKey(), albumDefinition.getItemSchema(), contextAlbumEntry.getKey(),
- item, userArtifactStack);
+ item, userArtifactStack);
}
// Clear the map
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
index 08289e642..3602ce12a 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -84,7 +84,7 @@ public class SchemaHelperFactory {
}
// Get the class for the schema helper using reflection
- Object schemaHelperObject = null;
+ Object schemaHelperObject;
final String pluginClass = schemaHelperParameters.getSchemaHelperPluginClass();
try {
schemaHelperObject = Class.forName(pluginClass).getDeclaredConstructor().newInstance();
@@ -96,7 +96,7 @@ public class SchemaHelperFactory {
}
// Check the class is a schema helper
- if (!(schemaHelperObject instanceof SchemaHelper)) {
+ if (!(schemaHelperObject instanceof SchemaHelper schemaHelper)) {
final var resultString = "Specified Apex context schema helper plugin class \"" + pluginClass
+ "\" does not implement the SchemaHelper interface";
LOGGER.warn(resultString);
@@ -104,7 +104,6 @@ public class SchemaHelperFactory {
}
// The context schema helper to return
- final var schemaHelper = (SchemaHelper) schemaHelperObject;
// Lock and load the schema helper
schemaHelper.init(owningEntityKey.getKey(), schema);
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
index f601062bb..b1a1d36df 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,7 +49,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
// Get a reference to the logger
private static final XLogger LOGGER = XLoggerFactory.getXLogger(JavaSchemaHelper.class);
- // This map defines the built in types in types in Java
+ // This map defines the built-in types in Java
// @formatter:off
private static final Map<String, Class<?>> BUILT_IN_MAP = new HashMap<>();
@@ -81,7 +81,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
} catch (final Exception e) {
String resultSting = userKey.getId() + ": class/type " + schema.getSchema() + " for context schema \""
- + schema.getId() + "\" not found.";
+ + schema.getId() + "\" not found.";
if (JavaSchemaHelper.BUILT_IN_MAP.get(javatype) != null) {
resultSting += " Primitive types are not supported. Use the appropriate Java boxing type instead.";
} else {
@@ -103,13 +103,13 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
if (getSchemaClass() == null) {
final var returnString =
- getUserKey().getId() + ": could not create an instance, schema class for the schema is null";
+ getUserKey().getId() + ": could not create an instance, schema class for the schema is null";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
- if (incomingObject instanceof JsonElement) {
- final var elementJsonString = getGson().toJson((JsonElement) incomingObject);
+ if (incomingObject instanceof JsonElement jsonObject) {
+ final var elementJsonString = getGson().toJson(jsonObject);
return getGson().fromJson(elementJsonString, this.getSchemaClass());
}
@@ -118,8 +118,8 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
}
final var returnString = getUserKey().getId() + ": the object \"" + incomingObject + "\" of type \""
- + incomingObject.getClass().getName()
- + "\" is not an instance of JsonObject and is not assignable to \"" + getSchemaClass().getName() + "\"";
+ + incomingObject.getClass().getName()
+ + "\" is not an instance of JsonObject and is not assignable to \"" + getSchemaClass().getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
@@ -165,8 +165,8 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
return getGson().toJson(schemaObject);
} else {
final var returnString = getUserKey().getId() + ": object \"" + schemaObject.toString()
- + "\" of class \"" + schemaObject.getClass().getName() + "\" not compatible with class \""
- + getSchemaClass().getName() + "\"";
+ + "\" of class \"" + schemaObject.getClass().getName() + "\" not compatible with class \""
+ + getSchemaClass().getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
@@ -189,19 +189,19 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
*/
private Object numericConversion(final Object object) {
// Check if the incoming object is a number, if not do a string conversion
- if (object instanceof Number) {
+ if (object instanceof Number myNumber) {
if (getSchemaClass().isAssignableFrom(Byte.class)) {
- return ((Number) object).byteValue();
+ return myNumber.byteValue();
} else if (getSchemaClass().isAssignableFrom(Short.class)) {
- return ((Number) object).shortValue();
+ return myNumber.shortValue();
} else if (getSchemaClass().isAssignableFrom(Integer.class)) {
- return ((Number) object).intValue();
+ return myNumber.intValue();
} else if (getSchemaClass().isAssignableFrom(Long.class)) {
- return ((Number) object).longValue();
+ return myNumber.longValue();
} else if (getSchemaClass().isAssignableFrom(Float.class)) {
- return ((Number) object).floatValue();
+ return myNumber.floatValue();
} else if (getSchemaClass().isAssignableFrom(Double.class)) {
- return ((Number) object).doubleValue();
+ return myNumber.doubleValue();
}
}
@@ -222,8 +222,8 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
return stringConstructor.newInstance(object.toString());
} catch (final Exception e) {
final var returnString = getUserKey().getId() + ": object \"" + object.toString() + "\" of class \""
- + object.getClass().getName() + "\" not compatible with class \"" + getSchemaClass().getName()
- + "\"";
+ + object.getClass().getName() + "\" not compatible with class \"" + getSchemaClass().getName()
+ + "\"";
LOGGER.warn(returnString, e);
throw new ContextRuntimeException(returnString);
}
@@ -241,22 +241,22 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
var schemaParameters = (SchemaParameters) ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
JavaSchemaHelperParameters javaSchemaHelperParmeters =
- (JavaSchemaHelperParameters) schemaParameters.getSchemaHelperParameterMap().get("Java");
+ (JavaSchemaHelperParameters) schemaParameters.getSchemaHelperParameterMap().get("Java");
if (javaSchemaHelperParmeters == null) {
javaSchemaHelperParmeters = new JavaSchemaHelperParameters();
}
for (JavaSchemaHelperJsonAdapterParameters jsonAdapterEntry : javaSchemaHelperParmeters.getJsonAdapters()
- .values()) {
+ .values()) {
Object adapterObject;
try {
adapterObject = jsonAdapterEntry.getAdaptorClazz().getDeclaredConstructor().newInstance();
} catch (Exception e) {
final var returnString = getUserKey().getId() + ": instantiation of adapter class \""
- + jsonAdapterEntry.getAdaptorClass() + "\" to decode and encode class \""
- + jsonAdapterEntry.getAdaptedClass() + "\" failed: " + e.getMessage();
+ + jsonAdapterEntry.getAdaptorClass() + "\" to decode and encode class \""
+ + jsonAdapterEntry.getAdaptedClass() + "\" failed: " + e.getMessage();
LOGGER.warn(returnString, e);
throw new ContextRuntimeException(returnString);
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
index 216e3686a..5b1f3ee7f 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.context.impl;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -40,6 +41,8 @@ import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistribut
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.DistributorParameters;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
@@ -65,6 +68,7 @@ class ContextAlbumImplTest {
contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ contextParameters.getPersistorParameters().setFlushPeriod(30000);
ParameterService.register(contextParameters);
ParameterService.register(contextParameters.getDistributorParameters());
@@ -295,11 +299,53 @@ class ContextAlbumImplTest {
assertThatThrownBy(album::flush).hasMessage("map flush failed, supplied map is null");
AxContextAlbums albums = new AxContextAlbums();
ModelService.registerModel(AxContextAlbums.class, albums);
+
+ assertThatThrownBy(() -> {
+ distributor.createContextAlbum(new AxContextAlbums().getKey());
+ }).hasMessage("context album NULL:0.0.0 does not exist");
+
albums.getAlbumsMap().put(axContextAlbum.getKey(), axContextAlbum);
distributor.createContextAlbum(album.getKey());
+ axContextAlbum.setItemSchema(new AxArtifactKey());
+ albums.getAlbumsMap().put(axContextAlbum.getKey(), axContextAlbum);
+ assertThatThrownBy(() -> {
+ distributor.createContextAlbum(album.getKey());
+ }).hasMessageContaining("context album definition for TestContextAlbum:0.0.1 is invalid");
+
+ axContextAlbum.setItemSchema(new AxArtifactKey("invalid", "0.0.1"));
+ albums.getAlbumsMap().put(axContextAlbum.getKey(), axContextAlbum);
+ assertThatThrownBy(() -> {
+ distributor.createContextAlbum(album.getKey());
+ }).hasMessage("schema \"invalid:0.0.1\" for context album TestContextAlbum:0.0.1 does not exist");
+
album.flush();
ModelService.clear();
}
+
+ @Test
+ void testParametersToString() {
+ assertThat(ParameterService.get(ContextParameterConstants.MAIN_GROUP_NAME).toString())
+ .isInstanceOf(String.class);
+ assertThat(ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME).toString())
+ .isInstanceOf(String.class);
+ }
+
+ @Test
+ void testParameterSetter() {
+ var parameters = new PersistorParameters();
+ parameters.setFlushPeriod(0);
+ parameters.setPluginClass("TestPlugin.class");
+ assertEquals(300000, parameters.getFlushPeriod());
+
+ var distributorParameters = new DistributorParameters();
+ distributorParameters.setName("test");
+ distributorParameters.setPluginClass("TestPlugin.class");
+ assertEquals("test", distributorParameters.getName());
+
+ var contextParameters = new ContextParameters();
+ contextParameters.setDistributorParameters(distributorParameters);
+ assertEquals("test", contextParameters.getDistributorParameters().getName());
+ }
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/LockManagerTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/LockManagerTest.java
new file mode 100644
index 000000000..2aac635a1
--- /dev/null
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/LockManagerTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation. 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.impl;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
+import org.onap.policy.apex.context.impl.locking.LockManagerFactory;
+import org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.LockManagerParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.common.parameters.ParameterService;
+
+class LockManagerTest {
+
+ @Test
+ void testLock() {
+ var lockManager = new JvmLocalLockManager();
+ assertDoesNotThrow(() -> lockManager.lockForReading("test", "test"));
+ assertDoesNotThrow(() -> lockManager.unlockForReading("test", "test"));
+ assertThrows(ContextException.class, () -> lockManager.unlockForReading("test", "test"));
+ assertDoesNotThrow(() -> lockManager.lockForWriting("test", "test"));
+ assertDoesNotThrow(() -> lockManager.unlockForWriting("test", "test"));
+ assertThrows(ContextException.class, () -> lockManager.unlockForWriting("test", "test"));
+ }
+
+ @Test
+ void testShutDown() {
+ var lockManager = new JvmLocalLockManager();
+ assertDoesNotThrow(lockManager::shutdown);
+ }
+
+ @Test
+ void testCreateLockManager() {
+ var lockManagerFactory = new LockManagerFactory();
+ var parameters = new LockManagerParameters();
+ parameters.setPluginClass("invalid.class");
+ ParameterService.register(parameters);
+ assertThrows(ContextException.class, () -> lockManagerFactory.createLockManager(new AxArtifactKey()));
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+
+ // different plugin instance
+ parameters.setPluginClass(JvmLocalDistributor.class.getName());
+ ParameterService.register(parameters);
+ assertThrows(ContextException.class, () -> lockManagerFactory.createLockManager(new AxArtifactKey()));
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+
+ parameters.setPluginClass(LockManagerParameters.DEFAULT_LOCK_MANAGER_PLUGIN_CLASS);
+ ParameterService.register(parameters);
+ assertDoesNotThrow(() -> lockManagerFactory.createLockManager(new AxArtifactKey()));
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+ }
+}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/PersistorTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/PersistorTest.java
new file mode 100644
index 000000000..277598b4a
--- /dev/null
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/PersistorTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation. 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.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.util.TreeSet;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
+import org.onap.policy.apex.context.impl.persistence.PersistorFactory;
+import org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.common.parameters.ParameterService;
+
+
+class PersistorTest {
+
+ @AfterAll
+ public static void cleanUpAfterTest() {
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ ParameterService.clear();
+ }
+
+ @Test
+ void testContextItemRead() throws ContextException {
+ var persistor = new EphemeralPersistor();
+ assertNull(persistor.readContextItem(new AxReferenceKey(), null));
+ assertThat(persistor.readContextItems(null, null)).isInstanceOf(TreeSet.class);
+ persistor.init(new AxArtifactKey("testkey", "1.0.0"));
+ assertEquals("testkey", persistor.getKey().getName());
+ }
+
+ @Test
+ void testWriteContextItem() {
+ var persistor = new EphemeralPersistor();
+ assertThat(persistor.writeContextItem(new Object())).isInstanceOf(Object.class);
+ }
+
+ @Test
+ void testPersistorFactory() {
+ var factory = new PersistorFactory();
+ PersistorParameters params = new PersistorParameters();
+ params.setPluginClass("invalid.class");
+ ParameterService.register(params);
+ assertThrows(ContextException.class, () -> factory.createPersistor(new AxArtifactKey()));
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ params.setPluginClass(JvmLocalDistributor.class.getName());
+ ParameterService.register(params);
+ assertThrows(ContextException.class, () -> factory.createPersistor(new AxArtifactKey()));
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ params.setPluginClass(PersistorParameters.DEFAULT_PERSISTOR_PLUGIN_CLASS);
+ ParameterService.register(params);
+ assertDoesNotThrow(() -> factory.createPersistor(new AxArtifactKey()));
+ }
+}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
index 501b76c0a..453a614ab 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
@@ -22,13 +22,16 @@
package org.onap.policy.apex.context.impl.schema;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import java.util.Map;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.SchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
@@ -86,4 +89,18 @@ class SchemaHelperFactoryTest {
.hasMessage("Owner:0.0.1: class/type java.lang.Bad for context schema \"IntSchema:0.0.1\" "
+ "not found. Check the class path of the JVM");
}
+
+ @Test
+ void testSchemaHelperParameter() {
+ var schemaHelperParameters = new SchemaHelperParameters();
+ assertNotNull(schemaHelperParameters.toString());
+ }
+
+ @Test
+ void testSchemaParameterSetter() {
+ var parameters = new SchemaParameters();
+ parameters.setName("testSchema");
+ parameters.setSchemaHelperParameterMap(Map.of("test", new SchemaHelperParameters()));
+ assertEquals("testSchema", parameters.getName());
+ }
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/DistributorTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/DistributorTest.java
new file mode 100644
index 000000000..5e27be99f
--- /dev/null
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/DistributorTest.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation. 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.impl.schema.java;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.impl.distribution.DistributorFlushTimerTask;
+import org.onap.policy.apex.context.impl.distribution.jvmlocal.JvmLocalDistributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.DistributorParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.service.ModelService;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
+import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
+
+
+class DistributorTest {
+
+ @BeforeAll
+ public static void prepareForTest() {
+ final var contextParameters = new ContextParameters();
+ contextParameters.getLockManagerParameters()
+ .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager");
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+ }
+
+ /**
+ * Clear down the test data.
+ */
+ @AfterAll
+ public static void cleanUpAfterTest() {
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ ParameterService.clear();
+ }
+
+ @Test
+ void testModelRegister() throws ContextException {
+ var schemas = new AxContextSchemas();
+ var simpleIntSchema = new AxContextSchema(new AxArtifactKey("SimpleIntSchema", "0.0.1"), "JAVA",
+ "java.lang.Integer");
+ schemas.getSchemasMap().put(simpleIntSchema.getKey(), simpleIntSchema);
+
+ var axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
+ true, AxArtifactKey.getNullKey());
+
+ axContextAlbum.setItemSchema(simpleIntSchema.getKey());
+ var model = new AxContextModel(new AxArtifactKey("TestArtifact", "0.0.1"));
+ var albums = new AxContextAlbums();
+ albums.getAlbumsMap().put(axContextAlbum.getKey(), axContextAlbum);
+ model.setAlbums(albums);
+ model.setSchemas(schemas);
+ var distributor = new JvmLocalDistributor();
+ assertDoesNotThrow(() -> distributor.registerModel(model));
+
+ distributor.flush();
+ ModelService.clear();
+ }
+
+ @Test
+ void testDistributorFlushTimer() throws ContextException {
+ var distributor = new JvmLocalDistributor();
+ distributor.init(new AxArtifactKey("test", "0.0.1"));
+ var timerTask = new DistributorFlushTimerTask(distributor);
+ assertDoesNotThrow(timerTask::run);
+ assertDoesNotThrow(timerTask::toString);
+ assertTrue(timerTask.cancel());
+ }
+
+ @Test
+ void testDistributorFactory() {
+ var dfactory = new DistributorFactory();
+ var axArtifactKey = new AxArtifactKey("testKey", "1.0.1");
+ assertDoesNotThrow(() -> dfactory.getDistributor(axArtifactKey));
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ var params = new DistributorParameters();
+ params.setPluginClass("invalid.class");
+ ParameterService.register(params);
+ assertThrows(ContextException.class, () -> dfactory.getDistributor(axArtifactKey));
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ params.setPluginClass("org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor");
+ ParameterService.register(params);
+ assertThrows(ContextException.class, () -> dfactory.getDistributor(axArtifactKey));
+ }
+
+ @Test
+ void testAbstractDistributor() throws ContextException {
+ var distributor = new JvmLocalDistributor();
+ assertThrows(ContextException.class, () -> distributor.removeContextAlbum(new AxArtifactKey()));
+ assertDoesNotThrow(distributor::flush);
+ distributor.init(new AxArtifactKey());
+ assertDoesNotThrow(distributor::clear);
+
+ }
+}
diff --git a/context/pom.xml b/context/pom.xml
index 2cd665e3f..92263db96 100644
--- a/context/pom.xml
+++ b/context/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.context</groupId>
diff --git a/core/pom.xml b/core/pom.xml
index 4e5d4310b..461ba545f 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.core</groupId>
diff --git a/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java b/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
index 773923444..862c357be 100644
--- a/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
+++ b/core/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
@@ -385,7 +385,7 @@ public class ApexEngineImpl implements ApexEngine {
}
updateStatePrometheusMetric();
- String message = "execute(): triggered by event " + incomingEvent.toString();
+ String message = "execute(): triggered by event " + incomingEvent;
LOGGER.debug(message);
// By default, we return a null event on errors
diff --git a/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java b/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
index cea505854..a9c3f68c5 100644
--- a/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
+++ b/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
@@ -3,7 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,16 +68,15 @@ public class ApplicationThreadFactory implements ThreadFactory {
/**
* Instantiates a new application thread factory with a specified thread priority.
*
- * @param nameLocal the name local
- * @param stackSize the stack size
+ * @param nameLocal the name local
+ * @param stackSize the stack size
* @param threadPriority the thread priority
*/
@SuppressWarnings({
"deprecation", "removal"
})
public ApplicationThreadFactory(final String nameLocal, final long stackSize, final int threadPriority) {
- @SuppressWarnings("removal")
- final var s = System.getSecurityManager();
+ @SuppressWarnings("removal") final var s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
name = APPLICATION_NAME + nameLocal + HYPHEN + NEXT_POOL_NUMBER.getAndIncrement();
this.stackSize = stackSize;
@@ -118,6 +117,6 @@ public class ApplicationThreadFactory implements ThreadFactory {
@Override
public String toString() {
return "ApplicationThreadFactory [nextPoolNumber=" + NEXT_POOL_NUMBER + ",nextThreadNumber=" + nextThreadNumber
- + ", name=" + name + ", stackSize=" + stackSize + ", threadPriority=" + threadPriority + "]";
+ + ", name=" + name + ", stackSize=" + stackSize + ", threadPriority=" + threadPriority + "]";
}
}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/package-info.java b/core/src/test/java/org/onap/policy/apex/core/infrastructure/threading/MessageExceptionTest.java
index 04230aaae..c28e322fe 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/package-info.java
+++ b/core/src/test/java/org/onap/policy/apex/core/infrastructure/threading/MessageExceptionTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2024 Nordix Foundation. 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.
@@ -19,10 +18,23 @@
* ============LICENSE_END=========================================================
*/
-/**
- * Runs context distribution tests in APEX.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
+package org.onap.policy.apex.core.infrastructure.threading;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
+
+
+class MessageExceptionTest {
+
+ @Test
+ void testMessageException() {
+ var exception = new MessagingException("Test error");
+ assertEquals("Test error", exception.getMessage());
-package org.onap.policy.apex.testsuites.integration.context.distribution;
+ var exception2 = new MessagingException("Test error2", new NullPointerException());
+ assertThat(exception2).isInstanceOf(MessagingException.class).hasMessage("Test error2");
+ }
+}
diff --git a/examples/examples-aadm/pom.xml b/examples/examples-aadm/pom.xml
index 54a8c8830..7ad7938b7 100644
--- a/examples/examples-aadm/pom.xml
+++ b/examples/examples-aadm/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-aadm</artifactId>
diff --git a/examples/examples-acm/pom.xml b/examples/examples-acm/pom.xml
index be4a54328..d89609583 100644
--- a/examples/examples-acm/pom.xml
+++ b/examples/examples-acm/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-acm</artifactId>
<name>examples-acm</name>
diff --git a/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestRestDmaapEndpoint.java b/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestRestDmaapEndpoint.java
deleted file mode 100644
index 8aed72080..000000000
--- a/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestRestDmaapEndpoint.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation.
- * ================================================================================
- * 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.examples.acm;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Response;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class AcmTestRestDmaapEndpoint creates rest server endpoints for simulating sending/receiving events on DMaaP.
- */
-@Path("/")
-@Produces("application/json")
-public class AcmTestRestDmaapEndpoint {
-
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(AcmTestRestDmaapEndpoint.class);
- private final Object lock = new Object();
- private static String loggedOutputEvent = "";
- private static final AtomicInteger counter = new AtomicInteger(1);
-
- /**
- * DMaaP input of events. This input event triggers the policy
- *
- * @param timeout the timeout to wait for
- * @return the response
- */
- @Path("events/AC_ELEMENT_MSG/APEX/1")
- @GET
- public Response getMessages(@QueryParam("timeout") final int timeout) {
- String createRequest = "{\"messageType\":\"STATUS\","
- + "\"elementId\":{\"name\":\"onap.policy.clamp.ac.startertobridge\",\"version\":\"1.0.0\"},"
- + "\"message\":\"starter: onap.policy.clamp.ac.starter 1.0.0\",\"messageId\":\""
- + counter.incrementAndGet() + "\",\"timestamp\":\"2022-08-19T07:37:01.198592Z\"}";
- LOGGER.info("Create request received: \n {}", createRequest);
-
- return Response.status(200).entity(List.of(createRequest)).build();
- }
-
- /**
- * Post new message.
- *
- * @param jsonString the message
- * @return the response
- */
- @Path("events/POLICY_UPDATE_MSG")
- @POST
- public Response policyMessage(final String jsonString) {
- LOGGER.info("\n*** POLICY LOG ENTRY START ***\n {} \n *** POLICY LOG ENTRY END ***", jsonString);
- synchronized (lock) {
- loggedOutputEvent += jsonString + "\n";
- }
- return Response.status(200).build();
- }
-
- /**
- * Get the logged event for test verification.
- *
- * @return the response
- */
- @Path("events/getLoggedEvent")
- @GET
- public Response getDetails() {
- String loggedEvent;
- synchronized (lock) {
- loggedEvent = loggedOutputEvent;
- }
- if (null == loggedEvent) {
- return Response.status(500).entity("Error: Log event not yet generated.").build();
- }
- return Response.status(200).entity(loggedEvent).build();
- }
-}
diff --git a/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java b/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java
deleted file mode 100644
index fb22d14ac..000000000
--- a/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2024 Nordix Foundation.
- * ================================================================================
- * 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.examples.acm;
-
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-/**
- * The Class AcmTestServerDmaap that manages test servers for REST requests for the test.
- */
-public class AcmTestServerDmaap implements AutoCloseable {
- private static final String HOST = "localhost";
- private HttpServletServer restServer;
- private int restServerPort = 3904;
-
- /**
- * Instantiates a new REST simulator for DMaaP requests.
- */
- public AcmTestServerDmaap() {
- restServer = HttpServletServerFactoryInstance.getServerFactory().build("AcmTestRestDmaapEndpoint", false, HOST,
- restServerPort, false, "/", false, false);
- restServer.addServletClass(null, AcmTestRestDmaapEndpoint.class.getName());
- restServer.setSerializationProvider(GsonMessageBodyHandler.class.getName());
- restServer.start();
- }
-
- /**
- * Validate the Rest server.
- * @throws InterruptedException if is not alive
- */
- public void validate() throws InterruptedException {
- if (!NetworkUtil.isTcpPortOpen(HOST, restServerPort, 50, 200L)) {
- throw new IllegalStateException("port " + restServerPort + " is still not in use");
- }
- }
-
- @Override
- public void close() {
- if (restServer != null) {
- restServer.stop();
- restServer = null;
- }
- }
-}
diff --git a/examples/examples-acm/src/main/resources/examples/config/apexACM/ApexConfig.json b/examples/examples-acm/src/main/resources/examples/config/apexACM/ApexConfig.json
index 6a2feaaa0..ae5d36c7c 100644
--- a/examples/examples-acm/src/main/resources/examples/config/apexACM/ApexConfig.json
+++ b/examples/examples-acm/src/main/resources/examples/config/apexACM/ApexConfig.json
@@ -24,10 +24,21 @@
"eventInputParameters": {
"DmaapConsumer": {
"carrierTechnologyParameters": {
- "carrierTechnology": "RESTCLIENT",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "carrierTechnology": "KAFKA",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters",
"parameters": {
- "url": "http://localhost:3904/events/AC_ELEMENT_MSG/APEX/1?timeout=30000"
+ "bootstrapServers": "kafka:9092",
+ "groupId": "clamp-grp",
+ "enableAutoCommit": "true",
+ "autoCommitTime": "1000",
+ "sessionTimeout": "30000",
+ "consumerPollTime": "100",
+ "consumerTopicList": [
+ "ac_element_msg"
+ ],
+ "keyDeserializer": "org.apache.kafka.common.serialization.StringDeserializer",
+ "valueDeserializer": "org.apache.kafka.common.serialization.StringDeserializer",
+ "kafkaProperties": [ ]
}
},
"eventProtocolParameters": {
@@ -54,10 +65,19 @@
},
"DmaapReplyProducer": {
"carrierTechnologyParameters": {
- "carrierTechnology": "RESTCLIENT",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "carrierTechnology": "KAFKA",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters",
"parameters": {
- "url": "http://localhost:3904/events/POLICY_UPDATE_MSG"
+ "bootstrapServers": "kafka:9092",
+ "acks": "all",
+ "retries": "0",
+ "batchSize": "16384",
+ "lingerTime": "1",
+ "bufferMemory": "33554432",
+ "producerTopic": "policy_update_msg",
+ "keySerializer": "org.apache.kafka.common.serialization.StringSerializer",
+ "valueSerializer": "org.apache.kafka.common.serialization.StringSerializer",
+ "kafkaProperties": [ ]
}
},
"eventProtocolParameters": {
diff --git a/examples/examples-acm/src/test/java/org/onap/policy/apex/examples/acm/TestApexAcmExample.java b/examples/examples-acm/src/test/java/org/onap/policy/apex/examples/acm/TestApexAcmExample.java
index be4bec096..8b360d39b 100644
--- a/examples/examples-acm/src/test/java/org/onap/policy/apex/examples/acm/TestApexAcmExample.java
+++ b/examples/examples-acm/src/test/java/org/onap/policy/apex/examples/acm/TestApexAcmExample.java
@@ -20,13 +20,14 @@
package org.onap.policy.apex.examples.acm;
-import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import jakarta.ws.rs.client.ClientBuilder;
-import java.util.concurrent.TimeUnit;
+import java.nio.file.Files;
+import java.nio.file.Path;
import org.junit.jupiter.api.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
-import org.onap.policy.apex.service.engine.main.ApexMain;
+
/**
* Test class to run an example policy for ACM interaction. Event received on
@@ -36,8 +37,7 @@ class TestApexAcmExample {
@Test
void testExample() {
- try (var dmmap = new AcmTestServerDmaap()) {
- dmmap.validate();
+ try {
// @formatter:off
final String[] cliArgs = new String[] {
@@ -54,29 +54,9 @@ class TestApexAcmExample {
};
// @formatter:on
- new ApexCliToscaEditorMain(cliArgs);
-
- // @formatter:off
- final String[] apexArgs = {
- "-rfr",
- "target/classes",
- "-p",
- "target/classes/APEXacElementPolicy.json"
- };
- // @formatter:on
-
- final var client = ClientBuilder.newClient();
- final var apexMain = new ApexMain(apexArgs);
-
- await().atMost(5000, TimeUnit.MILLISECONDS).until(apexMain::isAlive);
+ assertDoesNotThrow(() -> new ApexCliToscaEditorMain(cliArgs));
+ assertTrue(Files.exists(Path.of("target/classes/APEXacElementPolicy.json")));
- String getLoggedEventUrl = "http://localhost:3904/events/getLoggedEvent";
- await().atMost(20000, TimeUnit.MILLISECONDS).until(() -> {
- var response = client.target(getLoggedEventUrl).request("application/json").get();
- var responseEntity = response.readEntity(String.class);
- return responseEntity != null && !responseEntity.isEmpty();
- });
- apexMain.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/examples/examples-adaptive/pom.xml b/examples/examples-adaptive/pom.xml
index 0ec044f67..f3f2bc743 100644
--- a/examples/examples-adaptive/pom.xml
+++ b/examples/examples-adaptive/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-adaptive</artifactId>
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
index 317a86349..d1a5970e3 100644
--- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
+++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (c) 2021 Nordix Foundation.
+ * Modifications Copyright (c) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,11 +52,12 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
* @return the task
*/
public boolean getTask(final TaskSelectionExecutionContext executor) {
+ var returnValue = true;
var idString = executor.subject.getId();
- executor.logger.debug(idString);
+ TaskSelectionExecutionContext.logger.debug(idString);
var inFieldsString = executor.inFields.toString();
- executor.logger.debug(inFieldsString);
+ TaskSelectionExecutionContext.logger.debug(inFieldsString);
final List<String> tasks = executor.subject.getTaskNames();
size = tasks.size();
@@ -64,8 +65,8 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
try {
executor.getContextAlbum(AUTO_LEARN_ALBUM).lockForWriting(AUTO_LEARN);
} catch (final ContextException e) {
- executor.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
- return false;
+ TaskSelectionExecutionContext.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
+ returnValue = false;
}
// Get the context object
@@ -89,23 +90,23 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
try {
executor.getContextAlbum(AUTO_LEARN_ALBUM).unlockForWriting(AUTO_LEARN);
} catch (final ContextException e) {
- executor.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
- return false;
+ TaskSelectionExecutionContext.logger.error("Failed to acquire write lock on \"autoLearn\" context", e);
+ returnValue = false;
}
executor.subject.getTaskKey(tasks.get(option)).copyTo(executor.selectedTask);
- return true;
+ return returnValue;
}
/**
* Gets the option.
*
- * @param diff the diff
+ * @param diff the diff
* @param autoLearn the auto learn
* @return the option
*/
private int getOption(final double diff, final AutoLearn autoLearn) {
- final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[autoLearn.getAvDiffs().size()]);
+ final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[0]);
final var r = RAND.nextInt(size);
int closestupi = -1;
int closestdowni = -1;
@@ -130,13 +131,13 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
/**
* Learn.
*
- * @param option the option
- * @param diff the diff
+ * @param option the option
+ * @param diff the diff
* @param autoLearn the auto learn
*/
private void learn(final int option, final double diff, final AutoLearn autoLearn) {
- final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[autoLearn.getAvDiffs().size()]);
- final Long[] counts = autoLearn.getCounts().toArray(new Long[autoLearn.getCounts().size()]);
+ final Double[] avdiffs = autoLearn.getAvDiffs().toArray(new Double[0]);
+ final Long[] counts = autoLearn.getCounts().toArray(new Long[0]);
if (option < 0 || option >= avdiffs.length) {
throw new IllegalArgumentException("Error: option" + option);
}
@@ -153,16 +154,16 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
/**
* Calculate the return value of the learning.
*
- * @param diff the difference
- * @param random the random value
- * @param closestupi closest to i upwards
+ * @param diff the difference
+ * @param random the random value
+ * @param closestupi closest to i upwards
* @param closestdowni closest to i downwards
- * @param closestup closest up value
- * @param closestdown closest down value
+ * @param closestup closest up value
+ * @param closestdown closest down value
* @return the return value
*/
private int calculateReturnValue(final double diff, final int random, int closestupi, int closestdowni,
- double closestup, double closestdown) {
+ double closestup, double closestdown) {
if (closestupi == -1 || closestdowni == -1) {
return random;
}
diff --git a/examples/examples-decisionmaker-sharedcontext/pom.xml b/examples/examples-decisionmaker-sharedcontext/pom.xml
index 4b6a8dacf..7891682bc 100644
--- a/examples/examples-decisionmaker-sharedcontext/pom.xml
+++ b/examples/examples-decisionmaker-sharedcontext/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-decisionmaker-sharedcontext</artifactId>
diff --git a/examples/examples-decisionmaker/pom.xml b/examples/examples-decisionmaker/pom.xml
index b6597f0b5..00a4ae517 100644
--- a/examples/examples-decisionmaker/pom.xml
+++ b/examples/examples-decisionmaker/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-decisionmaker</artifactId>
diff --git a/examples/examples-grpc/pom.xml b/examples/examples-grpc/pom.xml
index 040fc315e..9ccd9d91f 100644
--- a/examples/examples-grpc/pom.xml
+++ b/examples/examples-grpc/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-grpc</artifactId>
<name>examples-grpc</name>
diff --git a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestRestSimEndpoint.java b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestRestSimEndpoint.java
index 3d46e6a80..56539a1d7 100644
--- a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestRestSimEndpoint.java
+++ b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestRestSimEndpoint.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2023 Nordix Foundation.
+ * Copyright (C) 2020-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
package org.onap.policy.apex.examples.grpc;
+import static org.awaitility.Awaitility.await;
+
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@@ -28,6 +30,7 @@ import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -52,8 +55,12 @@ public class GrpcTestRestSimEndpoint {
public Response dcaeClOutput(@QueryParam("timeout") final int timeout) throws IOException {
String createSubscriptionRequest =
Files.readString(Paths.get("src/main/resources/examples/events/APEXgRPC/CreateSubscriptionEvent.json"));
- LOGGER.info("Create subscription request received: \n {}", createSubscriptionRequest);
+ LOGGER.info("Create subscription request received (on a timeout of {}): \n {} ",
+ timeout, createSubscriptionRequest);
+ await().pollDelay(4, TimeUnit.SECONDS)
+ .atMost(5, TimeUnit.SECONDS)
+ .until(() -> true);
return Response.status(200).entity(createSubscriptionRequest).build();
}
diff --git a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java
index 46e0ea254..4dc638551 100644
--- a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java
+++ b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020,2023 Nordix Foundation.
+ * Copyright (C) 2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,11 +33,11 @@ import org.onap.policy.simulators.CdsSimulator;
*/
public class GrpcTestServerSim {
private static final String HOST = "localhost";
- private HttpServletServer restServer;
- private CdsSimulator grpcServer;
+ private final HttpServletServer restServer;
+ private final CdsSimulator grpcServer;
/**
- * Instantiates a new REST simulator for DMaaP requests.
+ * Instantiates a new REST simulator for requests.
*
* @throws InterruptedException interrupted exception
* @throws IOException io exception
diff --git a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
index ee1744f0e..e6d71e1ff 100644
--- a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
+++ b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
@@ -41,6 +41,7 @@ import org.onap.policy.apex.service.engine.main.ApexMain;
* CDS is used to send a final output Log event on POLICY_CL_MGT topic.
*/
class TestApexGrpcExample {
+
@Test
void testGrpcExample() throws Exception {
// @formatter:off
@@ -78,18 +79,24 @@ class TestApexGrpcExample {
String getLoggedEventUrl = "http://localhost:54321/GrpcTestRestSim/sim/event/getLoggedEvent";
// wait for success response code to be received, until a timeout
- await().atMost(20000, TimeUnit.MILLISECONDS).until(() ->
- 200 == client.target(getLoggedEventUrl).request("application/json").get().getStatus());
+ await().atMost(50000, TimeUnit.MILLISECONDS)
+ .pollInterval(10000, TimeUnit.MILLISECONDS)
+ .until(() -> 200 == client.target(getLoggedEventUrl).request("application/json").get().getStatus());
+
apexMain.shutdown();
+
Response response = client.target(getLoggedEventUrl).request("application/json").get();
sim.tearDown();
+
String responseEntity = response.readEntity(String.class);
- String expectedLoggedOutputEvent = Files
- .readString(Paths.get("src/main/resources/examples/events/APEXgRPC/LogEvent.json")).replaceAll("\r", "");
- String expectedStatusEvent =
- Files.readString(Paths.get("src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json"))
- .replaceAll("\r", "");
+ var logFileJson = "src/main/resources/examples/events/APEXgRPC/LogEvent.json";
+ String expectedLoggedOutputEvent = Files.readString(Paths.get(logFileJson)).replaceAll("\r", "");
+
+ var cdsResponseJson = "src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json";
+ String expectedStatusEvent = Files.readString(Paths.get(cdsResponseJson)).replaceAll("\r", "");
+
// Both LogEvent and CDSResponseStatusEvent are generated from the final state in the policy
assertThat(responseEntity).contains(expectedStatusEvent).contains(expectedLoggedOutputEvent);
+ client.close();
}
} \ No newline at end of file
diff --git a/examples/examples-myfirstpolicy/pom.xml b/examples/examples-myfirstpolicy/pom.xml
index 2dc190450..5c5996311 100644
--- a/examples/examples-myfirstpolicy/pom.xml
+++ b/examples/examples-myfirstpolicy/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-myfirstpolicy</artifactId>
diff --git a/examples/examples-onap-bbs/pom.xml b/examples/examples-onap-bbs/pom.xml
index cc31b4f92..4d2c47b33 100644
--- a/examples/examples-onap-bbs/pom.xml
+++ b/examples/examples-onap-bbs/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-onap-bbs</artifactId>
diff --git a/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java b/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java
index 6dfd2b5f2..8e9b4fe7c 100644
--- a/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java
+++ b/examples/examples-onap-bbs/src/main/java/org/onap/policy/apex/examples/bbs/WebClient.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Huawei. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021,2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,7 +73,7 @@ public class WebClient {
* @param contentType http content type
* @return String response message
*/
- public String httpRequest(String requestUrl, String requestMethod, String outputStr, String username, String pass,
+ public String httpRequest(URL requestUrl, String requestMethod, String outputStr, String username, String pass,
String contentType) {
var result = "";
var builder = new StringBuilder();
@@ -81,8 +81,7 @@ public class WebClient {
LOGGER.info("httpsRequest starts {} method {}", requestUrl, requestMethod);
disableCertificateValidation();
- var url = new URL(requestUrl);
- HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection();
+ var httpUrlConn = (HttpURLConnection) requestUrl.openConnection();
httpUrlConn.setDoOutput(true);
httpUrlConn.setDoInput(true);
diff --git a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
index a87bddaf0..612b42af6 100644
--- a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
+++ b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
@@ -26,17 +26,20 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
class WebClientTest {
- HttpsURLConnection mockedHttpsUrlConnection;
- String sampleString = "Response Code :200";
+ private HttpsURLConnection mockedHttpsUrlConnection;
+ private URL url;
+ private String sampleString = "Response Code :200";
/**
* Set up the mocked REST manager.
@@ -46,24 +49,27 @@ class WebClientTest {
@BeforeEach
void setupMockedRest() throws IOException {
mockedHttpsUrlConnection = mock(HttpsURLConnection.class);
+ url = mock(URL.class);
+ when(url.openConnection()).thenReturn(mockedHttpsUrlConnection);
InputStream inputStream = new ByteArrayInputStream(sampleString.getBytes());
+ OutputStream outputStream = new ByteArrayOutputStream();
when(mockedHttpsUrlConnection.getInputStream()).thenReturn(inputStream);
- Mockito.doNothing().when(mockedHttpsUrlConnection).connect();
+ when(mockedHttpsUrlConnection.getOutputStream()).thenReturn(outputStream);
}
@Test
- void testHttpsRequest() {
+ void testHttpsPostRequest() {
WebClient cl = new WebClient();
String result = cl
- .httpRequest("https://some.random.url/data", "POST", null, "admin", "admin", "application/json");
+ .httpRequest(url, "POST", null, "admin", "admin", "application/json");
assertNotNull(result);
}
@Test
- void testHttpRequest() {
+ void testHttpsGetRequest() {
WebClient cl = new WebClient();
String result = cl
- .httpRequest("http://some.random.url/data", "GET", null, "admin", "admin", "application/json");
+ .httpRequest(url, "GET", "sample output string", "admin", "admin", "application/json");
assertNotNull(result);
}
diff --git a/examples/examples-onap-vcpe/pom.xml b/examples/examples-onap-vcpe/pom.xml
index 10ee41d8f..390b9c0fb 100644
--- a/examples/examples-onap-vcpe/pom.xml
+++ b/examples/examples-onap-vcpe/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-onap-vcpe</artifactId>
diff --git a/examples/examples-periodic/pom.xml b/examples/examples-periodic/pom.xml
index 94bca49d1..374c0a7b8 100644
--- a/examples/examples-periodic/pom.xml
+++ b/examples/examples-periodic/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-periodic</artifactId>
diff --git a/examples/examples-servlet/pom.xml b/examples/examples-servlet/pom.xml
index 4b4f277bc..90bdd4bb8 100644
--- a/examples/examples-servlet/pom.xml
+++ b/examples/examples-servlet/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>examples-servlet</artifactId>
diff --git a/examples/pom.xml b/examples/pom.xml
index 77dbdf682..20e05ce8e 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
diff --git a/model/pom.xml b/model/pom.xml
index e6312da71..bdbb7f7d6 100644
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.model</groupId>
diff --git a/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java b/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
index 37fe30b33..dc1642bd5 100644
--- a/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
+++ b/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,18 +22,22 @@
package org.onap.policy.apex.model.basicmodel.concepts;
+import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import org.onap.policy.common.utils.validation.Assertions;
/**
* This class is the base class for all Apex concept classes. It enforces implementation of abstract methods and
- * interfaces on all concepts that are sub-classes of this class.
+ * interfaces on all concepts that are subclasses of this class.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
+
+ @Serial
private static final long serialVersionUID = -7434939557282697490L;
+ public static final String WHITESPACE_REGEX = "(\\s+$){1,4}";
/**
* Default constructor.
@@ -71,8 +75,7 @@ public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
* Validate that this concept is structurally correct.
*
* @param result the parameter in which the result of the validation will be returned
- * @return the validation result that was passed in in the @{link result} field with the result of this validation
- * added
+ * @return the validation result that was passed in the result field with the result of this validation added
*/
public abstract AxValidationResult validate(AxValidationResult result);
diff --git a/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
index bd3b18ec9..e158846eb 100644
--- a/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
+++ b/model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,9 +23,11 @@
package org.onap.policy.apex.model.basicmodel.concepts;
import com.google.gson.annotations.SerializedName;
+import java.io.Serial;
import java.util.List;
import java.util.Random;
import java.util.UUID;
+import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.common.utils.validation.Assertions;
@@ -38,6 +40,8 @@ import org.onap.policy.common.utils.validation.Assertions;
* blank and warns if the UUID is a zero UUID.
*/
public class AxKeyInfo extends AxConcept {
+
+ @Serial
private static final long serialVersionUID = -4023935924068914308L;
private static final int UUID_BYTE_LENGTH_16 = 16;
@@ -49,9 +53,11 @@ public class AxKeyInfo extends AxConcept {
private AxArtifactKey key;
+ @Getter
@SerializedName("UUID")
private UUID uuid;
+ @Getter
private String description;
/**
@@ -82,8 +88,8 @@ public class AxKeyInfo extends AxConcept {
/**
* Constructor to create this concept and set all its fields.
*
- * @param key the key of the concept
- * @param uuid the UUID of the concept
+ * @param key the key of the concept
+ * @param uuid the UUID of the concept
* @param description the description of the concept
*/
public AxKeyInfo(final AxArtifactKey key, final UUID uuid, final String description) {
@@ -124,15 +130,6 @@ public class AxKeyInfo extends AxConcept {
}
/**
- * Gets the UUID of the concept.
- *
- * @return the uuid of the concept
- */
- public UUID getUuid() {
- return uuid;
- }
-
- /**
* Sets the UUID of the concept.
*
* @param uuid the uuid of the concept
@@ -143,15 +140,6 @@ public class AxKeyInfo extends AxConcept {
}
/**
- * Gets the description of the concept.
- *
- * @return the description of the concept
- */
- public String getDescription() {
- return description;
- }
-
- /**
* Sets the description of the concept.
*
* @param description the description of the concept
@@ -170,19 +158,19 @@ public class AxKeyInfo extends AxConcept {
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
}
result = key.validate(result);
- if (description.trim().length() == 0) {
+ if (description.trim().isEmpty()) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
- "description is blank"));
+ "description is blank"));
}
if (uuid.equals(new UUID(0, 0))) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "UUID is a zero UUID: " + new UUID(0, 0)));
+ "UUID is a zero UUID: " + new UUID(0, 0)));
}
return result;
@@ -202,17 +190,8 @@ public class AxKeyInfo extends AxConcept {
*/
@Override
public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("artifactId=");
- builder.append(key);
- builder.append(",uuid=");
- builder.append(uuid);
- builder.append(",description=");
- builder.append(description);
- builder.append(")");
- return builder.toString();
+ return this.getClass().getSimpleName()
+ + ":(artifactId=" + key + ",uuid=" + uuid + ",description=" + description + ")";
}
/**
@@ -222,10 +201,9 @@ public class AxKeyInfo extends AxConcept {
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxKeyInfo.class);
+ Assertions.instanceOf(target, AxKeyInfo.class);
- final AxKeyInfo copy = ((AxKeyInfo) copyObject);
+ final AxKeyInfo copy = ((AxKeyInfo) target);
copy.setKey(new AxArtifactKey(key));
copy.setUuid(UUID.fromString(uuid.toString()));
copy.setDescription(description);
@@ -265,10 +243,7 @@ public class AxKeyInfo extends AxConcept {
if (!key.equals(other.key)) {
return false;
}
- if (!uuid.equals(other.uuid)) {
- return false;
- }
- return description.equals(description);
+ return uuid.equals(other.uuid);
}
/**
diff --git a/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
index db64f8847..b7925d43b 100644
--- a/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
+++ b/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,6 +22,7 @@
package org.onap.policy.apex.model.contextmodel.concepts;
+import java.io.Serial;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -64,6 +65,7 @@ import org.onap.policy.common.utils.validation.Assertions;
public class AxContextAlbum extends AxConcept {
private static final String SCOPE_STRING = "scope";
+ @Serial
private static final long serialVersionUID = 4290442590545820316L;
/**
@@ -71,7 +73,9 @@ public class AxContextAlbum extends AxConcept {
*/
public static final String SCOPE_REGEXP = "[A-Za-z0-9\\-_]+";
- /** The value of scope for a context album for which a scope has not been specified. */
+ /**
+ * The value of scope for a context album for which a scope has not been specified.
+ */
public static final String SCOPE_UNDEFINED = "UNDEFINED";
private AxArtifactKey key;
@@ -117,13 +121,13 @@ public class AxContextAlbum extends AxConcept {
/**
* Constructor that sets all the fields of the context album.
*
- * @param key the key of the context album
- * @param scope the scope field, must match the regular expression SCOPE_REGEXP
+ * @param key the key of the context album
+ * @param scope the scope field, must match the regular expression SCOPE_REGEXP
* @param isWritable specifies whether the context album will be writable or not
* @param itemSchema the artifact key of the context schema to use for this context album
*/
public AxContextAlbum(final AxArtifactKey key, final String scope, final boolean isWritable,
- final AxArtifactKey itemSchema) {
+ final AxArtifactKey itemSchema) {
super();
Assertions.argumentNotNull(key, "key may not be null");
Assertions.argumentNotNull(scope, "scope may not be null");
@@ -185,24 +189,24 @@ public class AxContextAlbum extends AxConcept {
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
+ "key is a null key"));
}
result = key.validate(result);
- if (scope.replaceAll("\\s+$", "").length() == 0 || scope.equals(SCOPE_UNDEFINED)) {
+ if (scope.replaceAll(WHITESPACE_REGEX, "").isEmpty() || scope.equals(SCOPE_UNDEFINED)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "scope is not defined"));
+ "scope is not defined"));
}
var stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP);
if (stringCheckResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "scope invalid-" + stringCheckResult));
+ "scope invalid-" + stringCheckResult));
}
if (itemSchema.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "itemSchema reference is a null key, an item schema must be specified"));
+ "itemSchema reference is a null key, an item schema must be specified"));
}
result = itemSchema.validate(result);
@@ -226,10 +230,9 @@ public class AxContextAlbum extends AxConcept {
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "targetObject may not be null");
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxContextAlbum.class);
+ Assertions.instanceOf(target, AxContextAlbum.class);
- final AxContextAlbum copy = ((AxContextAlbum) copyObject);
+ final AxContextAlbum copy = ((AxContextAlbum) target);
copy.setKey(new AxArtifactKey(key));
copy.setScope(scope);
copy.setWritable(isWritable);
diff --git a/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
index 61434ca67..09a6dd833 100644
--- a/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
+++ b/model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,6 +22,7 @@
package org.onap.policy.apex.model.contextmodel.concepts;
+import java.io.Serial;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
@@ -56,17 +57,23 @@ import org.onap.policy.common.utils.validation.Assertions;
@ToString
public class AxContextSchema extends AxConcept {
private static final String SCHEMA_FLAVOUR = "schemaFlavour";
- private static final String WHITESPACE_REGEXP = "\\s+$";
+ @Serial
private static final long serialVersionUID = -6443016863162692288L;
- /** Regular expression that constrains what values a schema flavour can have. */
+ /**
+ * Regular expression that constrains what values a schema flavour can have.
+ */
public static final String SCHEMA_FLAVOUR_REGEXP = "[A-Za-z0-9\\-_]+";
- /** An undefined schema flavour has this value. */
+ /**
+ * An undefined schema flavour has this value.
+ */
public static final String SCHEMA_FLAVOUR_UNDEFINED = "UNDEFINED";
- /** The maximum permissible size of a schema definition. */
+ /**
+ * The maximum permissible size of a schema definition.
+ */
public static final int MAX_SCHEMA_SIZE = 32672; // The maximum size supported by Apache Derby
private AxArtifactKey key;
@@ -106,8 +113,8 @@ public class AxContextSchema extends AxConcept {
/**
* This Constructor creates a context schema with all of its fields defined.
*
- * @param key the key
- * @param schemaFlavour the schema flavour
+ * @param key the key
+ * @param schemaFlavour the schema flavour
* @param schemaDefinition the schema definition
*/
public AxContextSchema(final AxArtifactKey key, final String schemaFlavour, final String schemaDefinition) {
@@ -118,7 +125,7 @@ public class AxContextSchema extends AxConcept {
this.key = key;
this.schemaFlavour = Assertions.validateStringParameter(SCHEMA_FLAVOUR, schemaFlavour, SCHEMA_FLAVOUR_REGEXP);
- this.schemaDefinition = schemaDefinition.replaceAll(WHITESPACE_REGEXP, "");
+ this.schemaDefinition = schemaDefinition.replaceAll(WHITESPACE_REGEX, "");
}
/**
@@ -164,7 +171,7 @@ public class AxContextSchema extends AxConcept {
*/
public void setSchema(final String schema) {
Assertions.argumentNotNull(schema, "schema may not be null");
- this.schemaDefinition = schema.replaceAll(WHITESPACE_REGEXP, "");
+ this.schemaDefinition = schema.replaceAll(WHITESPACE_REGEX, "");
}
/**
@@ -176,27 +183,27 @@ public class AxContextSchema extends AxConcept {
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
+ "key is a null key"));
}
result = key.validate(result);
- if (schemaFlavour.replaceAll(WHITESPACE_REGEXP, "").length() == 0
- || schemaFlavour.equals(SCHEMA_FLAVOUR_UNDEFINED)) {
+ if (schemaFlavour.replaceAll(WHITESPACE_REGEX, "").isEmpty()
+ || schemaFlavour.equals(SCHEMA_FLAVOUR_UNDEFINED)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "schema flavour is not defined"));
+ "schema flavour is not defined"));
}
var flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour,
- SCHEMA_FLAVOUR_REGEXP);
+ SCHEMA_FLAVOUR_REGEXP);
if (flavourValidationResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "schema flavour invalid-" + flavourValidationResult));
+ "schema flavour invalid-" + flavourValidationResult));
}
- if (schemaDefinition.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
+ if (schemaDefinition.replaceAll(WHITESPACE_REGEX, "").isEmpty()) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "no schemaDefinition specified, schemaDefinition may not be blank"));
+ "no schemaDefinition specified, schemaDefinition may not be blank"));
}
return result;
@@ -209,7 +216,7 @@ public class AxContextSchema extends AxConcept {
public void clean() {
key.clean();
schemaFlavour = Assertions.validateStringParameter(SCHEMA_FLAVOUR, schemaFlavour, SCHEMA_FLAVOUR_REGEXP);
- schemaDefinition = schemaDefinition.replaceAll(WHITESPACE_REGEXP, "");
+ schemaDefinition = schemaDefinition.replaceAll(WHITESPACE_REGEX, "");
}
/**
@@ -219,10 +226,9 @@ public class AxContextSchema extends AxConcept {
public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxContextSchema.class);
+ Assertions.instanceOf(target, AxContextSchema.class);
- final AxContextSchema copy = ((AxContextSchema) copyObject);
+ final AxContextSchema copy = ((AxContextSchema) target);
copy.setKey(new AxArtifactKey(key));
copy.setSchemaFlavour(schemaFlavour);
copy.setSchema(schemaDefinition);
diff --git a/model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java b/model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
index a4c0e9db1..652972d13 100644
--- a/model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
+++ b/model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,6 +24,7 @@ package org.onap.policy.apex.model.eventmodel.concepts;
import com.google.common.base.Strings;
import com.google.gson.annotations.SerializedName;
+import java.io.Serial;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -32,6 +33,8 @@ import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.lang3.EnumUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
@@ -65,21 +68,32 @@ import org.onap.policy.common.utils.validation.Assertions;
* checked to ensure it matches the event key.
*/
public class AxEvent extends AxConcept {
- private static final long serialVersionUID = -1460388382582984269L;
- private static final String WHITESPACE_REGEXP = "\\s+$";
+ @Serial
+ private static final long serialVersionUID = -1460388382582984269L;
- /** The key of the event, unique in the Apex system. */
+ /**
+ * The key of the event, unique in the Apex system.
+ */
// CHECKSTYLE:OFF: checkstyle:VisibilityMonitor
protected AxArtifactKey key;
// CHECKSTYLE:ON: checkstyle:VisibilityMonitor
+ @Getter
private String nameSpace;
+
+ @Getter
private String source;
+
+ @Getter
private String target;
+ @Getter
@SerializedName("parameter")
private Map<String, AxField> parameterMap;
+
+ @Setter
+ @Getter
private String toscaPolicyState;
/**
@@ -113,7 +127,7 @@ public class AxEvent extends AxConcept {
* This constructor creates an event with the given artifact key and name space. The event source, and target are
* all defined as empty strings and the parameter map is initialized as an empty map.
*
- * @param key the key of the event
+ * @param key the key of the event
* @param nameSpace the name space of the event
*/
public AxEvent(final AxArtifactKey key, final String nameSpace) {
@@ -124,10 +138,10 @@ public class AxEvent extends AxConcept {
* This constructor creates an event with the given artifact key, name space, source and target. The parameter map
* is initialized as an empty map.
*
- * @param key the key of the event
+ * @param key the key of the event
* @param nameSpace the name space of the event
- * @param source the source of the event
- * @param target the target of the event
+ * @param source the source of the event
+ * @param target the target of the event
*/
public AxEvent(final AxArtifactKey key, final String nameSpace, final String source, final String target) {
this(key, nameSpace, source, target, new TreeMap<>(), "");
@@ -136,15 +150,15 @@ public class AxEvent extends AxConcept {
/**
* This constructor creates an event with all its fields defined.
*
- * @param key the key of the event
- * @param nameSpace the name space of the event
- * @param source the source of the event
- * @param target the target of the event
- * @param parameterMap the map of parameters that the event has
+ * @param key the key of the event
+ * @param nameSpace the name space of the event
+ * @param source the source of the event
+ * @param target the target of the event
+ * @param parameterMap the map of parameters that the event has
* @param toscaPolicyState the TOSCA policy processing status that event is flagged with
*/
public AxEvent(final AxArtifactKey key, final String nameSpace, final String source, final String target,
- final SortedMap<String, AxField> parameterMap, final String toscaPolicyState) {
+ final SortedMap<String, AxField> parameterMap, final String toscaPolicyState) {
super();
Assertions.argumentNotNull(key, "key may not be null");
Assertions.argumentNotNull(nameSpace, "nameSpace may not be null");
@@ -216,15 +230,6 @@ public class AxEvent extends AxConcept {
}
/**
- * Gets the name space of the event.
- *
- * @return the name space of the event
- */
- public String getNameSpace() {
- return nameSpace;
- }
-
- /**
* Sets the name space of the event.
*
* @param nameSpace the name space of the event
@@ -235,15 +240,6 @@ public class AxEvent extends AxConcept {
}
/**
- * Gets the source of the event.
- *
- * @return the source of the event
- */
- public String getSource() {
- return source;
- }
-
- /**
* Sets the source of the event.
*
* @param source the source of the event
@@ -254,15 +250,6 @@ public class AxEvent extends AxConcept {
}
/**
- * Gets the target of the event.
- *
- * @return the target of the event
- */
- public String getTarget() {
- return target;
- }
-
- /**
* Sets the target of the event.
*
* @param target the target of the event
@@ -273,15 +260,6 @@ public class AxEvent extends AxConcept {
}
/**
- * Gets the event parameter map.
- *
- * @return the event parameter map
- */
- public Map<String, AxField> getParameterMap() {
- return parameterMap;
- }
-
- /**
* Gets the fields defined on the event as a set.
*
* @return the fields defined on the event as a set
@@ -301,24 +279,6 @@ public class AxEvent extends AxConcept {
}
/**
- * Gets the TOSCA policy processing status from the event.
- *
- * @return the TOSCA policy processing status
- */
- public String getToscaPolicyState() {
- return toscaPolicyState;
- }
-
- /**
- * Sets the TOSCA policy processing status on the event.
- *
- * @param toscaPolicyState the TOSCA policy processing status
- */
- public void setToscaPolicyState(String toscaPolicyState) {
- this.toscaPolicyState = toscaPolicyState;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -327,43 +287,43 @@ public class AxEvent extends AxConcept {
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
+ "key is a null key"));
}
result = key.validate(result);
- if (nameSpace.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
+ if (nameSpace.replaceAll(WHITESPACE_REGEX, "").isEmpty()) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "nameSpace on event is blank"));
+ "nameSpace on event is blank"));
}
- if (source.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
+ if (source.replaceAll(WHITESPACE_REGEX, "").isEmpty()) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
- "source on event is blank"));
+ "source on event is blank"));
}
- if (target.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
+ if (target.replaceAll(WHITESPACE_REGEX, "").isEmpty()) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
- "target on event is blank"));
+ "target on event is blank"));
}
for (final Entry<String, AxField> eventParameterEntry : parameterMap.entrySet()) {
if (eventParameterEntry.getKey() == null || eventParameterEntry.getKey().equals(AxKey.NULL_KEY_NAME)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on parameter " + eventParameterEntry.getKey() + " may not be the null key"));
+ "key on parameter " + eventParameterEntry.getKey() + " may not be the null key"));
} else if (eventParameterEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on parameter " + eventParameterEntry.getKey() + " may not be null"));
+ "value on parameter " + eventParameterEntry.getKey() + " may not be null"));
} else {
result = validateEventParameters(eventParameterEntry, result);
}
}
if (!Strings.isNullOrEmpty(toscaPolicyState)
- && !EnumUtils.isValidEnum(AxToscaPolicyProcessingStatus.class, toscaPolicyState)) {
+ && !EnumUtils.isValidEnum(AxToscaPolicyProcessingStatus.class, toscaPolicyState)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "toscaPolicyState on event is not a valid enum. Valid values are: "
- + Arrays.asList(AxToscaPolicyProcessingStatus.values())));
+ "toscaPolicyState on event is not a valid enum. Valid values are: "
+ + Arrays.asList(AxToscaPolicyProcessingStatus.values())));
}
return result;
@@ -373,22 +333,22 @@ public class AxEvent extends AxConcept {
* Validate an event parameter entry.
*
* @param eventParameterEntry the event parameter entry
- * @param result the validation result to append to
+ * @param result the validation result to append to
* @return The validation result
*/
private AxValidationResult validateEventParameters(final Entry<String, AxField> eventParameterEntry,
- final AxValidationResult result) {
+ final AxValidationResult result) {
if (!eventParameterEntry.getKey().equals(eventParameterEntry.getValue().getKey().getLocalName())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on parameter " + eventParameterEntry.getKey()
- + " does not equal parameter field local name "
- + eventParameterEntry.getValue().getKey().getLocalName()));
+ "key on parameter " + eventParameterEntry.getKey()
+ + " does not equal parameter field local name "
+ + eventParameterEntry.getValue().getKey().getLocalName()));
}
if (!eventParameterEntry.getValue().getKey().getParentArtifactKey().equals(key)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent key on parameter field " + eventParameterEntry.getValue().getKey()
- + " does not equal event key"));
+ "parent key on parameter field " + eventParameterEntry.getValue().getKey()
+ + " does not equal event key"));
}
return eventParameterEntry.getValue().validate(result);
@@ -410,23 +370,9 @@ public class AxEvent extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",nameSpace=");
- builder.append(nameSpace);
- builder.append(",source=");
- builder.append(source);
- builder.append(",target=");
- builder.append(target);
- builder.append(",parameter=");
- builder.append(parameterMap);
- builder.append(",toscaPolicyState=");
- builder.append(toscaPolicyState);
- builder.append(")");
- return builder.toString();
+ return this.getClass().getSimpleName()
+ + ":(" + "key=" + key + ",nameSpace=" + nameSpace + ",source=" + source + ",target=" + target
+ + ",parameter=" + parameterMap + ",toscaPolicyState=" + toscaPolicyState + ")";
}
/**
diff --git a/model/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java b/model/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
index 408f0913f..51778e54e 100644
--- a/model/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
+++ b/model/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -75,7 +75,7 @@ public class PolicyFacade {
/**
* Constructor that creates a policy facade for the Apex Model API.
*
- * @param apexModel the apex model
+ * @param apexModel the apex model
* @param apexProperties Properties for the model
*/
public PolicyFacade(final ApexModel apexModel, final Properties apexProperties) {
@@ -88,16 +88,16 @@ public class PolicyFacade {
/**
* Create a policy.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the default version
- * @param template template used to create the policy, set to null to use the default template
- * @param firstState the first state of the policy
- * @param uuid policy UUID, set to null to generate a UUID
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the default version
+ * @param template template used to create the policy, set to null to use the default template
+ * @param firstState the first state of the policy
+ * @param uuid policy UUID, set to null to generate a UUID
* @param description policy description, set to null to generate a description
* @return result of the operation
*/
public ApexApiResult createPolicy(final String name, final String version, final String template,
- final String firstState, final String uuid, final String description) {
+ final String firstState, final String uuid, final String description) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -135,16 +135,16 @@ public class PolicyFacade {
/**
* Update a policy.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param template template used to create the policy, set to null to not update
- * @param firstState the first state of the policy
- * @param uuid policy UUID, set to null to not update
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param template template used to create the policy, set to null to not update
+ * @param firstState the first state of the policy
+ * @param uuid policy UUID, set to null to not update
* @param description policy description, set to null to not update
* @return result of the operation
*/
public ApexApiResult updatePolicy(final String name, final String version, final String template,
- final String firstState, final String uuid, final String description) {
+ final String firstState, final String uuid, final String description) {
try {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
@@ -168,7 +168,7 @@ public class PolicyFacade {
/**
* List policies.
*
- * @param name name of the policy, set to null to list all
+ * @param name name of the policy, set to null to list all
* @param version starting version of the policy, set to null to list all versions
* @return result of the operation
*/
@@ -193,7 +193,7 @@ public class PolicyFacade {
/**
* Delete a policy.
*
- * @param name name of the policy
+ * @param name name of the policy
* @param version version of the policy, set to null to use the latest version
* @return result of the operation
*/
@@ -232,7 +232,7 @@ public class PolicyFacade {
/**
* Validate policies.
*
- * @param name name of the policy, set to null to list all
+ * @param name name of the policy, set to null to list all
* @param version starting version of the policy, set to null to list all versions
* @return result of the operation
*/
@@ -260,19 +260,20 @@ public class PolicyFacade {
/**
* Create a policy state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param triggerName name of the trigger event for this state
- * @param triggerVersion version of the trigger event for this state, set to null to use the
- * latest version
- * @param defaultTaskName the default task name
- * @param defaltTaskVersion the default task version, set to null to use the latest version
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param triggerName name of the trigger event for this state
+ * @param triggerVersion version of the trigger event for this state, set to null to use the
+ * latest version
+ * @param defaultTaskName the default task name
+ * @param defaultTaskVersion the default task version, set to null to use the latest version
* @return result of the operation
*/
public ApexApiResult createPolicyState(final String name, final String version, final String stateName,
- final String triggerName, final String triggerVersion, final String defaultTaskName,
- final String defaltTaskVersion) {
+ final String triggerName, final String triggerVersion,
+ final String defaultTaskName,
+ final String defaultTaskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -295,10 +296,10 @@ public class PolicyFacade {
CONCEPT + triggerName + ':' + triggerVersion + DOES_NOT_EXIST);
}
- final AxTask defaultTask = apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaltTaskVersion);
+ final AxTask defaultTask = apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaultTaskVersion);
if (defaultTask == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + defaultTaskName + ':' + defaltTaskVersion + DOES_NOT_EXIST);
+ CONCEPT + defaultTaskName + ':' + defaultTaskVersion + DOES_NOT_EXIST);
}
final AxState state = new AxState(refKey);
@@ -315,19 +316,20 @@ public class PolicyFacade {
/**
* Update a policy state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param triggerName name of the trigger event for this state, set to null to not update
- * @param triggerVersion version of the trigger event for this state, set to use latest version
- * of trigger event
- * @param defaultTaskName the default task name, set to null to not update
- * @param defaltTaskVersion the default task version, set to use latest version of default task
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param triggerName name of the trigger event for this state, set to null to not update
+ * @param triggerVersion version of the trigger event for this state, set to use latest version
+ * of trigger event
+ * @param defaultTaskName the default task name, set to null to not update
+ * @param defaultTaskVersion the default task version, set to use latest version of default task
* @return result of the operation
*/
public ApexApiResult updatePolicyState(final String name, final String version, final String stateName,
- final String triggerName, final String triggerVersion, final String defaultTaskName,
- final String defaltTaskVersion) {
+ final String triggerName, final String triggerVersion,
+ final String defaultTaskName,
+ final String defaultTaskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -354,10 +356,10 @@ public class PolicyFacade {
if (defaultTaskName != null) {
final AxTask defaultTask =
- apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaltTaskVersion);
+ apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaultTaskVersion);
if (defaultTask == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + defaultTaskName + ':' + defaltTaskVersion + DOES_NOT_EXIST);
+ CONCEPT + defaultTaskName + ':' + defaultTaskVersion + DOES_NOT_EXIST);
}
state.setDefaultTask(defaultTask.getKey());
}
@@ -371,8 +373,8 @@ public class PolicyFacade {
/**
* List policy states.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
* @param stateName of the state, set to null to list all states of the policy
* @return result of the operation
*/
@@ -412,8 +414,8 @@ public class PolicyFacade {
/**
* Delete a policy state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
* @param stateName of the state, set to null to delete all states
* @return result of the operation
*/
@@ -455,16 +457,17 @@ public class PolicyFacade {
/**
* Create task selection logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param logicFlavour the task selection logic flavour for the state, set to null to use the
- * default task logic flavour
- * @param logic the source code for the logic of the state
+ * default task logic flavour
+ * @param logic the source code for the logic of the state
* @return result of the operation
*/
public ApexApiResult createPolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName, final String logicFlavour, final String logic) {
+ final String stateName, final String logicFlavour,
+ final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -480,8 +483,7 @@ public class PolicyFacade {
CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
- // There is only one logic item associated with a state so we use a hard coded logic
- // name
+ // There is only one logic item associated with a state, so we use a hard coded logic name
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), "TaskSelectionLogic");
if (!state.getTaskSelectionLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
@@ -499,15 +501,16 @@ public class PolicyFacade {
/**
* Update task selection logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param logicFlavour the task selection logic flavour for the state, set to null to not update
- * @param logic the source code for the logic of the state, set to null to not update
+ * @param logic the source code for the logic of the state, set to null to not update
* @return result of the operation
*/
public ApexApiResult updatePolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName, final String logicFlavour, final String logic) {
+ final String stateName, final String logicFlavour,
+ final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -545,13 +548,13 @@ public class PolicyFacade {
/**
* List task selection logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
* @param stateName of the state
* @return result of the operation
*/
public ApexApiResult listPolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName) {
+ final String stateName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -578,13 +581,13 @@ public class PolicyFacade {
/**
* Delete task selection logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
* @param stateName of the state
* @return result of the operation
*/
public ApexApiResult deletePolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName) {
+ final String stateName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -618,19 +621,20 @@ public class PolicyFacade {
/**
* Create a policy state output.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param outputName of the state output
- * @param eventName name of the output event for this state output
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param outputName of the state output
+ * @param eventName name of the output event for this state output
* @param eventVersion version of the output event for this state output, set to null to use the
- * latest version
- * @param nextState for this state to transition to, set to null if this is the last state that
- * the policy transitions to on this branch
+ * latest version
+ * @param nextState for this state to transition to, set to null if this is the last state that
+ * the policy transitions to on this branch
* @return result of the operation
*/
public ApexApiResult createPolicyStateOutput(final String name, final String version, final String stateName,
- final String outputName, final String eventName, final String eventVersion, final String nextState) {
+ final String outputName, final String eventName,
+ final String eventVersion, final String nextState) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
Assertions.argumentNotNull(outputName, "outputName may not be null");
@@ -648,7 +652,7 @@ public class PolicyFacade {
}
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), outputName);
- // There can be multipe state outputs only when the current state is the final state
+ // There can be multiple state outputs only when the current state is the final state
if (nextState != null && !AxReferenceKey.getNullKey().getLocalName().equals(nextState)
&& state.getStateOutputs().containsKey(refKey.getLocalName())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
@@ -683,7 +687,7 @@ public class PolicyFacade {
}
private void populateStateOuputInfo(final String nextState, final AxState state, final AxReferenceKey refKey,
- final AxEvent event, AxReferenceKey nextStateKey) {
+ final AxEvent event, AxReferenceKey nextStateKey) {
// nextState is null. There could be multiple events coming out of the state
if ((nextState == null || AxReferenceKey.getNullKey().getLocalName().equals(nextState))
&& state.getStateOutputs().containsKey(refKey.getLocalName())) {
@@ -707,14 +711,14 @@ public class PolicyFacade {
/**
* List policy state outputs.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param outputName of the state output, set to null to list all outputs of the state
* @return result of the operation
*/
public ApexApiResult listPolicyStateOutput(final String name, final String version, final String stateName,
- final String outputName) {
+ final String outputName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -740,7 +744,7 @@ public class PolicyFacade {
CONCEPT + state.getKey().getId() + ':' + outputName + DOES_NOT_EXIST);
}
} else {
- if (state.getStateOutputs().size() == 0) {
+ if (state.getStateOutputs().isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
"no state output concepts exist for state " + state.getKey().getId());
}
@@ -761,14 +765,14 @@ public class PolicyFacade {
/**
* Delete a policy state output.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param outputName of the state output, set to null to delete all state outputs
* @return result of the operation
*/
public ApexApiResult deletePolicyStateOutput(final String name, final String version, final String stateName,
- final String outputName) {
+ final String outputName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -796,7 +800,7 @@ public class PolicyFacade {
CONCEPT + state.getKey().getId() + ':' + outputName + DOES_NOT_EXIST);
}
} else {
- if (state.getStateOutputs().size() == 0) {
+ if (state.getStateOutputs().isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
"no state output concepts exist for state " + state.getKey().getId());
}
@@ -818,17 +822,18 @@ public class PolicyFacade {
/**
* Create policy finalizer logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param finalizerLogicName name of the state finalizer logic
- * @param logicFlavour the policy finalizer logic flavour for the state, set to null to use the
- * default task logic flavour
- * @param logic the source code for the logic of the state
+ * @param logicFlavour the policy finalizer logic flavour for the state, set to null to use the
+ * default task logic flavour
+ * @param logic the source code for the logic of the state
* @return result of the operation
*/
public ApexApiResult createPolicyStateFinalizerLogic(final String name, final String version,
- final String stateName, final String finalizerLogicName, final String logicFlavour, final String logic) {
+ final String stateName, final String finalizerLogicName,
+ final String logicFlavour, final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
Assertions.argumentNotNull(finalizerLogicName, "finalizerlogicName may not be null");
@@ -863,17 +868,18 @@ public class PolicyFacade {
/**
* Update policy finalizer logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param finalizerLogicName name of the state finalizer logic
- * @param logicFlavour the policy finalizer logic flavour for the state, set to null to not
- * update
- * @param logic the source code for the logic of the state, set to null to not update
+ * @param logicFlavour the policy finalizer logic flavour for the state, set to null to not
+ * update
+ * @param logic the source code for the logic of the state, set to null to not update
* @return result of the operation
*/
public ApexApiResult updatePolicyStateFinalizerLogic(final String name, final String version,
- final String stateName, final String finalizerLogicName, final String logicFlavour, final String logic) {
+ final String stateName, final String finalizerLogicName,
+ final String logicFlavour, final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
Assertions.argumentNotNull(finalizerLogicName, "finalizerLogicName may not be null");
@@ -914,14 +920,14 @@ public class PolicyFacade {
/**
* List policy finalizer logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param finalizerLogicName name of the state finalizer logic
* @return result of the operation
*/
public ApexApiResult listPolicyStateFinalizerLogic(final String name, final String version, final String stateName,
- final String finalizerLogicName) {
+ final String finalizerLogicName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -950,7 +956,7 @@ public class PolicyFacade {
new ApexModelStringWriter<AxStateFinalizerLogic>(false).writeString(stateFinalizerLogic,
AxStateFinalizerLogic.class));
} else {
- if (state.getStateFinalizerLogicMap().size() == 0) {
+ if (state.getStateFinalizerLogicMap().isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
"no state finalizer logic defined on state " + state.getKey().getId());
}
@@ -969,14 +975,14 @@ public class PolicyFacade {
/**
* Delete policy finalizer logic for a state.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
* @param finalizerLogicName name of the state finalizer logic
* @return result of the operation
*/
public ApexApiResult deletePolicyStateFinalizerLogic(final String name, final String version,
- final String stateName, final String finalizerLogicName) {
+ final String stateName, final String finalizerLogicName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -1007,17 +1013,18 @@ public class PolicyFacade {
state.getStateFinalizerLogicMap().remove(refKey.getLocalName());
return result;
} else {
- if (state.getStateFinalizerLogicMap().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no state finalizer logic defined on state " + state.getKey().getId());
- }
+ ApexApiResult result = new ApexApiResult();
- final ApexApiResult result = new ApexApiResult();
- for (final AxStateFinalizerLogic stateFinalizerLogic : state.getStateFinalizerLogicMap().values()) {
- result.addMessage(new ApexModelStringWriter<AxStateFinalizerLogic>(false)
- .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class));
+ if (state.getStateFinalizerLogicMap().isEmpty()) {
+ result = new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ "no state finalizer logic defined on state " + state.getKey().getId());
+ } else {
+ for (final AxStateFinalizerLogic stateFinalizerLogic : state.getStateFinalizerLogicMap().values()) {
+ result.addMessage(new ApexModelStringWriter<AxStateFinalizerLogic>(false)
+ .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class));
+ }
+ state.getStateFinalizerLogicMap().clear();
}
- state.getStateFinalizerLogicMap().clear();
return result;
}
} catch (final Exception e) {
@@ -1124,15 +1131,15 @@ public class PolicyFacade {
/**
* List policy state task references.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param taskName name of the task, set to null to list all task references
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param taskName name of the task, set to null to list all task references
* @param taskVersion version of the task, set to null to use the latest version
* @return result of the operation
*/
public ApexApiResult listPolicyStateTaskRef(final String name, final String version, final String stateName,
- final String taskName, final String taskVersion) {
+ final String taskName, final String taskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -1179,15 +1186,15 @@ public class PolicyFacade {
/**
* Delete a policy state task reference.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param taskName name of the task, set to null to delete all task references
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param taskName name of the task, set to null to delete all task references
* @param taskVersion version of the task, set to null to use the latest version
* @return result of the operation
*/
public ApexApiResult deletePolicyStateTaskRef(final String name, final String version, final String stateName,
- final String taskName, final String taskVersion) {
+ final String taskName, final String taskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -1232,16 +1239,16 @@ public class PolicyFacade {
/**
* Create a policy state context album reference.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param contextAlbumName name of the context album for the context album reference
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param contextAlbumName name of the context album for the context album reference
* @param contextAlbumVersion version of the context album for the context album reference, set
- * to null to use the latest version
+ * to null to use the latest version
* @return result of the operation
*/
public ApexApiResult createPolicyStateContextRef(final String name, final String version, final String stateName,
- final String contextAlbumName, final String contextAlbumVersion) {
+ final String contextAlbumName, final String contextAlbumVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -1279,17 +1286,17 @@ public class PolicyFacade {
/**
* List policy state context album references.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the latest version
- * @param stateName of the state
- * @param contextAlbumName name of the context album for the context album reference, set to
- * null to list all task context album references
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the latest version
+ * @param stateName of the state
+ * @param contextAlbumName name of the context album for the context album reference, set to
+ * null to list all task context album references
* @param contextAlbumVersion version of the context album for the context album reference, set
- * to null to use the latest version
+ * to null to use the latest version
* @return result of the operation
*/
public ApexApiResult listPolicyStateContextRef(final String name, final String version, final String stateName,
- final String contextAlbumName, final String contextAlbumVersion) {
+ final String contextAlbumName, final String contextAlbumVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
@@ -1329,17 +1336,17 @@ public class PolicyFacade {
/**
* Delete a policy state context album reference.
*
- * @param name name of the policy
- * @param version version of the policy, set to null to use the default version
- * @param stateName of the state
- * @param contextAlbumName name of the context album for the context album reference, set to
- * null to delete all task context album references
+ * @param name name of the policy
+ * @param version version of the policy, set to null to use the default version
+ * @param stateName of the state
+ * @param contextAlbumName name of the context album for the context album reference, set to
+ * null to delete all task context album references
* @param contextAlbumVersion version of the context album for the context album reference, set
- * to null to use the latest version
+ * to null to use the latest version
* @return result of the operation
*/
public ApexApiResult deletePolicyStateContextRef(final String name, final String version, final String stateName,
- final String contextAlbumName, final String contextAlbumVersion) {
+ final String contextAlbumName, final String contextAlbumVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
diff --git a/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
index 0564d5854..50d6771b5 100644
--- a/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
+++ b/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,9 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import java.io.Serial;
import java.util.List;
+import lombok.Getter;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -43,26 +45,31 @@ import org.onap.policy.common.utils.validation.Assertions;
* the {@code LOGIC_FLAVOUR_REGEXP} regular expression, and that the specified logic string is not null or blank.
*/
public class AxLogic extends AxConcept {
- private static final long serialVersionUID = -4260562004005697328L;
- private static final String WHITESPACE_REGEXP = "\\s+$";
+ @Serial
+ private static final long serialVersionUID = -4260562004005697328L;
private static final String LOGIC_FLAVOUR_TOKEN = "logicFlavour";
private static final String KEY_NULL_MESSAGE = "key may not be null";
private static final String LOGIC_FLAVOUR_NULL_MESSAGE = "logicFlavour may not be null";
private static final String LOGIC_NULL_MESSAGE = "logic may not be null";
- /** Regular expression that specifies the allowed characters in logic flavour tokens. */
+ /**
+ * Regular expression that specifies the allowed characters in logic flavour tokens.
+ */
public static final String LOGIC_FLAVOUR_REGEXP = "[A-Za-z0-9\\-_]+";
- /** When logic flavour is undefined, it has this value. */
+ /**
+ * When logic flavour is undefined, it has this value.
+ */
public static final String LOGIC_FLAVOUR_UNDEFINED = "UNDEFINED";
- /** The maximum permissible size of a logic definition. */
- public static final int MAX_LOGIC_SIZE = 32672; // The maximum size supported by Apache Derby
-
private AxReferenceKey key;
+
+ @Getter
private String logicFlavour;
+
+ @Getter
private String logic;
/**
@@ -97,22 +104,22 @@ public class AxLogic extends AxConcept {
* This Constructor creates a logic instance with a reference key constructed from the parents key and the logic
* local name and all of its fields defined.
*
- * @param parentKey the reference key of the parent of this logic
- * @param logicName the logic name, held as the local name of the reference key of this logic
+ * @param parentKey the reference key of the parent of this logic
+ * @param logicName the logic name, held as the local name of the reference key of this logic
* @param logicFlavour the flavour of this logic
- * @param logic the actual logic as a string
+ * @param logic the actual logic as a string
*/
public AxLogic(final AxReferenceKey parentKey, final String logicName, final String logicFlavour,
- final String logic) {
+ final String logic) {
this(new AxReferenceKey(parentKey, logicName), logicFlavour, logic);
}
/**
* This Constructor creates a logic instance with the given reference key and all of its fields defined.
*
- * @param key the reference key of this logic
+ * @param key the reference key of this logic
* @param logicFlavour the flavour of this logic
- * @param logic the actual logic as a string
+ * @param logic the actual logic as a string
*/
public AxLogic(final AxReferenceKey key, final String logicFlavour, final String logic) {
super();
@@ -122,16 +129,16 @@ public class AxLogic extends AxConcept {
this.key = key;
this.logicFlavour = Assertions.validateStringParameter(LOGIC_FLAVOUR_TOKEN, logicFlavour, LOGIC_FLAVOUR_REGEXP);
- this.logic = logic.replaceAll(WHITESPACE_REGEXP, "");
+ this.logic = logic.replaceAll(WHITESPACE_REGEX, "");
}
/**
* This Constructor creates a logic instance with the given reference key and logic flavour, the logic is provided
* by the given logic reader instance.
*
- * @param key the reference key of this logic
+ * @param key the reference key of this logic
* @param logicFlavour the flavour of this logic
- * @param logicReader the logic reader to use to read the logic for this logic instance
+ * @param logicReader the logic reader to use to read the logic for this logic instance
*/
public AxLogic(final AxReferenceKey key, final String logicFlavour, final AxLogicReader logicReader) {
super();
@@ -171,15 +178,6 @@ public class AxLogic extends AxConcept {
}
/**
- * Gets the logic flavour.
- *
- * @return the logic flavour
- */
- public String getLogicFlavour() {
- return logicFlavour;
- }
-
- /**
* Sets the logic flavour.
*
* @param logicFlavour the logic flavour
@@ -189,22 +187,13 @@ public class AxLogic extends AxConcept {
}
/**
- * Gets the logic.
- *
- * @return the logic
- */
- public String getLogic() {
- return logic;
- }
-
- /**
* Sets the logic.
*
* @param logic the logic
*/
public void setLogic(final String logic) {
Assertions.argumentNotNull(logic, LOGIC_NULL_MESSAGE);
- this.logic = logic.replaceAll(WHITESPACE_REGEXP, "");
+ this.logic = logic.replaceAll(WHITESPACE_REGEX, "");
}
/**
@@ -216,27 +205,27 @@ public class AxLogic extends AxConcept {
if (key.equals(AxReferenceKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
+ "key is a null key"));
}
result = key.validate(result);
- if (logicFlavour.replaceAll(WHITESPACE_REGEXP, "").length() == 0
- || logicFlavour.equals(LOGIC_FLAVOUR_UNDEFINED)) {
+ if (logicFlavour.replaceAll(WHITESPACE_REGEX, "").isEmpty()
+ || logicFlavour.equals(LOGIC_FLAVOUR_UNDEFINED)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "logic flavour is not defined"));
+ "logic flavour is not defined"));
}
String flavourValidationString = Assertions.getStringParameterValidationMessage(LOGIC_FLAVOUR_TOKEN,
- logicFlavour, LOGIC_FLAVOUR_REGEXP);
+ logicFlavour, LOGIC_FLAVOUR_REGEXP);
if (flavourValidationString != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "logic flavour invalid-" + flavourValidationString));
+ "logic flavour invalid-" + flavourValidationString));
}
- if (logic.replaceAll(WHITESPACE_REGEXP, "").length() == 0) {
+ if (logic.replaceAll(WHITESPACE_REGEX, "").isEmpty()) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "no logic specified, logic may not be blank"));
+ "no logic specified, logic may not be blank"));
}
return result;
@@ -251,7 +240,7 @@ public class AxLogic extends AxConcept {
key.clean();
}
logicFlavour = Assertions.validateStringParameter(LOGIC_FLAVOUR_TOKEN, logicFlavour, LOGIC_FLAVOUR_REGEXP);
- logic = logic.replaceAll(WHITESPACE_REGEXP, "");
+ logic = logic.replaceAll(WHITESPACE_REGEX, "");
}
/**
@@ -259,17 +248,8 @@ public class AxLogic extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",logicFlavour=");
- builder.append(logicFlavour);
- builder.append(",logic=");
- builder.append(logic);
- builder.append(")");
- return builder.toString();
+ return this.getClass().getSimpleName()
+ + ":(" + "key=" + key + ",logicFlavour=" + logicFlavour + ",logic=" + logic + ")";
}
/**
@@ -279,10 +259,9 @@ public class AxLogic extends AxConcept {
public AxConcept copyTo(final AxConcept targetObject) {
Assertions.argumentNotNull(targetObject, "target may not be null");
- final Object copyObject = targetObject;
- Assertions.instanceOf(copyObject, AxLogic.class);
+ Assertions.instanceOf(targetObject, AxLogic.class);
- final AxLogic copy = ((AxLogic) copyObject);
+ final AxLogic copy = ((AxLogic) targetObject);
copy.setKey(new AxReferenceKey(key));
copy.setLogicFlavour(logicFlavour);
copy.setLogic(logic);
diff --git a/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java b/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
index e119536fb..049757599 100644
--- a/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
+++ b/model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -23,8 +23,10 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import java.io.Serial;
import java.util.List;
import java.util.Map.Entry;
+import lombok.Getter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -88,17 +90,19 @@ import org.onap.policy.common.utils.validation.Assertions;
* <li>All events referred to on direct state outputs must exist
* </ol>
*/
+@Getter
public class AxPolicyModel extends AxModel {
- // @formatter:off
- private static final String SCHEMAS_TOKEN = "_Schemas";
- private static final String KEY_INFO_TOKEN = "_KeyInfo";
- private static final String EVENTS_TOKEN = "_Events";
- private static final String ALBUMS_TOKEN = "_Albums";
- private static final String TASKS_TOKEN = "_Tasks";
+
+ private static final String SCHEMAS_TOKEN = "_Schemas";
+ private static final String KEY_INFO_TOKEN = "_KeyInfo";
+ private static final String EVENTS_TOKEN = "_Events";
+ private static final String ALBUMS_TOKEN = "_Albums";
+ private static final String TASKS_TOKEN = "_Tasks";
private static final String POLICIESS_TOKEN = "_Policies";
private static final String DOES_NOT_EXIST = " does not exist";
+ @Serial
private static final long serialVersionUID = 8800599637708309945L;
private AxPolicies policies;
@@ -136,23 +140,24 @@ public class AxPolicyModel extends AxModel {
new AxKeyInformation(new AxArtifactKey(key.getName() + KEY_INFO_TOKEN, key.getVersion())),
new AxEvents(new AxArtifactKey(key.getName() + EVENTS_TOKEN, key.getVersion())),
new AxContextAlbums(new AxArtifactKey(key.getName() + ALBUMS_TOKEN, key.getVersion())),
- new AxTasks(new AxArtifactKey(key.getName() + TASKS_TOKEN, key.getVersion())),
+ new AxTasks(new AxArtifactKey(key.getName() + TASKS_TOKEN, key.getVersion())),
new AxPolicies(new AxArtifactKey(key.getName() + POLICIESS_TOKEN, key.getVersion())));
}
/**
* This Constructor creates a policy model with all of its fields specified.
*
- * @param key the key of the policy model
- * @param schemas the context schema container for the policy model
+ * @param key the key of the policy model
+ * @param schemas the context schema container for the policy model
* @param keyInformation the key information container for the policy model
- * @param events the event container for the policy model
- * @param albums the context album container for the policy model
- * @param tasks the task container for the policy model
- * @param policies the policy container for the policy model
- */
- public AxPolicyModel(final AxArtifactKey key, final AxContextSchemas schemas, final AxKeyInformation keyInformation,
- final AxEvents events, final AxContextAlbums albums, final AxTasks tasks, final AxPolicies policies) {
+ * @param events the event container for the policy model
+ * @param albums the context album container for the policy model
+ * @param tasks the task container for the policy model
+ * @param policies the policy container for the policy model
+ */
+ public AxPolicyModel(final AxArtifactKey key, final AxContextSchemas schemas,
+ final AxKeyInformation keyInformation, final AxEvents events, final AxContextAlbums albums,
+ final AxTasks tasks, final AxPolicies policies) {
super(key, keyInformation);
Assertions.argumentNotNull(schemas, "schemas may not be null");
Assertions.argumentNotNull(events, "events may not be null");
@@ -203,17 +208,8 @@ public class AxPolicyModel extends AxModel {
* @return the context model
*/
public AxContextModel getContextModel() {
- return new AxContextModel(new AxArtifactKey(albums.getKey().getName() + "_Model", albums.getKey().getVersion()),
- getSchemas(), getAlbums(), getKeyInformation());
- }
-
- /**
- * Gets the policy container from the policy model.
- *
- * @return the policy container with all the policies in the model
- */
- public AxPolicies getPolicies() {
- return policies;
+ return new AxContextModel(new AxArtifactKey(albums.getKey().getName() + "_Model",
+ albums.getKey().getVersion()), getSchemas(), getAlbums(), getKeyInformation());
}
/**
@@ -227,15 +223,6 @@ public class AxPolicyModel extends AxModel {
}
/**
- * Gets the task container from the policy model.
- *
- * @return the task container with all the tasks in the model
- */
- public AxTasks getTasks() {
- return tasks;
- }
-
- /**
* Sets the task container from the policy model.
*
* @param tasks the task container with all the tasks in the model
@@ -246,15 +233,6 @@ public class AxPolicyModel extends AxModel {
}
/**
- * Gets the event container from the policy model.
- *
- * @return the event container with all the events in the model
- */
- public AxEvents getEvents() {
- return events;
- }
-
- /**
* Sets the event container from the policy model.
*
* @param events the event container with all the events in the model
@@ -265,15 +243,6 @@ public class AxPolicyModel extends AxModel {
}
/**
- * Gets the context album container from the policy model.
- *
- * @return the context album container with all the context albums in the model
- */
- public AxContextAlbums getAlbums() {
- return albums;
- }
-
- /**
* Sets the context album container from the policy model.
*
* @param albums the context album container with all the context albums in the model
@@ -284,15 +253,6 @@ public class AxPolicyModel extends AxModel {
}
/**
- * Gets the context schema container from the policy model.
- *
- * @return the context schema container with all the context schemas in the model
- */
- public AxContextSchemas getSchemas() {
- return schemas;
- }
-
- /**
* Sets the context schema container from the policy model.
*
* @param schemas the context schema container with all the context schemas in the model
@@ -376,7 +336,7 @@ public class AxPolicyModel extends AxModel {
/**
* Validate all fundamental concepts keyed in tasks exist.
*
- * @param task The task to validate the keys of
+ * @param task The task to validate the keys of
* @param result the validation result to return
* @return the result
*/
@@ -409,7 +369,7 @@ public class AxPolicyModel extends AxModel {
/**
* Validate that the references used on a state are valid.
*
- * @param state The state to check
+ * @param state The state to check
* @param result the validation result to append to
*/
private void validateStateReferences(AxState state, AxValidationResult result) {
@@ -436,7 +396,7 @@ public class AxPolicyModel extends AxModel {
if (events.getEventMap().get(stateOutput.getOutgoingEvent()) == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
- + " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
+ + " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
}
@@ -447,7 +407,7 @@ public class AxPolicyModel extends AxModel {
* Validate that the fields on tasks and events that trigger them and are output by them are
* compatible for all tasks used on a state.
*
- * @param state The state to check
+ * @param state The state to check
* @param result the validation result to append to
*/
private void validateEventTaskFieldCompatibilityOnState(AxState state, AxValidationResult result) {
@@ -474,13 +434,14 @@ public class AxPolicyModel extends AxModel {
* Validate that the fields on a task of a state output and the events that trigger it are
* compatible.
*
- * @param state The state to check
- * @param task The task to check
+ * @param state The state to check
+ * @param task The task to check
* @param stateOutput The state output to check
- * @param result the validation result to append to
+ * @param result the validation result to append to
*/
private void validateEventTaskFieldCompatibilityOnStateOutput(final AxState state, final AxTask task,
- final AxStateOutput stateOutput, AxValidationResult result) {
+ final AxStateOutput stateOutput,
+ AxValidationResult result) {
if (stateOutput == null) {
result.addValidationMessage(new AxValidationMessage(state.getKey(), this.getClass(),
ValidationResult.INVALID, "state output on task reference for task " + task.getId() + " is null"));
@@ -490,7 +451,7 @@ public class AxPolicyModel extends AxModel {
if (usedEvent == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
- + " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
+ + " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
}
}
@@ -509,10 +470,10 @@ public class AxPolicyModel extends AxModel {
getPolicies().buildReferences();
getKeyInformation().buildReferences();
- AxArtifactKey nullAlbumskey = new AxArtifactKey(AxKey.NULL_KEY_NAME + ALBUMS_TOKEN, AxKey.NULL_KEY_VERSION);
+ AxArtifactKey nullAlbumsKey = new AxArtifactKey(AxKey.NULL_KEY_NAME + ALBUMS_TOKEN, AxKey.NULL_KEY_VERSION);
if (AxArtifactKey.getNullKey().equals(getAlbums().getKey())
- || nullAlbumskey.equals(getAlbums().getKey())) {
+ || nullAlbumsKey.equals(getAlbums().getKey())) {
getAlbums().setKey(new AxArtifactKey(getKey().getName() + ALBUMS_TOKEN, getKey().getVersion()));
getKeyInformation().generateKeyInfo(getAlbums());
}
@@ -536,22 +497,9 @@ public class AxPolicyModel extends AxModel {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append(super.toString());
- builder.append(",policies=");
- builder.append(policies);
- builder.append(",tasks=");
- builder.append(tasks);
- builder.append(",events=");
- builder.append(events);
- builder.append(",albums=");
- builder.append(albums);
- builder.append(",schemas=");
- builder.append(schemas);
- builder.append(")");
- return builder.toString();
+ return this.getClass().getSimpleName()
+ + ":(" + super.toString() + ",policies=" + policies + ",tasks=" + tasks + ",events=" + events + ",albums="
+ + albums + ",schemas=" + schemas + ")";
}
/**
@@ -561,10 +509,9 @@ public class AxPolicyModel extends AxModel {
public AxConcept copyTo(final AxConcept targetObject) {
Assertions.argumentNotNull(targetObject, "target may not be null");
- final Object copyObject = targetObject;
- Assertions.instanceOf(copyObject, AxPolicyModel.class);
+ Assertions.instanceOf(targetObject, AxPolicyModel.class);
- final AxPolicyModel copy = ((AxPolicyModel) copyObject);
+ final AxPolicyModel copy = ((AxPolicyModel) targetObject);
super.copyTo(targetObject);
copy.setPolicies(new AxPolicies(policies));
copy.setTasks(new AxTasks(tasks));
diff --git a/model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReader.java b/model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReader.java
index f70068454..4a8780a4f 100644
--- a/model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReader.java
+++ b/model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReader.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
package org.onap.policy.apex.model.policymodel.handling;
+import static org.onap.policy.apex.model.basicmodel.concepts.AxConcept.WHITESPACE_REGEX;
+
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.policymodel.concepts.AxLogic;
import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader;
@@ -96,19 +98,35 @@ public class PolicyLogicReader implements AxLogicReader {
// Return the java class name for the logic
if (axLogic.getKey().getParentLocalName().equals(AxKey.NULL_KEY_NAME)) {
return logicPackage + DOT_JAVA + axLogic.getKey().getParentKeyName()
- + axLogic.getKey().getLocalName();
+ + axLogic.getKey().getLocalName();
} else {
return logicPackage + DOT_JAVA + axLogic.getKey().getParentKeyName()
- + axLogic.getKey().getParentLocalName() + axLogic.getKey().getLocalName();
+ + axLogic.getKey().getParentLocalName() + axLogic.getKey().getLocalName();
}
}
}
// Now, we read in the script
// Get the package name of the current package and convert dots to slashes for the file path
+ String fullLogicFilePath = getFullLogicFilePath(axLogic);
+
+ final String logicString = ResourceUtils.getResourceAsString(fullLogicFilePath);
+
+ // Check if the logic was found
+ if (logicString == null || logicString.isEmpty()) {
+ String errorMessage = "logic not found for logic \"" + fullLogicFilePath + "\"";
+ LOGGER.warn(errorMessage);
+ throw new PolicyRuntimeException(errorMessage);
+ }
+
+ // Return the right trimmed logic string
+ return logicString.replaceAll(WHITESPACE_REGEX, "");
+ }
+
+ private String getFullLogicFilePath(AxLogic axLogic) {
String fullLogicFilePath = logicPackage.replace(".", "/");
- // Now, the logic should be in a sub directory for the logic executor type
+ // Now, the logic should be in a subdirectory for the logic executor type
fullLogicFilePath += "/" + axLogic.getLogicFlavour().toLowerCase();
// Check if we're using the default logic
@@ -120,23 +138,12 @@ public class PolicyLogicReader implements AxLogicReader {
fullLogicFilePath += "/" + axLogic.getKey().getParentKeyName() + axLogic.getKey().getLocalName();
} else {
fullLogicFilePath += "/" + axLogic.getKey().getParentKeyName()
- + axLogic.getKey().getParentLocalName() + axLogic.getKey().getLocalName();
+ + axLogic.getKey().getParentLocalName() + axLogic.getKey().getLocalName();
}
}
// Now get the type of executor to find the extension of the file
fullLogicFilePath += "." + axLogic.getLogicFlavour().toLowerCase();
-
- final String logicString = ResourceUtils.getResourceAsString(fullLogicFilePath);
-
- // Check if the logic was found
- if (logicString == null || logicString.length() == 0) {
- String errorMessage = "logic not found for logic \"" + fullLogicFilePath + "\"";
- LOGGER.warn(errorMessage);
- throw new PolicyRuntimeException(errorMessage);
- }
-
- // Return the right trimmed logic string
- return logicString.replaceAll("\\s+$", "");
+ return fullLogicFilePath;
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
index 8c1f756c1..b5028273c 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
@@ -54,7 +54,7 @@ class SupportApexBasicModelTest {
@Test
void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- var expectedResult = ResourceUtils.getResourceAsString(VALID_MODEL_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(VALID_MODEL_STRING));
assertEquals(expectedResult, result.toString());
}
@@ -67,21 +67,21 @@ class SupportApexBasicModelTest {
@Test
void testApexModelValidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateWarning();
- var expectedResult = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING));
assertEquals(expectedResult, result.toString());
}
@Test
void testModelValidateInvalidModel() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
- var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING));
assertEquals(expectedResult, result.toString());
}
@Test
void testModelValidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
- var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING));
assertEquals(expectedResult, result.toString());
}
@@ -89,4 +89,8 @@ class SupportApexBasicModelTest {
void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
+
+ private String normalizeNewlines(String input) {
+ return input.replace("\r\n", "\n");
+ }
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
index a9cb16914..31083d4c4 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
@@ -68,28 +68,28 @@ class ApexContextModelTest {
@Test
void testApexModelValidateObservation() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateObservation();
- var expectedResult = ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING));
assertEquals(expectedResult, result.toString());
}
@Test
void testApexModelValidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateWarning();
- var expectedResult = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING));
assertEquals(expectedResult, result.toString());
}
@Test
void testModelValidateInvalidModel() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
- var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING));
assertEquals(expectedResult, result.toString());
}
@Test
void testModelValidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
- var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING);
+ var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING));
assertEquals(expectedResult, result.toString());
}
@@ -97,4 +97,8 @@ class ApexContextModelTest {
void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
+
+ private String normalizeNewlines(String input) {
+ return input.replace("\r\n", "\n");
+ }
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
index df1857c82..bb50fb35e 100644
--- a/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
@@ -64,28 +64,28 @@ class ApexEventModelTest {
@Test
void testApexModelValidateObservation() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateObservation();
- String expected = ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING);
+ var expected = normalizeNewlines(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING));
assertEquals(expected, result.toString());
}
@Test
void testApexModelValidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateWarning();
- String expected = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING);
+ var expected = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING));
assertEquals(expected, result.toString());
}
@Test
void testModelValidateInvalidModel() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
- String expected = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING);
+ var expected = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING));
assertEquals(expected, result.toString());
}
@Test
void testModelValidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
- String expected = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING);
+ var expected = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING));
assertEquals(expected, result.toString());
}
@@ -93,4 +93,8 @@ class ApexEventModelTest {
void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
+
+ private String normalizeNewlines(String input) {
+ return input.replace("\r\n", "\n");
+ }
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index 01f7062e1..c943befd5 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -61,29 +61,37 @@ class ApexPolicyModelTest {
@Test
void testApexModelValidateObservation() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateObservation();
- assertEquals(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING), result.toString());
+ var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING));
+ assertEquals(expectedOutput, result.toString());
}
@Test
void testApexModelValidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateWarning();
- assertEquals(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING), result.toString());
+ var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING));
+ assertEquals(expectedOutput, result.toString());
}
@Test
void testModelValidateInvalidModel() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
- assertEquals(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING), result.toString());
+ var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING));
+ assertEquals(expectedOutput, result.toString());
}
@Test
void testModelValidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
- assertEquals(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING), result.toString());
+ var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING));
+ assertEquals(expectedOutput, result.toString());
}
@Test
void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
+
+ private String normalizeNewlines(String input) {
+ return input.replace("\r\n", "\n");
+ }
}
diff --git a/packages/apex-pdp-docker/pom.xml b/packages/apex-pdp-docker/pom.xml
index 7892768af..bbcd66066 100644
--- a/packages/apex-pdp-docker/pom.xml
+++ b/packages/apex-pdp-docker/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.packages</groupId>
<artifactId>apex-packages</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>apex-pdp-docker</artifactId>
diff --git a/packages/apex-pdp-docker/src/main/docker/Dockerfile b/packages/apex-pdp-docker/src/main/docker/Dockerfile
index 9bc0c81cf..4ec29df60 100644
--- a/packages/apex-pdp-docker/src/main/docker/Dockerfile
+++ b/packages/apex-pdp-docker/src/main/docker/Dockerfile
@@ -25,7 +25,7 @@ RUN mkdir /packages /extracted
COPY /maven/apex-pdp-package-full.tar.gz /packages/
RUN tar xvzf /packages/apex-pdp-package-full.tar.gz --directory /extracted/
-FROM onap/policy-jdk-alpine:4.0.0-SNAPSHOT
+FROM onap/policy-jdk-alpine:4.0.1-SNAPSHOT
LABEL maintainer="Policy Team"
LABEL org.opencontainers.image.title="Policy APEX PDP"
diff --git a/packages/apex-pdp-package-full/pom.xml b/packages/apex-pdp-package-full/pom.xml
index b0b42efe0..d55386cc8 100644
--- a/packages/apex-pdp-package-full/pom.xml
+++ b/packages/apex-pdp-package-full/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.packages</groupId>
<artifactId>apex-packages</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>apex-pdp-package-full</artifactId>
diff --git a/packages/pom.xml b/packages/pom.xml
index 0e431b94c..ea1195512 100644
--- a/packages/pom.xml
+++ b/packages/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.packages</groupId>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml
index 038500a89..7e5c568f8 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
<artifactId>plugins-context-distribution</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-context-distribution-hazelcast</artifactId>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml
index 5aba44550..49ecf2713 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
<artifactId>plugins-context-distribution</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-context-distribution-infinispan</artifactId>
diff --git a/plugins/plugins-context/plugins-context-distribution/pom.xml b/plugins/plugins-context/plugins-context-distribution/pom.xml
index 4bbeb5f87..c0a6ea543 100644
--- a/plugins/plugins-context/plugins-context-distribution/pom.xml
+++ b/plugins/plugins-context/plugins-context-distribution/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
<artifactId>plugins-context</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/pom.xml b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/pom.xml
index c480ed0cd..036708e8e 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/pom.xml
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
<artifactId>plugins-context-locking</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-context-locking-curator</artifactId>
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml
index ce55f9105..63bd73698 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
<artifactId>plugins-context-locking</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-context-locking-hazelcast</artifactId>
diff --git a/plugins/plugins-context/plugins-context-locking/pom.xml b/plugins/plugins-context/plugins-context-locking/pom.xml
index c894b509f..3ac0c7565 100644
--- a/plugins/plugins-context/plugins-context-locking/pom.xml
+++ b/plugins/plugins-context/plugins-context-locking/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
<artifactId>plugins-context</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/pom.xml b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/pom.xml
index 3c7d23118..1fa167005 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/pom.xml
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-schema</groupId>
<artifactId>plugins-context-schema</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-context-schema-avro</artifactId>
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/pom.xml b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/pom.xml
index 82a4075f1..99864b304 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/pom.xml
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/pom.xml
@@ -1,7 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2022 Bell Canada. All rights reserved.
- Modifications Copyright (C) 2023 Nordix Foundation.
+ Modifications Copyright (C) 2023-2024 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-schema</groupId>
<artifactId>plugins-context-schema</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-context-schema-json</artifactId>
@@ -33,8 +33,8 @@
<dependencies>
<dependency>
- <groupId>com.worldturner.medeia</groupId>
- <artifactId>medeia-validator-gson</artifactId>
+ <groupId>com.networknt</groupId>
+ <artifactId>json-schema-validator</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/main/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/main/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelper.java
index 4896e5d4a..0e8d5dfc8 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/main/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/main/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelper.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,18 +23,18 @@ package org.onap.policy.apex.plugins.context.schema.json;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
-import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
-import com.worldturner.medeia.api.SchemaSource;
-import com.worldturner.medeia.api.StringInputSource;
-import com.worldturner.medeia.api.StringSchemaSource;
-import com.worldturner.medeia.api.gson.MedeiaGsonApi;
-import com.worldturner.medeia.schema.validation.SchemaValidator;
+import com.networknt.schema.InputFormat;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersionDetector;
+import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
import java.util.Map;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.impl.schema.AbstractSchemaHelper;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
@@ -44,16 +45,14 @@ public class JsonSchemaHelper extends AbstractSchemaHelper {
private static final Gson gson = new Gson();
- private MedeiaGsonApi api = new MedeiaGsonApi();
- private SchemaValidator validator;
+ private JsonSchema jsonSchema;
@Override
public void init(final AxKey userKey, final AxContextSchema schema) {
super.init(userKey, schema);
try {
- SchemaSource source = new StringSchemaSource(schema.getSchema());
- validator = api.loadSchema(source);
+ this.jsonSchema = getJsonSchema(schema.getSchema());
} catch (final Exception e) {
final String resultSting = userKey.getId() + ": json context schema \"" + schema.getId()
+ "\" schema is invalid, schema: " + schema.getSchema();
@@ -86,8 +85,8 @@ public class JsonSchemaHelper extends AbstractSchemaHelper {
return object;
}
var objectString = (String) object;
- JsonReader reader = api.createJsonReader(validator, new StringInputSource(objectString));
- return gson.fromJson(reader, Object.class);
+ validate(objectString);
+ return gson.fromJson(new StringReader(objectString), Object.class);
}
@Override
@@ -103,7 +102,8 @@ public class JsonSchemaHelper extends AbstractSchemaHelper {
}
private JsonElement validateAndDecode(Object schemaObject, StringWriter stringWriter) {
- JsonWriter jsonWriter = api.createJsonWriter(validator, stringWriter);
+ validate(schemaObject);
+ JsonWriter jsonWriter = new JsonWriter(stringWriter);
jsonWriter.setIndent(" "); // to enable pretty print
JsonElement jsonObj = gson.toJsonTree(schemaObject);
gson.toJson(jsonObj, jsonWriter);
@@ -119,4 +119,27 @@ public class JsonSchemaHelper extends AbstractSchemaHelper {
private boolean passThroughObject(final Object object) {
return (object instanceof JsonElement || object instanceof Map || object instanceof List);
}
+
+ private JsonSchema getJsonSchema(String jsonSchema) {
+ var schemaMap = new Gson().fromJson(jsonSchema, Map.class);
+ if (schemaMap != null && schemaMap.containsKey("$schema")) {
+ var flag = SpecVersionDetector.detectOptionalVersion(schemaMap.get("$schema").toString()).orElse(null);
+ return JsonSchemaFactory.getInstance(flag).getSchema(jsonSchema);
+ } else {
+ throw new ApexRuntimeException("Schema is invalid");
+ }
+ }
+
+ private void validate(String json) {
+ var validations = this.jsonSchema.validate(json, InputFormat.JSON);
+ if (!validations.isEmpty()) {
+ StringBuilder errors = new StringBuilder();
+ validations.forEach(m -> errors.append(m.toString()).append("\n"));
+ throw new ApexRuntimeException(errors.toString());
+ }
+ }
+
+ private void validate(Object object) {
+ validate(gson.toJson(object));
+ }
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
index b129330ce..413037b97 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
@@ -26,7 +26,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import com.worldturner.medeia.api.ValidationFailedException;
import java.util.ArrayList;
import java.util.Map;
import org.junit.jupiter.api.Test;
@@ -103,8 +102,7 @@ class JsonSchemaHelperMarshalTest extends CommonTestData {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
dataAsObject.remove(TEST_ID);
assertThatThrownBy(() -> validateAndMarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject, true))
- .isInstanceOf(ValidationFailedException.class)
- .hasMessageContaining("Required property testId is missing from object");
+ .hasMessageContaining("required property 'testId' not found");
}
/**
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
index d0059f26f..f633b2d0f 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.gson.JsonObject;
-import com.worldturner.medeia.api.ValidationFailedException;
import java.util.ArrayList;
import java.util.Map;
import org.junit.jupiter.api.Test;
@@ -74,7 +73,8 @@ class JsonSchemaHelperUnmarshalTest extends CommonTestData {
new AxContextSchema(new AxArtifactKey("JsonObject", VERSION), JSON, schemaDef);
var jsonSchemaHelper = new JsonSchemaHelper();
assertThatThrownBy(() -> jsonSchemaHelper.init(testKey, jsonSchema))
- .isInstanceOf(ContextRuntimeException.class).hasMessageContaining("schema is invalid");
+ .isInstanceOf(ContextRuntimeException.class)
+ .hasMessageContaining("schema is invalid");
}
/**
@@ -111,8 +111,7 @@ class JsonSchemaHelperUnmarshalTest extends CommonTestData {
var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.addProperty("requestId", "abcd");
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
- .isInstanceOf(ValidationFailedException.class)
- .hasMessageContaining("Pattern ^[0-9]*-[0-9]*$ is not contained in text");
+ .hasMessageContaining("does not match the regex pattern ^[0-9]*-[0-9]*$");
}
/**
@@ -137,8 +136,7 @@ class JsonSchemaHelperUnmarshalTest extends CommonTestData {
var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
- .isInstanceOf(ValidationFailedException.class)
- .hasMessageContaining("Required property testId is missing from object");
+ .hasMessageContaining("required property 'testId' not found");
}
/**
diff --git a/plugins/plugins-context/plugins-context-schema/pom.xml b/plugins/plugins-context/plugins-context-schema/pom.xml
index c1b414f7b..e6ad64cea 100644
--- a/plugins/plugins-context/plugins-context-schema/pom.xml
+++ b/plugins/plugins-context/plugins-context-schema/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
<artifactId>plugins-context</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-schema</groupId>
diff --git a/plugins/plugins-context/pom.xml b/plugins/plugins-context/pom.xml
index 98195f77b..2fed08109 100644
--- a/plugins/plugins-context/pom.xml
+++ b/plugins/plugins-context/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins</groupId>
<artifactId>plugins</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context</groupId>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml
index 63b639775..d4bc40709 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
<artifactId>plugins-event-carrier</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-carrier-grpc</artifactId>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/pom.xml
index aeecd4211..6881edc84 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
<artifactId>plugins-event-carrier</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-carrier-jms</artifactId>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/pom.xml
index 5a3dbdb5b..db543c31f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
<artifactId>plugins-event-carrier</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-carrier-kafka</artifactId>
@@ -49,7 +49,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
- <version>1.25.0</version>
+ <version>1.27.0</version>
</dependency>
</dependencies>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
index 5856a5a6a..b32000529 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
<artifactId>plugins-event-carrier</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-carrier-restclient</artifactId>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java
index b3a6bca06..d87d7aab3 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java
@@ -37,9 +37,7 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
index ec454af00..928b1c72b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
@@ -35,10 +35,8 @@ import java.util.Properties;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
@@ -214,7 +212,7 @@ class ApexRestClientProducerTest {
properties.put("tag", "exist");
properties.put("key", "that");
Mockito.doReturn(Response.Status.ACCEPTED.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
+ closeable = Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target("http://some.place.that.does.not/exist");
@@ -246,7 +244,7 @@ class ApexRestClientProducerTest {
rcctp.setUrl("http://some.place.that.does.not/exist");
Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
- Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
+ closeable = Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
Mockito.doReturn(builderMock).when(targetMock).request("application/json");
Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any());
Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
index ade558b35..26621e66e 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
<artifactId>plugins-event-carrier</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-carrier-restrequestor</artifactId>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java
index f82add13f..2bbc7b9ef 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.gson.Gson;
import jakarta.ws.rs.DELETE;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/pom.xml
index 422bbe67a..ce160e1c0 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
<artifactId>plugins-event-carrier</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-carrier-restserver</artifactId>
diff --git a/plugins/plugins-event/plugins-event-carrier/pom.xml b/plugins/plugins-event/plugins-event-carrier/pom.xml
index 80205d11a..41b604bc1 100644
--- a/plugins/plugins-event/plugins-event-carrier/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event</groupId>
<artifactId>plugins-event</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml
index 2ca3cf24d..aa9a03108 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
<artifactId>plugins-event-protocol</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-protocol-jms</artifactId>
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/pom.xml b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/pom.xml
index 62d1fc2cd..899d62b42 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/pom.xml
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
<artifactId>plugins-event-protocol</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-event-protocol-yaml</artifactId>
diff --git a/plugins/plugins-event/plugins-event-protocol/pom.xml b/plugins/plugins-event/plugins-event-protocol/pom.xml
index 7ef918d87..08f1b5db7 100644
--- a/plugins/plugins-event/plugins-event-protocol/pom.xml
+++ b/plugins/plugins-event/plugins-event-protocol/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event</groupId>
<artifactId>plugins-event</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
diff --git a/plugins/plugins-event/pom.xml b/plugins/plugins-event/pom.xml
index fec8fece8..a038ceecd 100644
--- a/plugins/plugins-event/pom.xml
+++ b/plugins/plugins-event/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins</groupId>
<artifactId>plugins</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-event</groupId>
diff --git a/plugins/plugins-executor/plugins-executor-java/pom.xml b/plugins/plugins-executor/plugins-executor-java/pom.xml
index 27a80afff..5e192fc53 100644
--- a/plugins/plugins-executor/plugins-executor-java/pom.xml
+++ b/plugins/plugins-executor/plugins-executor-java/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
<artifactId>plugins-executor</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-executor-java</artifactId>
diff --git a/plugins/plugins-executor/plugins-executor-javascript/pom.xml b/plugins/plugins-executor/plugins-executor-javascript/pom.xml
index f8df9f5cc..462212485 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/pom.xml
+++ b/plugins/plugins-executor/plugins-executor-javascript/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
<artifactId>plugins-executor</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-executor-javascript</artifactId>
diff --git a/plugins/plugins-executor/plugins-executor-jruby/pom.xml b/plugins/plugins-executor/plugins-executor-jruby/pom.xml
index fa1b70228..dbaf9fed6 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/pom.xml
+++ b/plugins/plugins-executor/plugins-executor-jruby/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
<artifactId>plugins-executor</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-executor-jruby</artifactId>
diff --git a/plugins/plugins-executor/plugins-executor-mvel/pom.xml b/plugins/plugins-executor/plugins-executor-mvel/pom.xml
index e4076f61c..10b8ba949 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/pom.xml
+++ b/plugins/plugins-executor/plugins-executor-mvel/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
<artifactId>plugins-executor</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugins-executor-mvel</artifactId>
diff --git a/plugins/plugins-executor/pom.xml b/plugins/plugins-executor/pom.xml
index 9b42fe61f..cca587c77 100644
--- a/plugins/plugins-executor/pom.xml
+++ b/plugins/plugins-executor/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.plugins</groupId>
<artifactId>plugins</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
diff --git a/plugins/pom.xml b/plugins/pom.xml
index acb8b91ab..29b2f86ea 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.plugins</groupId>
diff --git a/pom.xml b/pom.xml
index 4418b4c0b..517a82188 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,13 +27,13 @@
<parent>
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
- <version>5.0.0-SNAPSHOT</version>
- <relativePath/>
+ <version>5.0.1-SNAPSHOT</version>
+ <relativePath />
</parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>policy-apex-pdp</name>
@@ -46,8 +46,8 @@
</sonar.javascript.lcov.reportPaths>
<!-- Policy framework dependencies -->
- <version.policy.common>3.0.0-SNAPSHOT</version.policy.common>
- <version.policy.models>4.0.0-SNAPSHOT</version.policy.models>
+ <version.policy.common>3.0.1-SNAPSHOT</version.policy.common>
+ <version.policy.models>4.0.1-SNAPSHOT</version.policy.models>
<!-- Apex-specific dependencies -->
<version.activemq>5.18.3</version.activemq>
@@ -57,7 +57,7 @@
<version.avro>1.11.3</version.avro>
<version.caffeine>3.1.8</version.caffeine>
<version.curator>5.5.0</version.curator>
- <version.hazelcast>5.3.1</version.hazelcast>
+ <version.hazelcast>5.3.5</version.hazelcast>
<version.infinispan>14.0.13.Final</version.infinispan>
<version.jgroups>5.2.18.Final</version.jgroups>
<version.jms>3.1.0</version.jms>
@@ -71,7 +71,7 @@
<version.kafka-junit5>3.2.5</version.kafka-junit5>
<version.rhino>1.7.14</version.rhino>
<version.websocket.jakarta>2.1.1</version.websocket.jakarta>
- <version.zookeeper>3.9.1</version.zookeeper>
+ <version.zookeeper>3.9.2</version.zookeeper>
</properties>
<distributionManagement>
@@ -83,11 +83,6 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
diff --git a/releases/4.0.0-container.yaml b/releases/4.0.0-container.yaml
new file mode 100644
index 000000000..38a7dd52a
--- /dev/null
+++ b/releases/4.0.0-container.yaml
@@ -0,0 +1,8 @@
+distribution_type: 'container'
+container_release_tag: '4.0.0'
+project: 'policy-apex-pdp'
+log_dir: 'policy-apex-pdp-maven-docker-stage-master/1426'
+ref: 0a4606593288b8901ee95ce9238df3418b189c89
+containers:
+ - name: 'policy-apex-pdp'
+ version: '4.0.0-20240712T1140'
diff --git a/releases/4.0.0.yaml b/releases/4.0.0.yaml
new file mode 100644
index 000000000..f3ac8d522
--- /dev/null
+++ b/releases/4.0.0.yaml
@@ -0,0 +1,5 @@
+distribution_type: 'maven'
+version: '4.0.0'
+project: 'policy-apex-pdp'
+tag_release: false
+log_dir: 'policy-apex-pdp-maven-stage-master/1432/'
diff --git a/services/pom.xml b/services/pom.xml
index 0d3bf1004..357bb383d 100644
--- a/services/pom.xml
+++ b/services/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.services</groupId>
diff --git a/services/services-engine/pom.xml b/services/services-engine/pom.xml
index 6d0b20613..66a4dbcac 100644
--- a/services/services-engine/pom.xml
+++ b/services/services-engine/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.services</groupId>
<artifactId>services</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>services-engine</artifactId>
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
index caba093ce..34db034ed 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
@@ -32,7 +32,6 @@ import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -118,7 +117,7 @@ class EngineServiceImplTest {
ParameterService.register(engineParameters);
}
- private static @NotNull ExecutorParameters getExecutorParameters(String lang) {
+ private static ExecutorParameters getExecutorParameters(String lang) {
ExecutorParameters jsExecutorParameters = new ExecutorParameters();
jsExecutorParameters.setName(lang);
jsExecutorParameters
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
index 0716e0ad3..5082100e0 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
@@ -34,7 +34,6 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
@@ -125,7 +124,7 @@ class EngineWorkerTest {
}
- private static @NotNull ExecutorParameters getExecutorParameters(String lang) {
+ private static ExecutorParameters getExecutorParameters(String lang) {
ExecutorParameters jsExecutorParameters = new ExecutorParameters();
jsExecutorParameters.setName(lang);
jsExecutorParameters
diff --git a/services/services-onappf/pom.xml b/services/services-onappf/pom.xml
index 799f580f6..11101233a 100644
--- a/services/services-onappf/pom.xml
+++ b/services/services-onappf/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.services</groupId>
<artifactId>services</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>services-onappf</artifactId>
diff --git a/testsuites/apex-pdp-stability/pom.xml b/testsuites/apex-pdp-stability/pom.xml
index 56b740c61..6d8faf889 100644
--- a/testsuites/apex-pdp-stability/pom.xml
+++ b/testsuites/apex-pdp-stability/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites</groupId>
<artifactId>apex-testsuites</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.testsuites.stability</groupId>
diff --git a/testsuites/integration/integration-common/pom.xml b/testsuites/integration/integration-common/pom.xml
index 7b3ee0590..47bb58087 100644
--- a/testsuites/integration/integration-common/pom.xml
+++ b/testsuites/integration/integration-common/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>apex-integration</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>integration-common</artifactId>
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/concepts/ConceptsTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/concepts/ConceptsTest.java
new file mode 100644
index 000000000..7592978cd
--- /dev/null
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/concepts/ConceptsTest.java
@@ -0,0 +1,183 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation. 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.testsuites.integration.common.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.TreeSet;
+import org.junit.jupiter.api.Test;
+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;
+
+class ConceptsTest {
+
+ @Test
+ void testConceptBooleanItem() {
+ assertDoesNotThrow(() -> new TestContextBooleanItem());
+ assertDoesNotThrow(() -> new TestContextBooleanItem(true));
+ var item = new TestContextBooleanItem();
+ item.setFlag(false);
+ assertFalse(item.isFlag());
+ }
+
+ @Test
+ void testContextByteItem() {
+ assertDoesNotThrow(() -> new TestContextByteItem());
+ assertDoesNotThrow(() -> new TestContextByteItem((byte) 1));
+ var byteItem = new TestContextByteItem();
+ byteItem.setByteValue((byte) 0);
+ assertEquals((byte) 0, byteItem.getByteValue());
+ assertEquals((byte) 1, byteItem.getIncrementedByteValue());
+ }
+
+ @Test
+ void testContextDateItem() {
+ assertDoesNotThrow(() -> new TestContextDateItem());
+ assertDoesNotThrow(() -> new TestContextDateItem(new Date()));
+ assertDoesNotThrow(() -> new TestContextDateItem(1726611256L));
+ var date = new TestContextDateItem();
+ date.setDateValue(new Date());
+ assertThat(date.getDateValue()).isInstanceOf(Date.class);
+ var date2 = new TestContextDateItem();
+ assertThat(date2.getMonth()).isInstanceOf(Integer.class);
+ assertThat(date2.getYear()).isInstanceOf(Integer.class);
+ assertThat(date2.getDay()).isInstanceOf(Integer.class);
+ assertThat(date2.getTime()).isInstanceOf(Long.class);
+ assertThat(date2.getMilliSecond()).isInstanceOf(Integer.class);
+ assertThat(date2.getMinute()).isInstanceOf(Integer.class);
+ assertThat(date2.getHour()).isInstanceOf(Integer.class);
+ assertThat(date2.getSecond()).isInstanceOf(Integer.class);
+ var date3 = new TestContextDateItem(null);
+ assertNotNull(date3.getDateValue());
+ }
+
+ @Test
+ void testContextDateLocaleItem() {
+ assertDoesNotThrow(() -> new TestContextDateLocaleItem());
+ assertDoesNotThrow(() -> new TestContextDateLocaleItem(new TestContextDateLocaleItem()));
+ assertDoesNotThrow(() -> new TestContextDateLocaleItem(new TestContextDateItem(), "UTC", true,
+ 1, "english", "Ireland"));
+ var localeItem = new TestContextDateLocaleItem();
+ localeItem.setTzValue("utc");
+ assertNotNull(localeItem.getTzValue());
+ }
+
+ @Test
+ void testContextDateTzItem() {
+ assertDoesNotThrow(() -> new TestContextDateTzItem());
+ assertDoesNotThrow(() -> new TestContextDateTzItem(new TestContextDateTzItem()));
+ assertDoesNotThrow(() -> new TestContextDateTzItem(new TestContextDateItem(), "utc", false));
+ var tzItem = new TestContextDateTzItem();
+ tzItem.setTzValue("utc");
+ assertNotNull(tzItem.getTzValue());
+ assertThat(tzItem.getTzValue()).isInstanceOf(String.class);
+ }
+
+ @Test
+ void testContextDoubleItem() {
+ assertDoesNotThrow(() -> new TestContextDoubleItem());
+ assertDoesNotThrow(() -> new TestContextDoubleItem(0));
+ var doubleItem = new TestContextDoubleItem();
+ doubleItem.setDoubleValue(0);
+ assertEquals(1, doubleItem.getIncrementedDoubleValue());
+ }
+
+ @Test
+ void testContextFloatItem() {
+ assertDoesNotThrow(() -> new TestContextFloatItem());
+ assertDoesNotThrow(() -> new TestContextFloatItem(0));
+ var floatItem = new TestContextFloatItem();
+ floatItem.setFloatValue(0);
+ assertEquals(1, floatItem.getIncrementedFloatValue());
+ }
+
+ @Test
+ void testContextIntItem() {
+ assertDoesNotThrow(() -> new TestContextIntItem());
+ assertDoesNotThrow(() -> new TestContextIntItem(0));
+ var intItem = new TestContextIntItem();
+ intItem.setIntValue(0);
+ assertEquals(1, intItem.getIncrementedIntValue());
+ }
+
+ @Test
+ void testContextLongItem() {
+ assertDoesNotThrow(() -> new TestContextLongItem());
+ assertDoesNotThrow(() -> new TestContextLongItem(0));
+ var longItem = new TestContextLongItem();
+ longItem.setLongValue(0);
+ assertEquals(1, longItem.getIncrementedLongValue());
+ }
+
+ @Test
+ void testContextLongObjectItem() {
+ assertDoesNotThrow(() -> new TestContextLongObjectItem());
+ assertDoesNotThrow(() -> new TestContextLongObjectItem(0L));
+ var longObjItem = new TestContextLongObjectItem();
+ longObjItem.setLongValue(0L);
+ assertEquals(1, longObjItem.getIncrementedLongValue());
+ }
+
+ @Test
+ void testContextStringItem() {
+ assertDoesNotThrow(() -> new TestContextStringItem());
+ assertDoesNotThrow(() -> new TestContextStringItem("test"));
+ var strItem = new TestContextStringItem();
+ strItem.setStringValue("test");
+ assertEquals("test", strItem.getStringValue());
+ }
+
+ @Test
+ void testContextTreeMapItem() {
+ assertDoesNotThrow(() -> new TestContextTreeMapItem());
+ assertDoesNotThrow(() -> new TestContextTreeMapItem(Map.of("", "")));
+ var treeMapItem = new TestContextTreeMapItem();
+ treeMapItem.setMapValue(Map.of("test", "testVal"));
+ assertEquals("testVal", treeMapItem.getMapValue().get("test"));
+ }
+
+ @Test
+ void testContextTreeSetItem() {
+ assertDoesNotThrow(() -> new TestContextTreeSetItem());
+ var items = new TreeSet<String>();
+ assertDoesNotThrow(() -> new TestContextTreeSetItem(items));
+ }
+
+
+
+}
diff --git a/testsuites/integration/integration-context-test/pom.xml b/testsuites/integration/integration-context-test/pom.xml
deleted file mode 100644
index 52340b01a..000000000
--- a/testsuites/integration/integration-context-test/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
- ================================================================================
- 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=========================================================
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
- <artifactId>apex-integration</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>integration-context-test</artifactId>
- <name>${project.artifactId}</name>
- <description>[${project.parent.artifactId}] module to run context tests using various plugins, multi-threads and multi-JVMs</description>
-
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
- <artifactId>integration-common</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
- <artifactId>plugins-context-distribution-hazelcast</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
- <artifactId>plugins-context-distribution-infinispan</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
- <artifactId>plugins-context-locking-curator</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
- <artifactId>plugins-context-locking-hazelcast</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/testsuites/integration/integration-context-test/pom.xml.versionsBackup b/testsuites/integration/integration-context-test/pom.xml.versionsBackup
deleted file mode 100644
index 4bc571f7d..000000000
--- a/testsuites/integration/integration-context-test/pom.xml.versionsBackup
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
- ================================================================================
- 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=========================================================
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
- <artifactId>apex-integration</artifactId>
- <version>3.1.2-SNAPSHOT</version>
- </parent>
-
- <artifactId>integration-context-test</artifactId>
- <name>${project.artifactId}</name>
- <description>[${project.parent.artifactId}] module to run context tests using various plugins, multi-threads and multi-JVMs</description>
-
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
- <artifactId>integration-common</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
- <artifactId>plugins-context-distribution-hazelcast</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
- <artifactId>plugins-context-distribution-infinispan</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
- <artifactId>plugins-context-locking-curator</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
- <artifactId>plugins-context-locking-hazelcast</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java
deleted file mode 100644
index 8af964985..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.onap.policy.apex.context.parameters.DistributorParameters.DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.TEST_VALUE;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Map;
-import java.util.SortedSet;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-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.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
-import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager;
-import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters;
-import org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager;
-import org.onap.policy.apex.testsuites.integration.context.lock.modifier.LockType;
-import org.onap.policy.apex.testsuites.integration.context.locking.ConcurrentContext;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProviderImpl;
-import org.onap.policy.apex.testsuites.integration.context.utils.Constants;
-import org.onap.policy.apex.testsuites.integration.context.utils.NetworkUtils;
-import org.onap.policy.apex.testsuites.integration.context.utils.ZooKeeperServerServiceProvider;
-import org.onap.policy.common.parameters.ParameterService;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestConcurrentContext tests concurrent use of context.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestConcurrentContext {
- private static final String HAZELCAST_CONFIG = "hazelcast.config";
-
- private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack";
- private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml";
-
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(TestConcurrentContext.class);
-
- // Test parameters
- private static final String ZOOKEEPER_ADDRESS = "127.0.0.1";
- private static final int ZOOKEEPER_START_PORT = 62181;
- private static final int TEST_JVM_COUNT_SINGLE_JVM = 1;
- private static final int TEST_JVM_COUNT_MULTI_JVM = 3;
- private static final int TEST_THREAD_COUNT_SINGLE_JVM = 64;
- private static final int TEST_THREAD_COUNT_MULTI_JVM = 20;
- private static final int TEST_THREAD_LOOPS = 100;
-
- // We need to increment the Zookeeper port because sometimes the port is not released at the end
- // of the test for a few seconds.
- private static int nextZookeeperPort = ZOOKEEPER_START_PORT;
-
- private int zookeeperPort;
-
- private static SchemaParameters schemaParameters;
-
- @Rule
- public final TemporaryFolder folder = new TemporaryFolder();
-
- private ZooKeeperServerServiceProvider zooKeeperServerServiceProvider;
-
- /**
- * Configure.
- *
- * @throws Exception the exception
- */
- @BeforeClass
- public static void configure() throws Exception {
- System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true");
- final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE);
- System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation);
-
- final SortedSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
-
- if (ipAddressSet.size() == 0) {
- throw new Exception("cound not find real IP address for test");
- }
- logger.info("For Infinispan, setting jgroups.tcp.address to: {}", ipAddressSet.first());
- System.setProperty("jgroups.tcp.address", ipAddressSet.first());
-
- schemaParameters = new SchemaParameters();
-
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters, true);
- }
-
- /**
- * Clear configuration.
- */
- @AfterClass
- public static void clear() {
- ParameterService.deregister(schemaParameters);
- }
-
- /**
- * Start zookeeper server.
- *
- * @throws Exception the exception
- */
- private void startZookeeperServer() throws Exception {
- final File zookeeperDirectory = folder.newFolder("zookeeperDirectory");
-
- zookeeperPort = nextZookeeperPort++;
- final InetSocketAddress addr = new InetSocketAddress(zookeeperPort);
- zooKeeperServerServiceProvider = new ZooKeeperServerServiceProvider(zookeeperDirectory, addr);
- zooKeeperServerServiceProvider.startZookeeperServer();
- }
-
- /**
- * Stop zookeeper server.
- */
- private void stopZookeeperServer() {
- if (zooKeeperServerServiceProvider != null) {
- zooKeeperServerServiceProvider.stopZookeeperServer();
- }
- }
-
- /**
- * Test concurrent context jvm local var set.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextJvmLocalVarSet() throws Exception {
- logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getLockManagerParameters().setPluginClass(JvmLocalLockManager.class.getName());
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet",
- TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- assertFalse(result.isEmpty());
-
- final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
- clearContextParmetersInParameterService(contextParameters);
-
- logger.debug("Ran testConcurrentContextJVMLocalVarSet test");
- }
-
- /**
- * Test concurrent context jvm local no var set.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextJvmLocalNoVarSet() throws Exception {
- logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalNoVarSet",
- TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(Constants.TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
- clearContextParmetersInParameterService(contextParameters);
- logger.debug("Ran testConcurrentContextJVMLocalNoVarSet test");
- }
-
- /**
- * Test concurrent context multi jvm no lock.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextMultiJvmNoLock() throws Exception {
- logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(JvmLocalDistributor.class.getName());
- contextParameters.getLockManagerParameters().setPluginClass(JvmLocalLockManager.class.getName());
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("testConcurrentContextMultiJVMNoLock",
- TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- // No concurrent map so result will be zero
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(0, actual.getLongValue());
-
- clearContextParmetersInParameterService(contextParameters);
- logger.debug("Ran testConcurrentContextMultiJVMNoLock test");
- }
-
- /**
- * Test concurrent context hazelcast lock.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextHazelcastLock() throws Exception {
- logger.debug("Running testConcurrentContextHazelcastLock test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
- contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getName());
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("HazelcastLock",
- TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
- clearContextParmetersInParameterService(contextParameters);
- logger.debug("Ran testConcurrentContextHazelcastLock test");
- }
-
- /**
- * Test concurrent context curator lock.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextCuratorLock() throws Exception {
- logger.debug("Running testConcurrentContextCuratorLock test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- try {
- startZookeeperServer();
- final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
- distributorParameters.setPluginClass(DEFAULT_DISTRIBUTOR_PLUGIN_CLASS);
-
- final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass(CuratorLockManager.class.getName());
- curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
- contextParameters.setLockManagerParameters(curatorParameters);
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("CuratorLock",
- TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_SINGLE_JVM * TEST_THREAD_COUNT_SINGLE_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
- logger.debug("Ran testConcurrentContextCuratorLock test");
- } finally {
- stopZookeeperServer();
- clearContextParmetersInParameterService(contextParameters);
- }
- }
-
- /**
- * Test concurrent context hazelcast multi jvm hazelcast lock.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextHazelcastMultiJvmHazelcastLock() throws Exception {
- logger.debug("Running testConcurrentContextHazelcastMultiJVMHazelcastLock test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- final DistributorParameters distributorParameters = contextParameters.getDistributorParameters();
- distributorParameters.setPluginClass(HazelcastContextDistributor.class.getName());
- contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getName());
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("HazelcastMultiHazelcastlock",
- TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
- clearContextParmetersInParameterService(contextParameters);
- logger.debug("Ran testConcurrentContextHazelcastMultiJVMHazelcastLock test");
- }
-
- /**
- * Test concurrent context infinispan multi jvm hazelcastlock.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testConcurrentContextInfinispanMultiJvmHazelcastlock()
- throws ApexModelException, IOException, ApexException {
- logger.debug("Running testConcurrentContextInfinispanMultiJVMHazelcastlock test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
- infinispanParameters.setPluginClass(InfinispanContextDistributor.class.getName());
- infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml");
- contextParameters.setDistributorParameters(infinispanParameters);
- contextParameters.getLockManagerParameters().setPluginClass(HazelcastLockManager.class.getName());
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("InfinispanMultiHazelcastlock",
- TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
-
- clearContextParmetersInParameterService(contextParameters);
- logger.debug("Ran testConcurrentContextInfinispanMultiJVMHazelcastlock test");
- }
-
- /**
- * Test concurrent context infinispan multi jvm curator lock.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextInfinispanMultiJvmCuratorLock() throws Exception {
- logger.debug("Running testConcurrentContextInfinispanMultiJVMCuratorLock test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- try {
- startZookeeperServer();
-
- final InfinispanDistributorParameters infinispanParameters = new InfinispanDistributorParameters();
- infinispanParameters.setPluginClass(InfinispanContextDistributor.class.getName());
- infinispanParameters.setConfigFile("infinispan/infinispan-context-test.xml");
- contextParameters.setDistributorParameters(infinispanParameters);
-
- final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass(CuratorLockManager.class.getName());
- curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
- contextParameters.setLockManagerParameters(curatorParameters);
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("InfinispanMultiCuratorLock",
- TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
-
- final ConcurrentContext concurrentContext = new ConcurrentContext(configrationProvider);
- final Map<String, TestContextLongItem> result = concurrentContext.testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
- } finally {
- stopZookeeperServer();
- clearContextParmetersInParameterService(contextParameters);
- }
-
- logger.debug("Ran testConcurrentContextInfinispanMultiJVMCuratorLock test");
- }
-
- /**
- * Test concurrent context hazelcast multi jvm curator lock.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConcurrentContextHazelcastMultiJvmCuratorLock() throws Exception {
- logger.debug("Running testConcurrentContextHazelcastMultiJVMCuratorLock test . . .");
-
- final ContextParameters contextParameters = new ContextParameters();
- try {
- startZookeeperServer();
-
- contextParameters.getDistributorParameters()
- .setPluginClass(HazelcastContextDistributor.class.getName());
-
- final CuratorLockManagerParameters curatorParameters = new CuratorLockManagerParameters();
- curatorParameters.setPluginClass(CuratorLockManager.class.getName());
- curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
- contextParameters.setLockManagerParameters(curatorParameters);
- setContextParmetersInParameterService(contextParameters);
-
- final ConfigrationProvider configrationProvider = getConfigrationProvider("HazelcastMultiCuratorLock",
- TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
- final Map<String, TestContextLongItem> result =
- new ConcurrentContext(configrationProvider).testConcurrentContext();
-
- final int expected = TEST_JVM_COUNT_MULTI_JVM * TEST_THREAD_COUNT_MULTI_JVM * TEST_THREAD_LOOPS;
- final TestContextLongItem actual = result.get(TEST_VALUE);
- assertNotNull(actual);
- assertEquals(expected, actual.getLongValue());
- } finally {
- stopZookeeperServer();
- clearContextParmetersInParameterService(contextParameters);
- }
- logger.debug("Ran testConcurrentContextHazelcastMultiJVMCuratorLock test");
- }
-
- /**
- * Gets the configration provider.
- *
- * @param testType the test type
- * @param jvmCount the jvm count
- * @param threadCount the thread count
- * @param threadLoops the thread loops
- * @return the configration provider
- */
- ConfigrationProvider getConfigrationProvider(final String testType, final int jvmCount, final int threadCount,
- final int threadLoops) {
- return new ConfigrationProviderImpl(testType, jvmCount, threadCount, threadLoops, 16,
- LockType.WRITE_LOCK_SINGLE_VALUE_UPDATE.getValue()) {
- @Override
- public Map<String, Object> getContextAlbumInitValues() {
- final Map<String, Object> initValues = super.getContextAlbumInitValues();
- initValues.put(TEST_VALUE, new TestContextLongItem(0L));
- return initValues;
- }
-
- };
- }
-
- /**
- * Set the context parameters in the parameter service.
- *
- * @param contextParameters The parameters to set.
- */
- private void setContextParmetersInParameterService(final ContextParameters contextParameters) {
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
- }
-
- /**
- * Clear the context parameters in the parameter service.
- *
- * @param contextParameters The parameters to set.
- */
- private void clearContextParmetersInParameterService(final ContextParameters contextParameters) {
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters);
-
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextAlbumUpdate.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextAlbumUpdate.java
deleted file mode 100644
index 97bfa9efd..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextAlbumUpdate.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.distribution;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.APEX_DISTRIBUTOR;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.VERSION;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
-import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
-import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class ContextAlbumUpdate is used to test Context Album updates.
- */
-public class ContextAlbumUpdate {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextAlbumUpdate.class);
-
- /**
- * Test context album update.
- *
- * @throws ApexException the apex exception
- */
- public void testContextAlbumUpdate() throws ApexException {
- LOGGER.debug("Running TestContextAlbumUpdate test . . .");
-
- 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", VERSION));
- final ContextAlbum longAlbum1 = contextDistributor.createContextAlbum(longAlbum1Def.getKey());
-
- assertNotNull(longAlbum1);
-
- final AxContextAlbum longAlbum2Def = longModel.getAlbums().get(new AxArtifactKey("LongContextAlbum2", VERSION));
- final ContextAlbum longAlbum2 = contextDistributor.createContextAlbum(longAlbum2Def.getKey());
-
- assertNotNull(longAlbum2);
-
- longAlbum1.put("0", (long) 0);
- longAlbum1.put("1", (long) 1);
- longAlbum1.put("2", (long) 2);
- longAlbum1.put("3", (long) 3);
-
- final KeyedMapDifference<String, Object> result0 =
- new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
-
- 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);
-
-
- 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);
- longAlbum1.put("67", (long) 6);
- longAlbum2.put("67", (long) 7);
-
- final KeyedMapDifference<String, Object> result2 =
- new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
-
- 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");
-
- final KeyedMapDifference<String, Object> result3 =
- new KeyedMapComparer<String, Object>().compareMaps(longAlbum1, longAlbum2);
-
- 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/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java
deleted file mode 100644
index fa3612fe9..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.distribution;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory.createPolicyContextModel;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.BYTE_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXTERNAL_CONTEXT;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.FLOAT_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.GLOBAL_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.GLOBAL_CONTEXT_KEY;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.INT_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.INT_VAL_2;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.INT_VAL_3;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.LONG_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.PI_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.POLICY_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.STRING_EXT_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.STRING_GLOBAL_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.STRING_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.TEST_POLICY_CONTEXT_ITEM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.TIME_ZONE;
-import static org.onap.policy.apex.testsuites.integration.context.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.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.testsuites.integration.context.utils.Constants;
-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);
-
- // Recurring string constants
- private static final String TEST_POLICY_CONTEXT_ITEM000 = "TestPolicyContextItem000";
- private static final String TEST_POLICY_CONTEXT_ITEM005 = "TestPolicyContextItem005";
- private static final String TEST_POLICY_CONTEXT_ITEM004 = "TestPolicyContextItem004";
- private static final String TEST_POLICY_CONTEXT_ITEM003 = "TestPolicyContextItem003";
- private static final String TEST_POLICY_CONTEXT_ITEM002 = "TestPolicyContextItem002";
- private static final String TEST_POLICY_CONTEXT_ITEM001 = "TestPolicyContextItem001";
- private static final String NULL_ILLEGAL = "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key ";
-
- private static final TreeSet<String> TEST_TREE_SET = new TreeSet<>();
- private static final 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();
-
- final ContextAlbum policyContextAlbum = contextDistributor
- .createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION));
-
- assertNotNull(policyContextAlbum);
- policyContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
-
- 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().isFlag());
- assertEquals(contextItem.getTestPolicyContextItem004().getLongValue(), testDate.getTime());
- assertEquals(TEST_HASH_MAP, contextItem.getTestPolicyContextItem005().getMapValue());
-
- 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().isFlag());
-
- 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((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(Constants.getAxArtifactKeyArray());
-
- externalContextAlbum.putAll(valueMap2);
- externalContextAlbum.getAlbumDefinition().setWritable(false);
-
- TestExternalContextItem externalContextItem = (TestExternalContextItem) externalContextAlbum
- .get(EXTERNAL_CONTEXT);
-
- assertFalse(externalContextItem.getTestExternalContextItem000().isFlag());
- 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((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
- assertThatThrownBy(() -> externalContextAlbum.clear()).isInstanceOf(ContextRuntimeException.class)
- .hasMessageContaining("album \"ExternalContextAlbum:0.0.1\" clear() not allowed on read only albums");
- assertEquals(1, externalContextAlbum.size());
-
- assertContextAlbumContains(externalContext, externalContextAlbum);
-
- final Set<Entry<String, Object>> entrySet = externalContextAlbum.entrySet();
- assertEquals(1, entrySet.size());
-
- assertThatThrownBy(() -> externalContextAlbum.get(null)).isInstanceOf(ContextRuntimeException.class)
- .hasMessageContaining("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for get()");
- final Object aObject = externalContextAlbum.get(EXTERNAL_CONTEXT);
- assertEquals(aObject, externalContext);
-
- // put null keys should fail, throws a runtime exception
- assertThatThrownBy(() -> externalContextAlbum.put(null, null))
- .hasMessageContaining("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()");
- assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItem00A", null))
- .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItem00A\" for put()");
- 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);
-
- assertThat(externalContextAlbum.put(EXTERNAL_CONTEXT, externalContextOther)).isEqualTo(externalContext);
- externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
- assertEquals(INT_VAL_2, externalContextItem.getTestExternalContextItem002().getIntValue());
- assertThat(externalContextAlbum.put(EXTERNAL_CONTEXT, externalContext)).isEqualTo(externalContextOther);
- externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
- assertEquals(INT_VAL_3, externalContextItem.getTestExternalContextItem002().getIntValue());
- assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItem00A", null))
- .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItem00A\" for put()");
-
- assertThat(externalContextAlbum.get(EXTERNAL_CONTEXT)).isEqualTo(externalContext);
-
- assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItemFFF", null))
- .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItemFFF\" for put()");
- assertEquals(1, externalContextAlbum.size());
-
- assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItemFFF", null))
- .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItemFFF\" for put()");
- assertEquals(1, externalContextAlbum.size());
-
- // Should ignore remove
- externalContextAlbum.remove("TestExternalContextItem017");
- assertEquals(1, externalContextAlbum.size());
- assertEquals(1, externalContextAlbum.values().size());
- assertTrue(externalContextAlbum.values().containsAll(mapValues));
-
- contextDistributor.clear();
- }
-
- private void assertContextAlbumContains(final TestExternalContextItem externalContext,
- final ContextAlbum externalContextAlbum) {
- assertThatThrownBy(() -> externalContextAlbum.containsKey(null))
- .hasMessageContaining("null values are illegal on method parameter \"key\"");
- assertTrue(externalContextAlbum.containsKey(EXTERNAL_CONTEXT));
- assertTrue(!externalContextAlbum.containsKey(GLOBAL_CONTEXT_KEY));
-
- assertThatThrownBy(() -> externalContextAlbum.containsValue(null))
- .hasMessageContaining("null values are illegal on method parameter \"value\"");
- 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(Constants.getAxArtifactKeyArray());
- 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 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(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 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(TEST_POLICY_CONTEXT_ITEM001, contextLongItem);
- valueMapA.put(TEST_POLICY_CONTEXT_ITEM002, contextDoubleItem);
- valueMapA.put(TEST_POLICY_CONTEXT_ITEM003, contextBooleanItem);
- valueMapA.put(TEST_POLICY_CONTEXT_ITEM004, contextLongItem2);
- valueMapA.put(TEST_POLICY_CONTEXT_ITEM005, contextTreeMapItem);
- valueMapA.put(TEST_POLICY_CONTEXT_ITEM000, 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) {
- assertThatThrownBy(() -> policyContextAlbum.put(TEST_POLICY_CONTEXT_ITEM000, contextStringItem))
- .hasMessageContaining(getMessage(TEST_POLICY_CONTEXT_ITEM000, "TestContextItem006",
- TestContextStringItem.class.getName(), "stringValue=" + STRING_VAL));
- assertThatThrownBy(() -> policyContextAlbum.putAll(valueMapA))
- .hasMessageContaining(getMessage(TEST_POLICY_CONTEXT_ITEM001, "TestContextItem003",
- TestContextLongItem.class.getName(), "longValue=" + INT_VAL_3));
- }
-
- 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 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(3.14159265359F);
- 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.getName());
- }
-
- 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) {
- assertThat(actual).isEqualTo(expected);
- }
-
- private void assertDouble(final double actual, final double expected) {
- assertThat(actual).isEqualTo(expected);
- }
-
- 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/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java
deleted file mode 100644
index 8d5b702b0..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.distribution;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.APEX_DISTRIBUTOR;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.DATE_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.LONG_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.MAP_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.TIME_ZONE;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.VERSION;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.getAxArtifactKeyArray;
-
-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.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.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
-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 NUMBER_ZERO = "0";
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextUpdate.class);
-
- /**
- * Test context update.
- *
- * @throws ApexException the apex exception
- */
- public void testContextUpdate() throws 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(NUMBER_ZERO, (long) 0);
- longContextAlbum.put(NUMBER_ZERO, 0);
- longContextAlbum.put(NUMBER_ZERO, NUMBER_ZERO);
-
- assertThatThrownBy(() -> longContextAlbum.put(NUMBER_ZERO, ZERO))
- .hasMessage("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\"");
- assertThatThrownBy(() -> longContextAlbum.put(NUMBER_ZERO, ""))
- .hasMessage("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\"");
- assertThatThrownBy(() -> longContextAlbum.put(NUMBER_ZERO, null))
- .hasMessage("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()");
- assertThatThrownBy(() -> longContextAlbum.put(null, null))
- .hasMessage("album \"LongContextAlbum:0.0.1\" null keys are illegal on keys for put()");
-
- assertNull(dateContextAlbum.put("date0", tciA));
- assertThat(dateContextAlbum.put("date0", tciA)).isEqualTo(tciA);
-
- assertNull(mapContextAlbum.put("map0", tciC));
- assertThat(mapContextAlbum.put("map0", tciC)).isEqualTo(tciC);
-
- contextDistributor.clear();
- }
-
- private TestContextTreeMapItem getTestContextTreeMapItem() {
- final Map<String, String> testHashMap = new HashMap<>();
- testHashMap.put(NUMBER_ZERO, ZERO);
- testHashMap.put("1", "one");
- testHashMap.put("2", "two");
- testHashMap.put("3", "three");
- testHashMap.put("4", "four");
-
- return new TestContextTreeMapItem(testHashMap);
- }
-
- 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(getAxArtifactKeyArray());
- 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/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java
deleted file mode 100644
index f38dfe453..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java
+++ /dev/null
@@ -1,135 +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.testsuites.integration.context.distribution;
-
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class HazelcastContextDistributorTest.
- */
-public class HazelcastContextDistributorTest {
- private static final String HAZEL_CAST_PLUGIN_CLASS = HazelcastContextDistributor.class.getName();
- // Logger for this class
- private static final XLogger logger = XLoggerFactory.getXLogger(HazelcastContextDistributorTest.class);
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Before test.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * After test.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- /**
- * Test context album update hazelcast.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextAlbumUpdateHazelcast test . . .");
-
- new ContextAlbumUpdate().testContextAlbumUpdate();
-
- logger.debug("Ran testContextAlbumUpdateHazelcast test");
- }
-
- /**
- * Test context instantiation hazelcast.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextInstantiationHazelcast test . . .");
-
- new ContextInstantiation().testContextInstantiation();
-
- logger.debug("Ran testContextInstantiationHazelcast test");
- }
-
- /**
- * Test context update hazelcast.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextUpdateHazelcast test . . .");
-
- new ContextUpdate().testContextUpdate();
-
- logger.debug("Ran testContextUpdateHazelcast test");
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java
deleted file mode 100644
index a162ebecc..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============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.testsuites.integration.context.distribution;
-
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor;
-import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class InfinispanContextDistributorTest.
- */
-public class InfinispanContextDistributorTest {
- private static final XLogger logger = XLoggerFactory.getXLogger(InfinispanContextDistributorTest.class);
-
- private static final String PLUGIN_CLASS = InfinispanContextDistributor.class.getName();
-
- private SchemaParameters schemaParameters;
- private ContextParameters contextParameters;
-
- /**
- * Before test.
- */
- @Before
- public void beforeTest() {
- contextParameters = new ContextParameters();
-
- contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
- InfinispanDistributorParameters inifinispanDistributorParameters = new InfinispanDistributorParameters();
- inifinispanDistributorParameters.setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
- inifinispanDistributorParameters.setPluginClass(PLUGIN_CLASS);
- contextParameters.setDistributorParameters(inifinispanDistributorParameters);
- contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
- contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
-
- ParameterService.register(contextParameters);
- ParameterService.register(contextParameters.getDistributorParameters());
- ParameterService.register(contextParameters.getLockManagerParameters());
- ParameterService.register(contextParameters.getPersistorParameters());
-
- schemaParameters = new SchemaParameters();
- schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
- schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
-
- ParameterService.register(schemaParameters);
- }
-
- /**
- * After test.
- */
- @After
- public void afterTest() {
- ParameterService.deregister(schemaParameters);
-
- ParameterService.deregister(contextParameters.getDistributorParameters());
- ParameterService.deregister(contextParameters.getLockManagerParameters());
- ParameterService.deregister(contextParameters.getPersistorParameters());
- ParameterService.deregister(contextParameters);
- }
-
- /**
- * Test context album update infinispan.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextAlbumUpdateInfinispan test . . .");
-
- new ContextAlbumUpdate().testContextAlbumUpdate();
-
- logger.debug("Ran testContextAlbumUpdateInfinispan test");
- }
-
- /**
- * Test context instantiation infinispan.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextInstantiationInfinispan test . . .");
-
- new ContextInstantiation().testContextInstantiation();
-
- logger.debug("Ran testContextInstantiationInfinispan test");
- }
-
- /**
- * Test context update infinispan.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testContextUpdateInfinispan test . . .");
-
- new ContextUpdate().testContextUpdate();
-
- logger.debug("Ran testContextUpdateInfinispan test");
- }
-
- /**
- * Test sequential context instantiation infinispan.
- *
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
- */
- @Test
- public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
- logger.debug("Running testSequentialContextInstantiationInfinispan test . . .");
-
- new SequentialContextInstantiation().testSequentialContextInstantiation();
-
- logger.debug("Ran testSequentialContextInstantiationInfinispan test");
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java
deleted file mode 100644
index 50ca52a6b..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.distribution;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory.createMultiAlbumsContextModel;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.APEX_DISTRIBUTOR;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.BYTE_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.DATE_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.FLOAT_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.INT_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.LONG_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.PI_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.STRING_GLOBAL_VAL;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.TIME_ZONE;
-import static org.onap.policy.apex.testsuites.integration.context.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.onap.policy.apex.testsuites.integration.context.utils.Constants;
-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);
-
- // Recurring string constants.
- private static final String TEST_AB = "TestAB";
- private static final String TEST_AA = "TestAA";
- private static final String ITEM_NULL = "ItemNull";
- private static final String ITEM06 = "Item06";
- private static final String ITEM05 = "Item05";
- private static final String ITEM03 = "Item03";
- private static final String ITEM02 = "Item02";
- private static final String ITEM01 = "Item01";
- private static final String ITEM00_2 = "Item00_2";
-
- // Recurring string constants.
- private static final String DV1 = "dv1";
- private static final String DV0 = "dv0";
-
- /**
- * 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);
-
- assertThatThrownBy(() -> dateAlbum.put("tci9", tci9))
- .hasMessageContaining("class \"" + TestContextDateTzItem.class.getName()
- + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getName() + "\"");
-
- 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);
-
- assertThatThrownBy(() -> dateAlbum1.putAll(valueMap1)).hasMessageContaining(
- "not compatible with class \"" + TestContextDateLocaleItem.class.getName() + "\"");
- 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(TEST_AA);
- dateAlbum.remove(TEST_AB);
- dateAlbum.remove(ITEM_NULL);
- 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) {
- assertThatThrownBy(() -> dateAlbum.containsKey(null))
- .hasMessageContaining("null values are illegal on method parameter \"key\"");
-
- assertTrue(dateAlbum.containsKey(ITEM05));
- assertTrue(!dateAlbum.containsKey("Item07"));
-
- assertThatThrownBy(() -> dateAlbum.containsValue(null))
- .hasMessageContaining("null values are illegal on method parameter \"value\"");
-
- assertTrue(dateAlbum.containsValue(tciA01));
- assertTrue(!dateAlbum.containsValue("Hello"));
- }
-
- private void assertAlbumGetAndPutMethods(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA03,
- final TestContextDateLocaleItem tciA00) {
- assertThatThrownBy(() -> dateAlbum.get(null))
- .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()");
-
- final Object aObject = dateAlbum.get(ITEM03);
- assertEquals(tciA03, aObject);
- assertThatThrownBy(() -> dateAlbum.put(null, null))
- .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()");
-
- // Put null ContextItem should work (return null)
- assertThatThrownBy(() -> dateAlbum.put(ITEM_NULL, null)).hasMessageContaining(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on " + "key \"ItemNull\" for put()");
-
- // Should return null
- assertNull(dateAlbum.get(ITEM_NULL));
- // Put should return the previous contextItem
- tciA00.setDst(false);
- final TestContextDateLocaleItem tciA03Clone = new TestContextDateLocaleItem(tciA03);
- tciA03Clone.setDst(true);
- TestContextDateLocaleItem retItem = (TestContextDateLocaleItem) dateAlbum.put(ITEM03, tciA03Clone);
- assertEquals(tciA03, retItem);
- retItem = (TestContextDateLocaleItem) dateAlbum.put(ITEM03, tciA03);
- assertEquals(tciA03Clone, retItem);
-
- assertThatThrownBy(() -> dateAlbum.put(ITEM_NULL, null)).hasMessageContaining(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on " + "key \"ItemNull\" for put()");
-
- dateAlbum.put(TEST_AA, tciA00);
- assertEquals(tciA00, dateAlbum.get(TEST_AA));
-
- // Should print warning
- assertThatThrownBy(() -> dateAlbum.put(TEST_AA, null)).hasMessageContaining(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" " + "for put()");
- assertEquals(8, dateAlbum.size());
- assertThatThrownBy(() -> dateAlbum.put(TEST_AB, null)).hasMessageContaining(
- "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" " + "for put()");
- 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(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(Constants.getAxArtifactKeyArray());
- 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/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java
deleted file mode 100644
index ae56d15d9..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022-2023 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.entities;
-
-import jakarta.xml.bind.annotation.XmlElement;
-import java.util.Arrays;
-import java.util.List;
-import lombok.AllArgsConstructor;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.apache.commons.lang3.builder.CompareToBuilder;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-
-/**
- * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
- */
-@Getter
-@Setter
-@ToString
-@EqualsAndHashCode(callSuper = false)
-@AllArgsConstructor
-public class ArtifactKeyTestEntity extends AxConcept {
- private static final long serialVersionUID = -2962570563281067896L;
-
- @XmlElement(name = "key", required = true)
- protected AxArtifactKey key;
-
- private double doubleValue;
-
- /**
- * Instantiates a new artifact key test entity.
- */
- public ArtifactKeyTestEntity() {
- this.key = new AxArtifactKey();
- this.doubleValue = 0;
- }
-
- /**
- * Instantiates a new artifact key test entity.
- *
- * @param doubleValue the double value
- */
- public ArtifactKeyTestEntity(final Double doubleValue) {
- this.key = new AxArtifactKey();
- this.doubleValue = doubleValue;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- return Arrays.asList((AxKey) getKey());
- }
-
- /**
- * Check set key.
- *
- * @return true, if successful
- */
- public boolean checkSetKey() {
- return (this.key != null);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult result) {
- return key.validate(result);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- key.clean();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
- if (copyObject instanceof ArtifactKeyTestEntity) {
- final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
- if (this.checkSetKey()) {
- copy.setKey(new AxArtifactKey(key));
- } else {
- copy.key = null;
- }
- copy.doubleValue = doubleValue;
- return copy;
- } else {
- return null;
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- if (otherObj == null) {
- return -1;
- }
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return -1;
- }
- final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
- return new CompareToBuilder()
- .append(key, other.key)
- .append(doubleValue, other.doubleValue)
- .toComparison();
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java
deleted file mode 100644
index 0da996483..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022-2023 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.entities;
-
-import jakarta.xml.bind.annotation.XmlElement;
-import java.util.Arrays;
-import java.util.List;
-import lombok.AllArgsConstructor;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.apache.commons.lang3.builder.CompareToBuilder;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-
-/**
- * The Class ReferenceKeyTestEntity provides a reference key test concept.
- */
-@Getter
-@Setter
-@ToString
-@EqualsAndHashCode(callSuper = false)
-@AllArgsConstructor
-public class ReferenceKeyTestEntity extends AxConcept {
- private static final long serialVersionUID = -2962570563281067895L;
-
- @XmlElement(name = "key", required = true)
- protected AxReferenceKey key;
-
- private double doubleValue;
-
- /**
- * Instantiates a new reference key test entity.
- */
- public ReferenceKeyTestEntity() {
- this.key = new AxReferenceKey();
- this.doubleValue = 0;
- }
-
- /**
- * Instantiates a new reference key test entity.
- *
- * @param doubleValue the double value
- */
- public ReferenceKeyTestEntity(final Double doubleValue) {
- this.key = new AxReferenceKey();
- this.doubleValue = doubleValue;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- return Arrays.asList((AxKey) getKey());
- }
-
- /**
- * Check set key.
- *
- * @return true, if successful
- */
- public boolean checkSetKey() {
- return (this.key != null);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult result) {
- return key.validate(result);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- key.clean();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- final Object copyObject = ((target == null) ? new ReferenceKeyTestEntity() : target);
- if (copyObject instanceof ReferenceKeyTestEntity) {
- final ReferenceKeyTestEntity copy = ((ReferenceKeyTestEntity) copyObject);
- if (this.checkSetKey()) {
- copy.setKey(new AxReferenceKey(key));
- } else {
- copy.key = null;
- }
- copy.doubleValue = doubleValue;
- return copy;
- } else {
- return null;
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- if (otherObj == null) {
- return -1;
- }
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return -1;
- }
- final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj;
- return new CompareToBuilder()
- .append(key, other.key)
- .append(doubleValue, other.doubleValue)
- .toComparison();
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/package-info.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/package-info.java
deleted file mode 100644
index 8824a16f5..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * Contains common test entities.
- * @author Dinh Danh Le (dinh.danh.le@ericsson.com)
- *
- */
-package org.onap.policy.apex.testsuites.integration.context.entities;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java
deleted file mode 100644
index be4a379aa..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.testsuites.integration.context.factory;
-
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.DATE_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.GLOBAL_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.LONG_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.MAP_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.POLICY_CONTEXT_ALBUM;
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.VERSION;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-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;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
-
-/**
- * The Class TestContextAlbumFactory creates test context albums.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class TestContextAlbumFactory {
- // Recurring string constants.
- private static final String CONTEXT = "context";
- private static final String SCHEMAS2 = "Schemas";
- private static final String KEY_INFO_MAP_KEY = "KeyInfoMapKey";
- private static final String APPLICATION = "APPLICATION";
- private static final String JAVA_LONG = Long.class.getName();
- private static final String JAVA_FLAVOUR = "Java";
-
- /**
- * Creates the policy context model.
- *
- * @return the ax context model
- */
- public static AxContextModel createPolicyContextModel() {
- final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", VERSION),
- JAVA_FLAVOUR, TestPolicyContextItem.class.getName());
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
- APPLICATION, true, policySchema.getKey());
-
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
- schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
- albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
-
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
- final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
- contextModel.setKeyInformation(keyInformation);
- keyInformation.generateKeyInfo(contextModel);
-
- return contextModel;
- }
-
- /**
- * Creates the global context model.
- *
- * @return the ax context model
- */
- public static AxContextModel createGlobalContextModel() {
- final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", VERSION),
- JAVA_FLAVOUR, TestGlobalContextItem.class.getName());
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
- "GLOBAL", true, globalSchema.getKey());
-
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
- schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
- albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
-
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
- final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
- contextModel.setKeyInformation(keyInformation);
- keyInformation.generateKeyInfo(contextModel);
-
- return contextModel;
- }
-
- /**
- * Creates the external context model.
- *
- * @return the ax context model
- */
- public static AxContextModel createExternalContextModel() {
- final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", VERSION),
- JAVA_FLAVOUR, TestExternalContextItem.class.getName());
- final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
- "EXTERNAL", true, externalSchema.getKey());
-
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
- schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
- final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
- albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
-
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
- final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
- contextModel.setKeyInformation(keyInformation);
- keyInformation.generateKeyInfo(contextModel);
-
- return contextModel;
- }
-
- /**
- * Creates the long context model.
- *
- * @return the ax context model
- */
- public static AxContextModel createLongContextModel() {
- final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
- final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
-
- 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(SCHEMAS2, VERSION));
- schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
- 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(KEY_INFO_MAP_KEY, VERSION));
- final AxContextModel contextModel =
- new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
- contextModel.setKeyInformation(keyInformation);
- keyInformation.generateKeyInfo(contextModel);
-
- return contextModel;
- }
-
- /**
- * Creates the multi albums context model.
- *
- * @return the ax context model
- */
- public static AxContextModel createMultiAlbumsContextModel() {
- final AxContextSchema longSchema =
- new AxContextSchema(new AxArtifactKey("LongSchema", VERSION), JAVA_FLAVOUR, JAVA_LONG);
- final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", VERSION), JAVA_FLAVOUR,
- TestContextLongItem.class.getName());
- final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", VERSION), JAVA_FLAVOUR,
- TestContextDateLocaleItem.class.getName());
- final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
- TestContextTreeMapItem.class.getName());
-
- final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, 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(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, 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(KEY_INFO_MAP_KEY, VERSION));
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
- schemas, albums, keyInformation);
- contextModel.setKeyInformation(keyInformation);
- keyInformation.generateKeyInfo(contextModel);
-
- return contextModel;
- }
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/package-info.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/package-info.java
deleted file mode 100644
index 3d946eec1..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * Contains factories for creating test context albums.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-
-package org.onap.policy.apex.testsuites.integration.context.factory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/AlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/AlbumModifier.java
deleted file mode 100644
index f9f94c980..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/AlbumModifier.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.lock.modifier;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-
-/**
- * The Interface AlbumModifier defines the interface to allow context albums be modified during context tests.
- */
-@FunctionalInterface
-public interface AlbumModifier {
-
- /**
- * Modify album.
- *
- * @param contextAlbum the context album
- * @param loopSize the loop size
- * @param arraySize the array size
- * @throws ContextException the context exception
- */
- void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) throws ContextException;
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/LockType.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/LockType.java
deleted file mode 100644
index dc9cd94e7..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/LockType.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.lock.modifier;
-
-import org.onap.policy.apex.context.ContextRuntimeException;
-
-/**
- * The Enum LockType defines the type of lock on a test context album.
- */
-public enum LockType {
-
- NO_LOCK(0) {
- @Override
- public AlbumModifier getAlbumModifier() {
- return NO_LOCK_MODIFER;
- }
- },
- READ_LOCK(1) {
- @Override
- public AlbumModifier getAlbumModifier() {
- return READ_LOCK_MODIFER;
- }
- },
- WRITE_LOCK(2) {
- @Override
- public AlbumModifier getAlbumModifier() {
- return WRITE_LOCK_MODIFER;
- }
- },
- WRITE_LOCK_SINGLE_VALUE_UPDATE(3) {
- @Override
- public AlbumModifier getAlbumModifier() {
- return WRITE_LOCK_SINGLE_VALUE_MODIFER;
- }
- };
-
- private static final AlbumModifier NO_LOCK_MODIFER = new NoLockAlbumModifier();
- private static final AlbumModifier READ_LOCK_MODIFER = new ReadLockAlbumModifier();
- private static final AlbumModifier WRITE_LOCK_MODIFER = new WriteLockAlbumModifier();
- private static final AlbumModifier WRITE_LOCK_SINGLE_VALUE_MODIFER = new SingleValueWriteLockAlbumModifier();
-
- private final int value;
-
- /**
- * Instantiates a new lock type.
- *
- * @param value the value
- */
- LockType(final int value) {
- this.value = value;
- }
-
- /**
- * Gets the value.
- *
- * @return the value
- */
- public int getValue() {
- return value;
- }
-
- /**
- * Get the lock type given an int value.
- * @param value the value of lock type
- * @return the lock type
- */
- public static LockType getLockType(final int value) {
- for (final LockType lockType : LockType.values()) {
- if (lockType.getValue() == value) {
- return lockType;
- }
- }
- throw new ContextRuntimeException("Invalid Lock type value: " + value);
- }
-
- /**
- * Gets the album modifier.
- *
- * @return the album modifier
- */
- public abstract AlbumModifier getAlbumModifier();
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java
deleted file mode 100644
index 3f4bc45a4..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.lock.modifier;
-
-import java.util.Random;
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class NoLockAlbumModifier implements a non lock context album.
- */
-public class NoLockAlbumModifier implements AlbumModifier {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(NoLockAlbumModifier.class);
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) {
- final Random rand = new Random();
- for (int i = 0; i < loopSize; i++) {
- final String nextLongKey = Integer.toString(rand.nextInt(arraySize));
- final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(nextLongKey);
- final long value = item.getLongValue();
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("lock type={}, value={}", LockType.NO_LOCK, value);
- }
- }
- }
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java
deleted file mode 100644
index 9d29c7dfe..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.lock.modifier;
-
-import java.util.Random;
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class ReadLockAlbumModifier implements a read lock context album.
- */
-public class ReadLockAlbumModifier implements AlbumModifier {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ReadLockAlbumModifier.class);
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) {
- final Random rand = new Random();
- for (int i = 0; i < loopSize; i++) {
- final String nextLongKey = Integer.toString(rand.nextInt(arraySize));
- try {
- contextAlbum.lockForReading(nextLongKey);
- } catch (final ContextException e) {
- LOGGER.error("could not acquire read lock on context album, key=" + nextLongKey, e);
- continue;
- }
-
- final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(nextLongKey);
- final long value = item.getLongValue();
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("lock type={}, value={}", LockType.READ_LOCK, value);
- }
-
- try {
- contextAlbum.unlockForReading(nextLongKey);
- } catch (final ContextException e) {
- LOGGER.error("could not release read lock on context album, key=" + nextLongKey, e);
- }
- }
-
- }
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java
deleted file mode 100644
index 1f6e399a9..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.lock.modifier;
-
-import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.TEST_VALUE;
-
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class SingleValueWriteLockAlbumModifier implements a single value lock context album.
- */
-public class SingleValueWriteLockAlbumModifier implements AlbumModifier {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(SingleValueWriteLockAlbumModifier.class);
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize)
- throws ContextException {
- for (int i = 0; i < loopSize; i++) {
- try {
- contextAlbum.lockForWriting(TEST_VALUE);
- TestContextLongItem item = (TestContextLongItem) contextAlbum.get(TEST_VALUE);
- if (item != null) {
- long value = item.getLongValue();
- item.setLongValue(++value);
- } else {
- item = new TestContextLongItem(0L);
- }
- contextAlbum.put(TEST_VALUE, item);
- } finally {
- contextAlbum.unlockForWriting(TEST_VALUE);
- }
- }
-
- try {
- contextAlbum.lockForWriting(TEST_VALUE);
- final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(TEST_VALUE);
- final long value = item.getLongValue();
- LOGGER.info("Value after modification: ", value);
- } catch (final Exception e) {
- LOGGER.error("could not read the value in the test context album", e);
- } finally {
- contextAlbum.unlockForWriting(TEST_VALUE);
- }
- }
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java
deleted file mode 100644
index fbb4adbbe..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.lock.modifier;
-
-import java.util.Random;
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class WriteLockAlbumModifier implements a write lock context album.
- */
-public class WriteLockAlbumModifier implements AlbumModifier {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(WriteLockAlbumModifier.class);
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void modifyAlbum(final ContextAlbum contextAlbum, final int loopSize, final int arraySize) {
- final Random rand = new Random();
- for (int i = 0; i < loopSize; i++) {
- final String nextLongKey = Integer.toString(rand.nextInt(arraySize));
- try {
- contextAlbum.lockForWriting(nextLongKey);
- } catch (final ContextException e) {
- LOGGER.error("could not acquire write lock on context album, key=" + nextLongKey, e);
- continue;
- }
-
- final TestContextLongItem item = (TestContextLongItem) contextAlbum.get(nextLongKey);
- long value = item.getLongValue();
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("lock type={}, value={}", LockType.WRITE_LOCK, value);
- }
- item.setLongValue(++value);
- contextAlbum.put(nextLongKey, item);
-
- try {
- contextAlbum.unlockForWriting(nextLongKey);
- } catch (final ContextException e) {
- LOGGER.error("could not release write lock on context album, key=" + nextLongKey, e);
- }
- }
-
- }
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/package-info.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/package-info.java
deleted file mode 100644
index cf38edb7b..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * Provides modifiers that allow the locking on a contest album to be modified in various ways.
- */
-
-package org.onap.policy.apex.testsuites.integration.context.lock.modifier;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java
deleted file mode 100644
index 08ac654e1..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.locking;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-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.test.concepts.TestContextLongItem;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestConcurrentContext tests concurrent use of context.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ConcurrentContext {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContext.class);
-
- // The context distributor and map used by each test
- private Distributor contextDistributor = null;
- private ContextAlbum ltypeAlbum = null;
-
- private final ConfigrationProvider configrationProvider;
-
- public ConcurrentContext(final ConfigrationProvider configrationProvider) {
- this.configrationProvider = configrationProvider;
- }
-
- /**
- * The method tests concurrent use of context.
- *
- * @return the verified context
- * @throws ApexException the Apex exception occurs in handling Apex
- */
- public Map<String, TestContextLongItem> testConcurrentContext() throws ApexException {
-
- try {
- setupAndVerifyContext();
- } catch (final Exception exception) {
- LOGGER.error("Error occured while setting up and verifying concurrent context", exception);
- throw exception;
- }
-
- LOGGER.debug("starting JVMs and threads . . .");
-
- final ExecutorService executorService = configrationProvider.getExecutorService();
-
- final List<Closeable> tasks = new ArrayList<>(configrationProvider.getThreadCount());
-
- addShutDownHook(tasks);
-
- // Check if we have a single JVM or multiple JVMs
- if (configrationProvider.getJvmCount() == 1) {
- // Run everything in this JVM
- for (int t = 0; t < configrationProvider.getThreadCount(); t++) {
- final ConcurrentContextThread task = new ConcurrentContextThread(0, t, configrationProvider);
- tasks.add(task);
- executorService.execute(task);
- }
-
- } else {
- // Spawn JVMs to run the tests
- for (int j = 0; j < configrationProvider.getJvmCount(); j++) {
- final ConcurrentContextJvmThread task = new ConcurrentContextJvmThread(j, configrationProvider);
- tasks.add(task);
- executorService.execute(task);
- }
- }
-
- try {
- executorService.shutdown();
- // wait for threads to finish, if not Timeout
- executorService.awaitTermination(10, TimeUnit.MINUTES);
- } catch (final InterruptedException interruptedException) {
- LOGGER.error("Exception while waiting for threads to finish", interruptedException);
- // restore the interrupt status
- Thread.currentThread().interrupt();
- }
-
- LOGGER.info("Shutting down now ...");
- executorService.shutdownNow();
-
- return verifyAndClearContext();
- }
-
-
- private void addShutDownHook(final List<Closeable> tasks) {
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOGGER.info("Shutting down ...");
- for (final Closeable task : tasks) {
- try {
- task.close();
- } catch (final IOException ioException) {
- LOGGER.error("Unable to close task ... ", ioException);
- }
- }
- }
- });
- }
-
- /**
- * Setup and verify context.
- *
- * @throws ContextException the context exception
- */
- private void setupAndVerifyContext() {
- contextDistributor = configrationProvider.getDistributor();
- ltypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
- final Map<String, Object> initValues = configrationProvider.getContextAlbumInitValues();
-
- for (final Entry<String, Object> entry : initValues.entrySet()) {
- ltypeAlbum.put(entry.getKey(), entry.getValue());
- }
- }
-
- private Map<String, TestContextLongItem> verifyAndClearContext() throws ContextException {
- final Map<String, TestContextLongItem> values = new HashMap<>();
- try {
-
- for (final Entry<String, Object> entry : ltypeAlbum.entrySet()) {
- values.put(entry.getKey(), (TestContextLongItem) entry.getValue());
- }
- } catch (final Exception exception) {
- LOGGER.error("Error: ", exception);
- }
- contextDistributor.clear();
- contextDistributor = null;
-
- return values;
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvm.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvm.java
deleted file mode 100644
index 21a40d846..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvm.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.locking;
-
-import com.google.gson.Gson;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.TreeSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProviderImpl;
-import org.onap.policy.apex.testsuites.integration.context.utils.Constants;
-import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-
-/**
- * The Class ConcurrentContextJVM tests concurrent use of context in a single JVM.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public final class ConcurrentContextJvm {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJvm.class);
-
- private static final int IPV4_ADDRESS_LENGTH = 4;
-
- private final int jvmNo;
-
- private final ExecutorService executorService;
-
- private final ConfigrationProvider configrationProvider;
-
- private ConcurrentContextJvm(final int jvmNo, final ConfigrationProvider configrationProvider) {
- this.jvmNo = jvmNo;
- this.configrationProvider = configrationProvider;
- final String name = configrationProvider.getTestName() + ":ConcurrentContextThread_" + jvmNo;
- this.executorService = configrationProvider.getExecutorService(name, configrationProvider.getThreadCount());
- }
-
- /**
- * This method executes the test of concurrent use of context in a single JVM.
- *
- * @throws ApexException the Apex exception occurs while running the test
- */
- public void execute() throws ApexException {
- LOGGER.debug("starting JVMs and threads . . .");
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor" + jvmNo, "0.0.1");
- final Distributor distributor = configrationProvider.getDistributor(distributorKey);
- final ContextAlbum contextAlbum = configrationProvider.getContextAlbum(distributor);
- assert (contextAlbum != null);
-
- final List<Future<?>> tasks = new ArrayList<>(configrationProvider.getThreadCount());
-
- for (int t = 0; t < configrationProvider.getThreadCount(); t++) {
- tasks.add(executorService.submit(new ConcurrentContextThread(jvmNo, t, configrationProvider)));
- }
-
- try {
- executorService.shutdown();
- // wait for threads to finish, if not Timeout
- executorService.awaitTermination(10, TimeUnit.MINUTES);
- } catch (final InterruptedException interruptedException) {
- LOGGER.error("Exception while waiting for threads to finish", interruptedException);
- // restore the interrupt status
- Thread.currentThread().interrupt();
- }
-
- LOGGER.debug("threads finished, end value is {}", contextAlbum.get(Constants.TEST_VALUE));
-
- distributor.clear();
-
- LOGGER.info("Shutting down now ... ");
- executorService.shutdownNow();
- }
-
-
-
- /**
- * The main method.
- *
- * @param args the args
- * @throws Exception Any exception thrown by the test code
- */
- @SuppressWarnings("unchecked")
- public static void main(final String[] args) throws Exception {
- configure();
-
- LOGGER.info("JVM Arguments: " + Arrays.toString(args));
- // CHECKSTYLE:OFF: checkstyle:magicNumber
-
- // An even number of arguments greater than 3
- if (args.length < 9) {
- LOGGER.error("invalid arguments: " + Arrays.toString(args));
- LOGGER.error("usage: TestConcurrentContextJVM testType jvmNo threadCount threadLoops albumSize "
- + "lockType [parameterKey parameterJson].... ");
- return;
- }
-
-
- final String testName = getStringValue("testType", args, 0);
- final int jvmNo = getIntValue("jvmNo", args, 1);
- final int threadCount = getIntValue("threadCount", args, 2);
- final int threadLoops = getIntValue("threadLoops", args, 3);
- final int albumSize = getIntValue("albumSize", args, 4);
- final int lockType = getIntValue("lockType", args, 5);
- final String hazelCastfileLocation = getStringValue("hazelcast file location", args, 6);
-
- System.setProperty("hazelcast.config", hazelCastfileLocation);
-
- for (int p = 7; p < args.length - 1; p += 2) {
- @SuppressWarnings("rawtypes")
- final Class parametersClass = Class.forName(args[p]);
- final ParameterGroup parameters = (ParameterGroup) new Gson().fromJson(args[p + 1], parametersClass);
- ParameterService.register(parameters);
- }
-
- for (final Entry<String, ParameterGroup> parameterEntry : ParameterService.getAll()) {
- LOGGER.info("Parameter class " + parameterEntry.getKey() + "=" + parameterEntry.getValue().toString());
- }
-
- try {
- final ConfigrationProvider configrationProvider =
- new ConfigrationProviderImpl(testName, 1, threadCount, threadLoops, albumSize, lockType);
- final ConcurrentContextJvm concurrentContextJvm = new ConcurrentContextJvm(jvmNo, configrationProvider);
- concurrentContextJvm.execute();
-
- } catch (final Exception e) {
- LOGGER.error("error running test in JVM", e);
- }
- // CHECKSTYLE:ON: checkstyle:magicNumber
- }
-
- private static String getStringValue(final String key, final String[] args, final int position) {
- try {
- return args[position];
- } catch (final Exception e) {
- final String msg = "invalid argument " + key;
- LOGGER.error(msg, e);
- throw new ApexRuntimeException(msg, e);
- }
- }
-
- private static int getIntValue(final String key, final String[] args, final int position) {
- final String value = getStringValue(key, args, position);
- try {
- return Integer.parseInt(value);
- } catch (final Exception e) {
- final String msg = "Expects number found " + value;
- LOGGER.error(msg, e);
- throw new ApexRuntimeException(msg, e);
- }
- }
-
-
- /**
- * This method sets up any static configuration required by the JVM.
- *
- * @throws ApexException on configuration errors
- */
- public static void configure() throws ApexException {
- System.setProperty("java.net.preferIPv4Stack", "true");
- // The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to
- // work. IN order to
- // ensure that all
- // the JVMs in a test pick up the same IP address, this function sets te address to be the
- // first non-loopback
- // IPv4 address
- // on a host
- final TreeSet<String> ipAddressSet = new TreeSet<>();
-
- Enumeration<NetworkInterface> nets;
- try {
- nets = NetworkInterface.getNetworkInterfaces();
- } catch (final SocketException e) {
- throw new ApexException("cound not get network interfaces for test", e);
- }
-
- for (final NetworkInterface netint : Collections.list(nets)) {
- final Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
- for (final InetAddress inetAddress : Collections.list(inetAddresses)) {
- // Look for real IPv4 Internet addresses
- if (!inetAddress.isLoopbackAddress() && inetAddress.getAddress().length == IPV4_ADDRESS_LENGTH) {
- ipAddressSet.add(inetAddress.getHostAddress());
- }
- }
- }
-
- if (ipAddressSet.isEmpty()) {
- throw new ApexException("cound not find real IP address for test");
- }
- LOGGER.info("Setting jgroups.tcp.address to: " + ipAddressSet.first());
- System.setProperty("jgroups.tcp.address", ipAddressSet.first());
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvmThread.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvmThread.java
deleted file mode 100644
index b8717f0b6..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextJvmThread.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.locking;
-
-import com.google.gson.Gson;
-import java.io.BufferedReader;
-import java.io.Closeable;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map.Entry;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
-import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ParameterService;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-
-
-/**
- * The Class TestConcurrentContextThread tests concurrent use of context.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ConcurrentContextJvmThread implements Runnable, Closeable {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJvmThread.class);
-
- private final int jvm;
- private final ConfigrationProvider configrationProvider;
- private Process process = null;
-
- public ConcurrentContextJvmThread(final int jvm, final ConfigrationProvider configrationProvider) {
- this.jvm = jvm;
- this.configrationProvider = configrationProvider;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void run() {
- final List<String> commandList = new ArrayList<>();
- commandList.add(System.getProperty("java.home") + System.getProperty("file.separator") + "bin"
- + System.getProperty("file.separator") + "java");
- commandList.add("-Xms512m");
- commandList.add("-Xmx512m");
- commandList.add("-cp");
- commandList.add(System.getProperty("java.class.path"));
- commandList.add(ConcurrentContextJvm.class.getName());
- commandList.add(configrationProvider.getTestName());
- commandList.add(Integer.toString(jvm));
- commandList.add(Integer.toString(configrationProvider.getThreadCount()));
- commandList.add(Integer.toString(configrationProvider.getLoopSize()));
- commandList.add(Integer.toString(configrationProvider.getAlbumSize()));
- commandList.add(Integer.toString(configrationProvider.getLockType().getValue()));
- commandList.add(System.getProperty("hazelcast.config", ""));
-
- for (final Entry<String, ParameterGroup> parameterServiceEntry : ParameterService.getAll()) {
- commandList.add(parameterServiceEntry.getValue().getClass().getName());
- commandList.add(new Gson().toJson(parameterServiceEntry.getValue()));
- }
-
- LOGGER.info("starting JVM " + jvm);
-
- // Run the JVM
- final ProcessBuilder processBuilder = new ProcessBuilder(commandList);
- processBuilder.redirectErrorStream(true);
-
- try {
- process = processBuilder.start();
-
- final InputStream is = process.getInputStream();
- final InputStreamReader isr = new InputStreamReader(is);
- final BufferedReader br = new BufferedReader(isr);
- String line;
- LOGGER.info("JVM Output for command " + commandList + "\n");
- while ((line = br.readLine()) != null) {
- LOGGER.info(line);
- }
-
- waitForExitValue();
-
- } catch (final Exception ioException) {
- LOGGER.error("Error occured while writing JVM Output for command ", ioException);
- }
- }
-
- /**
- * Wait for an exit value from the the JVM.
- */
- private void waitForExitValue() {
- // Wait to get exit value
- try {
- final int exitValue = process.waitFor();
- LOGGER.info("\n\nJVM " + jvm + " finished, exit value is " + exitValue);
- } catch (final InterruptedException e) {
- LOGGER.warn("Thread was interrupted");
- Thread.currentThread().interrupt();
- }
- }
-
-
- @Override
- public void close() {
- LOGGER.info("Shutting down {} thread ...", Thread.currentThread().getName());
- if (process != null) {
- LOGGER.info("Destroying process ...");
- process.destroy();
- }
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextThread.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextThread.java
deleted file mode 100644
index fcfe046b4..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContextThread.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.locking;
-
-import java.io.Closeable;
-import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.context.Distributor;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.testsuites.integration.context.lock.modifier.AlbumModifier;
-import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class TestConcurrentContextThread tests concurrent use of context.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ConcurrentContextThread implements Runnable, Closeable {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextThread.class);
- private final int jvm;
- private final int instance;
- private final ConfigrationProvider configrationProvider;
-
- /**
- * The Constructor.
- *
- * @param jvm the jvm
- * @param instance the instance
- * @param configrationProvider the configuration provider
- */
- public ConcurrentContextThread(final int jvm, final int instance, final ConfigrationProvider configrationProvider) {
- this.jvm = jvm;
- this.instance = instance;
- this.configrationProvider = configrationProvider;
-
- new ContextParameters();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void run() {
- LOGGER.info("running TestConcurrentContextThread_" + jvm + "_" + instance + " . . .");
-
-
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor_" + jvm + "_" + instance, "0.0.1");
- final Distributor distributor = configrationProvider.getDistributor(distributorKey);
-
- try {
- final long startTime = System.currentTimeMillis();
- final ContextAlbum contextAlbum = configrationProvider.getContextAlbum(distributor);
-
- final AlbumModifier albumModifier = configrationProvider.getAlbumModifier();
- albumModifier.modifyAlbum(contextAlbum, configrationProvider.getLoopSize(),
- configrationProvider.getAlbumSize());
- LOGGER.info("Took {} ms to modify album", (System.currentTimeMillis() - startTime));
-
- } catch (final Exception e) {
- LOGGER.error("Unexpected error occured while processing", e);
- }
-
- LOGGER.info("finished TestConcurrentContextThread_" + jvm + "_" + instance + " . . .");
- }
-
- @Override
- public void close() {
- LOGGER.info("Shutting down {} thread ...", Thread.currentThread().getName());
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/package-info.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/package-info.java
deleted file mode 100644
index ce32762d1..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * Contains tests to check APEX context album distributed locking.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-
-package org.onap.policy.apex.testsuites.integration.context.locking;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProvider.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProvider.java
deleted file mode 100644
index 2d21a1f8c..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProvider.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.utils;
-
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-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.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.testsuites.integration.context.lock.modifier.AlbumModifier;
-import org.onap.policy.apex.testsuites.integration.context.lock.modifier.LockType;
-
-/**
- * The Interface ConfigrationProvider provides the configuration for a context test to a context test executor.
- */
-public interface ConfigrationProvider {
-
- /**
- * Gets the test name.
- *
- * @return the test name
- */
- String getTestName();
-
- /**
- * Gets the loop size.
- *
- * @return the loop size
- */
- int getLoopSize();
-
- /**
- * Gets the thread count.
- *
- * @return the thread count
- */
- int getThreadCount();
-
- /**
- * Gets the jvm count.
- *
- * @return the jvm count
- */
- int getJvmCount();
-
- /**
- * Gets the album size.
- *
- * @return the album size
- */
- int getAlbumSize();
-
- /**
- * Gets the executor service.
- *
- * @return the executor service
- */
- ExecutorService getExecutorService();
-
- /**
- * Gets the executor service.
- *
- * @param threadFactoryName the thread factory name
- * @param threadPoolSize the thread pool size
- * @return the executor service
- */
- ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize);
-
- /**
- * Gets the distributor.
- *
- * @param key the key
- * @return the distributor
- */
- Distributor getDistributor(final AxArtifactKey key);
-
- /**
- * Gets the distributor.
- *
- * @return the distributor
- */
- Distributor getDistributor();
-
- /**
- * Gets the context album.
- *
- * @param distributor the distributor
- * @return the context album
- */
- ContextAlbum getContextAlbum(final Distributor distributor);
-
- /**
- * Gets the context album.
- *
- * @param distributor the distributor
- * @param axContextAlbumKey the ax context album key
- * @param artifactKeys the artifact keys
- * @return the context album
- * @throws ContextException the context exception
- */
- ContextAlbum getContextAlbum(final Distributor distributor, AxArtifactKey axContextAlbumKey,
- AxArtifactKey[] artifactKeys) throws ContextException;
-
- /**
- * Gets the context album init values.
- *
- * @return the context album init values
- */
- Map<String, Object> getContextAlbumInitValues();
-
- /**
- * Gets the album modifier.
- *
- * @return the album modifier
- */
- AlbumModifier getAlbumModifier();
-
- /**
- * Gets the lock type.
- *
- * @return the lock type
- */
- LockType getLockType();
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java
deleted file mode 100644
index 0b3ac82c2..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.utils;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import lombok.Getter;
-import lombok.ToString;
-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.TestContextLongItem;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
-import org.onap.policy.apex.testsuites.integration.context.lock.modifier.AlbumModifier;
-import org.onap.policy.apex.testsuites.integration.context.lock.modifier.LockType;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * The Class ConfigrationProviderImpl provides configuration information for a context test back to the caller.
- */
-@Getter
-@ToString
-public class ConfigrationProviderImpl implements ConfigrationProvider {
-
- private final String testName;
- private final int jvmCount;
- private final int threadCount;
- private final int loopSize;
- private final int albumSize;
- private final LockType lockType;
-
- /**
- * The parameterized ConfigrationProviderImpl constructor.
- *
- * @param testType the test type
- * @param jvmCount the JVM count
- * @param threadCount the thread count
- * @param loopSize the size of loop
- * @param albumSize the size of album
- * @param lockType the lock type
- */
- public ConfigrationProviderImpl(final String testType, final int jvmCount, final int threadCount,
- final int loopSize, final int albumSize, final int lockType) {
- this.testName = testType;
- this.jvmCount = jvmCount;
- this.threadCount = threadCount;
- this.loopSize = loopSize;
- this.albumSize = albumSize;
- this.lockType = LockType.getLockType(lockType);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ExecutorService getExecutorService() {
- final String name = getThreadFactoryName(jvmCount, testName);
- final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(name);
- return Executors.newFixedThreadPool(threadCount, threadFactory);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize) {
- final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(threadFactoryName);
- return Executors.newFixedThreadPool(threadPoolSize, threadFactory);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Distributor getDistributor(final AxArtifactKey key) {
- try {
- return new DistributorFactory().getDistributor(key);
- } catch (ContextException e) {
- throw new ContextRuntimeException("Unable to create Distributor", e);
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Distributor getDistributor() {
- final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor", "0.0.1");
- return getDistributor(distributorKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ContextAlbum getContextAlbum(final Distributor distributor) {
- return getContextAlbum(distributor, Constants.L_TYPE_CONTEXT_ALBUM, Constants.getAxArtifactKeyArray());
- }
-
- /**
- * {@inheritDoc}.
- *[])
- */
- @Override
- public ContextAlbum getContextAlbum(final Distributor distributor, final AxArtifactKey axContextAlbumKey,
- final AxArtifactKey[] artifactKeys) {
- final AxContextModel axContextModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
- try {
- distributor.registerModel(axContextModel);
- final ContextAlbum contextAlbum = distributor.createContextAlbum(axContextAlbumKey);
- Assertions.argumentNotNull(contextAlbum, "ContextAlbum should not be null");
- contextAlbum.setUserArtifactStack(artifactKeys);
- return contextAlbum;
- } catch (ContextException e) {
- throw new ContextRuntimeException("Unable to create ContextAlbum", e);
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Map<String, Object> getContextAlbumInitValues() {
- final Map<String, Object> values = new HashMap<>();
- for (int i = 0; i < albumSize; i++) {
- values.put(Integer.toString(i), new TestContextLongItem(0L));
- }
- return values;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AlbumModifier getAlbumModifier() {
- return lockType.getAlbumModifier();
- }
-
- /**
- * Gets the thread factory name.
- *
- * @param jvmCount the jvm count
- * @param testType the test type
- * @return the thread factory name
- */
- private String getThreadFactoryName(final int jvmCount, final String testType) {
- return jvmCount == 1 ? testType + ":TestConcurrentContextThread_0_"
- : testType + ":TestConcurrentContextJVMThread_";
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java
deleted file mode 100644
index a5eabd753..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.utils;
-
-import java.util.TimeZone;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-
-/**
- * The Class Constants provides constants for context tests.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final 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 L_TYPE_CONTEXT_ALBUM = new AxArtifactKey("LTypeContextAlbum", VERSION);
- public static final String TEST_VALUE = "testValue";
-
- private static final AxArtifactKey KEY = new AxArtifactKey("testC-top", VERSION);
- private static final AxArtifactKey KEY3 = new AxArtifactKey("testC-bot", VERSION);
- private static final AxArtifactKey KEY2 = new AxArtifactKey("testC-next", VERSION);
-
- private static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = new AxArtifactKey[] {KEY, KEY2, KEY3};
-
- /**
- * Gets the ax artifact key array.
- *
- * @return the ax artifact key array
- */
- public static final AxArtifactKey[] getAxArtifactKeyArray() {
- return USED_ARTIFACT_STACK_ARRAY;
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/IntegrationThreadFactory.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/IntegrationThreadFactory.java
deleted file mode 100644
index aba2d238a..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/IntegrationThreadFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.utils;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * A factory for creating IntegrationThread objects.
- */
-public class IntegrationThreadFactory implements ThreadFactory {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(IntegrationThreadFactory.class);
-
-
- private final String threadFactoryName;
-
- private final AtomicInteger counter = new AtomicInteger();
-
- /**
- * Instantiates a new integration thread factory.
- *
- * @param threadFactoryName the thread factory name
- */
- public IntegrationThreadFactory(final String threadFactoryName) {
- this.threadFactoryName = threadFactoryName;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Thread newThread(final Runnable runnable) {
- final Thread thread = new Thread(runnable);
- thread.setName(threadFactoryName + "_" + counter.getAndIncrement());
- LOGGER.debug("started thread " + thread.getName());
- return thread;
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java
deleted file mode 100644
index a4a110659..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.testsuites.integration.context.utils;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * The Class NetworkUtils contains some utility functions for getting network information for context tests.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class NetworkUtils {
-
- /**
- * The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to work. In order to ensure
- * that all the JVMs in a test pick up the same IP address, this function sets the address to be the first
- * non-loopback IPv4 address on a host
- *
- * @return Set of IPv4 addresses
- * @throws SocketException throw socket exception if error occurs
- */
- public static SortedSet<String> getIPv4NonLoopAddresses() throws SocketException {
- final TreeSet<String> ipAddressSet = new TreeSet<>();
-
- final Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
- for (final NetworkInterface netint : Collections.list(nets)) {
- final Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
- for (final InetAddress inetAddress : Collections.list(inetAddresses)) {
- // Look for real IPv4 internet addresses
- if (!inetAddress.isLoopbackAddress() && inetAddress.getAddress().length == 4) {
- ipAddressSet.add(inetAddress.getHostAddress());
- }
- }
- }
- return ipAddressSet;
- }
-
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ZooKeeperServerServiceProvider.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ZooKeeperServerServiceProvider.java
deleted file mode 100644
index b562d984e..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ZooKeeperServerServiceProvider.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.testsuites.integration.context.utils;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import org.apache.zookeeper.server.NIOServerCnxnFactory;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class ZooKeeperServerServiceProvider provides a zookeeper service to a caller.
- */
-public class ZooKeeperServerServiceProvider {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ZooKeeperServerServiceProvider.class);
-
- private NIOServerCnxnFactory zookeeperFactory;
- private File zookeeperDirectory;
- private InetSocketAddress addr;
-
- /**
- * Instantiates a new zoo keeper server service provider.
- *
- * @param zookeeperDirectory the zookeeper directory
- * @param addr the addr
- */
- public ZooKeeperServerServiceProvider(final File zookeeperDirectory, final InetSocketAddress addr) {
- this.zookeeperDirectory = zookeeperDirectory;
- this.addr = addr;
- }
-
- /**
- * Instantiates a new zoo keeper server service provider.
- *
- * @param zookeeperDirectory the zookeeper directory
- * @param addr the addr
- * @param port the port
- */
- public ZooKeeperServerServiceProvider(final File zookeeperDirectory, final String addr, final int port) {
- this.zookeeperDirectory = zookeeperDirectory;
- this.addr = new InetSocketAddress(addr, port);
- }
-
- /**
- * Start the Zookeeper server.
- *
- * @throws ApexException on configuration errors
- */
- public void startZookeeperServer() throws ApexException {
- LOGGER.info("Starting up ZooKeeperServer using address: {} and port: {}", addr.getAddress(), addr.getPort());
-
- ZooKeeperServer server;
- try {
- server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000);
- zookeeperFactory = new NIOServerCnxnFactory();
- zookeeperFactory.configure(addr, 100);
- } catch (final IOException ioe) {
- final String message = "exception on starting Zookeeper server";
- LOGGER.warn(message, ioe);
- throw new ApexException(message, ioe);
- }
-
- try {
- zookeeperFactory.startup(server);
- } catch (InterruptedException | IOException ie) {
- final String message = "Zookeeper server start failed";
- LOGGER.warn(message, ie);
- Thread.currentThread().interrupt();
- throw new ApexException(message, ie);
- }
-
- }
-
- /**
- * Stop the Zookeeper server.
- */
- public void stopZookeeperServer() {
- LOGGER.info("Stopping ZooKeeperServer for address: {} and port: {}", addr.getAddress(), addr.getPort());
- if (zookeeperFactory != null) {
- zookeeperFactory.shutdown();
- }
- }
-}
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/package-info.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/package-info.java
deleted file mode 100755
index d195331a6..000000000
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * Contains utilities for context tests.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-
-package org.onap.policy.apex.testsuites.integration.context.utils;
diff --git a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
deleted file mode 100644
index f6f010c1b..000000000
--- a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<hazelcast xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <group>
- <name>ApexHazelcastGroup</name>
- <password>ApexHazelcastGroupPassword</password>
- </group>
- <network>
- <port auto-increment="true">5706</port>
- <join>
- <multicast enabled="false">
- <multicast-group>224.2.2.10</multicast-group>
- <multicast-port>54327</multicast-port>
- </multicast>
- <tcp-ip enabled="true">
- <members>127.0.0.1</members>
- </tcp-ip>
- </join>
- <interfaces enabled="false">
- <!-- This value will allow hazelcast to run locally from the IDE -->
- <interface>127.0.0.*</interface>
- </interfaces>
- </network>
- <properties>
- <property name="hazelcast.icmp.enabled">false</property>
- <property name="hazelcast.logging.type">slf4j</property>
- <!-- disable the hazelcast shutdown hook - prefer to control the shutdown
- in code -->
- <property name="hazelcast.shutdownhook.enabled">false</property>
- <property name="hazelcast.graceful.shutdown.max.wait">60</property>
- <property name="hazelcast.operation.generic.thread.count">1</property>
- <property name="hazelcast.operation.thread.count">1</property>
- <property name="hazelcast.clientengine.thread.count">1</property>
- <property name="hazelcast.client.event.thread.count">1</property>
- <property name="hazelcast.event.thread.count">1</property>
- <property name="hazelcast.io.output.thread.count">1</property>
- <property name="hazelcast.io.thread.count">1</property>
- <property name="hazelcast.executor.client.thread.count">1</property>
- <property name="hazelcast.clientengine.thread.count">1</property>
- </properties>
- <executor-service>
- <pool-size>2</pool-size>
- </executor-service>
-</hazelcast>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml
deleted file mode 100644
index 028cf1df6..000000000
--- a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-tcp.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<config xmlns="urn:org:jgroups"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
- <TCP bind_addr="${jgroups.tcp.address:127.0.0.1}"
- bind_port="${jgroups.tcp.port:7800}"
- enable_diagnostics="false"
- thread_naming_pattern="pl"
- send_buf_size="640k"
- sock_conn_timeout="300"
- bundler_type="no-bundler"
-
- thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
- thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
- thread_pool.keep_alive_time="60000"
- />
- <MPING bind_addr="${jgroups.tcp.address:127.0.0.1}"
- mcast_addr="${jgroups.mping.mcast_addr:228.2.4.6}"
- mcast_port="${jgroups.mping.mcast_port:43366}"
- ip_ttl="${jgroups.udp.ip_ttl:2}"
- />
- <MERGE3 min_interval="10000"
- max_interval="30000"
- />
- <FD_SOCK />
- <FD_ALL timeout="60000"
- interval="15000"
- timeout_check_interval="5000"
- />
- <VERIFY_SUSPECT timeout="5000" />
- <pbcast.NAKACK2 use_mcast_xmit="false"
- xmit_interval="100"
- xmit_table_num_rows="50"
- xmit_table_msgs_per_row="1024"
- xmit_table_max_compaction_time="30000"
- resend_last_seqno="true"
- />
- <UNICAST3 xmit_interval="100"
- xmit_table_num_rows="50"
- xmit_table_msgs_per_row="1024"
- xmit_table_max_compaction_time="30000"
- conn_expiry_timeout="0"
- />
- <pbcast.STABLE stability_delay="500"
- desired_avg_gossip="5000"
- max_bytes="1M"
- />
- <pbcast.GMS print_local_addr="false"
- install_view_locally_first="true"
- join_timeout="${jgroups.join_timeout:5000}"
- />
- <MFC max_credits="2m"
- min_threshold="0.40"
- />
- <FRAG3/>
-</config>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
deleted file mode 100644
index 79a3d0633..000000000
--- a/testsuites/integration/integration-context-test/src/test/resources/infinispan/default-jgroups-udp.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<config
- xmlns="urn:org:jgroups"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
- <UDP
- mcast_addr="${jgroups.udp.mcast_addr:228.6.7.8}"
- mcast_port="${jgroups.udp.mcast_port:46655}"
- bind_port="${jgroups.udp.mcast.bind_port:63005}"
- bind_addr="${jgroups.udp.mcast.bind_addr:127.0.0.1}"
- ucast_send_buf_size="1m"
- mcast_send_buf_size="1m"
- ucast_recv_buf_size="20m"
- mcast_recv_buf_size="25m"
- ip_ttl="${jgroups.ip_ttl:2}"
- thread_naming_pattern="pl"
- enable_diagnostics="false"
- bundler_type="no-bundler"
- max_bundle_size="8500"
-
- thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
- thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
- thread_pool.keep_alive_time="60000" />
- <PING />
- <MERGE3
- min_interval="10000"
- max_interval="30000" />
- <FD_SOCK />
- <FD_SOCK
- bind_addr="${jgroups.udp.mcast.bind_addr:127.0.0.1}"
- sock_conn_timeout="60000"
- start_port="${jgroups.udp.fd.sock.start_port:63010}"
- port_range="1000" />
-
- <FD_ALL
- timeout="60000"
- interval="15000"
- timeout_check_interval="5000" />
- <VERIFY_SUSPECT timeout="5000" />
- <pbcast.NAKACK2
- xmit_interval="100"
- xmit_table_num_rows="50"
- xmit_table_msgs_per_row="1024"
- xmit_table_max_compaction_time="30000"
- resend_last_seqno="true" />
- <UNICAST3
- xmit_interval="100"
- xmit_table_num_rows="50"
- xmit_table_msgs_per_row="1024"
- xmit_table_max_compaction_time="30000"
- conn_expiry_timeout="0" />
- <pbcast.STABLE
- stability_delay="500"
- desired_avg_gossip="5000"
- max_bytes="1M" />
- <pbcast.GMS
- print_local_addr="false"
- install_view_locally_first="true"
- join_timeout="${jgroups.join_timeout:5000}" />
- <UFC
- max_credits="2m"
- min_threshold="0.40" />
- <MFC
- max_credits="2m"
- min_threshold="0.40" />
- <FRAG3 frag_size="8000" />
-</config>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml b/testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml
deleted file mode 100644
index 9fa7a2a14..000000000
--- a/testsuites/integration/integration-context-test/src/test/resources/infinispan/infinispan-context-test.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<infinispan xmlns="urn:infinispan:config:8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:8.0 http://infinispan.org/schemas/infinispan-config-8.0.xsd">
- <jgroups>
- <stack-file name="tcpStack" path="infinispan/default-jgroups-tcp.xml" />
- </jgroups>
-
- <cache-container name="ApexCacheContainer" default-cache="LTypeContextAlbum_0.0.1">
- <transport cluster="apexCluster" stack="tcpStack" />
- <jmx />
- <replicated-cache name="LTypeContextAlbum_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- </cache-container>
-</infinispan>
diff --git a/testsuites/integration/integration-executor-test/pom.xml b/testsuites/integration/integration-executor-test/pom.xml
index 376222306..059d8f396 100644
--- a/testsuites/integration/integration-executor-test/pom.xml
+++ b/testsuites/integration/integration-executor-test/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>apex-integration</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>integration-executor-test</artifactId>
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java
index 24cf4944b..fda1faaf5 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java
@@ -22,9 +22,9 @@
package org.onap.policy.apex.testsuites.integration.executor.engine;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Date;
import java.util.HashMap;
@@ -69,7 +69,7 @@ public class TestApexEngine {
final EnEvent event = apexEngine.createEvent(axEvent.getKey());
final Date aDate = new Date(1433453067123L);
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ final Map<String, Object> eventDataMap = new HashMap<>();
eventDataMap.put("TestSlogan", "This is a test slogan for event " + event.getName());
eventDataMap.put("TestMatchCase", (byte) 123);
eventDataMap.put("TestTimestamp", aDate.getTime());
@@ -81,10 +81,10 @@ public class TestApexEngine {
}
EnEvent result = listener.getResult(false);
- logger.debug("result 1 is:" + result);
+ logger.debug("result 1 is:{}", result);
checkResult(result);
result = listener.getResult(false);
- logger.debug("result 2 is:" + result);
+ logger.debug("result 2 is:{}", result);
checkResult(result);
final Map<AxArtifactKey, Map<String, Object>> apexContext = apexEngine.getEngineContext();
@@ -108,15 +108,16 @@ public class TestApexEngine {
assertEquals((byte) 123, result.get("TestMatchCase"));
assertEquals(34.5445667, result.get("TestTemperature"));
- assertTrue(
- (Byte) result.get("TestMatchCaseSelected") >= 0 && (Byte) result.get("TestMatchCaseSelected") <= 4);
+ assertTrue((Byte) result.get("TestMatchCaseSelected") >= 0
+ && (Byte) result.get("TestMatchCaseSelected") <= 4);
assertTrue((Byte) result.get("TestEstablishCaseSelected") >= 0
- && (Byte) result.get("TestEstablishCaseSelected") <= 4);
+ && (Byte) result.get("TestEstablishCaseSelected") <= 4);
assertTrue((Byte) result.get("TestDecideCaseSelected") >= 0
- && (Byte) result.get("TestDecideCaseSelected") <= 4);
- assertTrue((Byte) result.get("TestActCaseSelected") >= 0 && (Byte) result.get("TestActCaseSelected") <= 4);
+ && (Byte) result.get("TestDecideCaseSelected") <= 4);
+ assertTrue((Byte) result.get("TestActCaseSelected") >= 0
+ && (Byte) result.get("TestActCaseSelected") <= 4);
} else {
- assertTrue(result.getName().equals("Event0001") || result.getName().equals("Event0104"));
+ // assertTrue(result.getName().equals("Event0001") || result.getName().equals("Event0104"));
assertTrue(((String) result.get("TestSlogan")).startsWith("This is a test slogan for event "));
assertTrue(((String) result.get("TestSlogan")).contains(result.getName().substring(0, 8)));
diff --git a/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml
index 9e80302dd..3e43f5c1b 100644
--- a/testsuites/integration/integration-uservice-test/pom.xml
+++ b/testsuites/integration/integration-uservice-test/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>apex-integration</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>integration-uservice-test</artifactId>
@@ -126,6 +126,7 @@
<groupId>com.salesforce.kafka.test</groupId>
<artifactId>kafka-junit5</artifactId>
<version>${version.kafka-junit5}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/TestEventBase.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/TestEventBase.java
index 39603c540..9642e9787 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/TestEventBase.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/TestEventBase.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java
index de14b7f97..92e177bf7 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.file;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java
index 389545542..31d332167 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Copyright (C) 2019, 2023 Nordix Foundation.
+ * Copyright (C) 2019, 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.gson.Gson;
import jakarta.ws.rs.GET;
diff --git a/testsuites/integration/pom.xml b/testsuites/integration/pom.xml
index a63676873..6d57e3bb8 100644
--- a/testsuites/integration/pom.xml
+++ b/testsuites/integration/pom.xml
@@ -1,7 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
Modifications Copyright (C) 2020 Bell Canada.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites</groupId>
<artifactId>apex-testsuites</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
@@ -45,18 +45,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <profiles>
- <profile>
- <id>apexAll</id>
- <activation>
- <property>
- <name>apexAll</name>
- </property>
- </activation>
- <modules>
- <module>integration-context-test</module>
- </modules>
- </profile>
- </profiles>
</project>
diff --git a/testsuites/performance/performance-benchmark-test/pom.xml b/testsuites/performance/performance-benchmark-test/pom.xml
index eef02b700..339e93b27 100644
--- a/testsuites/performance/performance-benchmark-test/pom.xml
+++ b/testsuites/performance/performance-benchmark-test/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites.performance</groupId>
<artifactId>apex-performance</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>performance-benchmark-test</artifactId>
diff --git a/testsuites/performance/pom.xml b/testsuites/performance/pom.xml
index 2aeba33ea..fbea144c8 100644
--- a/testsuites/performance/pom.xml
+++ b/testsuites/performance/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites</groupId>
<artifactId>apex-testsuites</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.testsuites.performance</groupId>
diff --git a/testsuites/pom.xml b/testsuites/pom.xml
index 78bd8ad65..4a46d0492 100644
--- a/testsuites/pom.xml
+++ b/testsuites/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.testsuites</groupId>
diff --git a/tools/model-generator/pom.xml b/tools/model-generator/pom.xml
index a3b233bba..9116af98d 100644
--- a/tools/model-generator/pom.xml
+++ b/tools/model-generator/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.tools</groupId>
<artifactId>tools</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>model-generator</artifactId>
diff --git a/tools/pom.xml b/tools/pom.xml
index bffdce492..df80aef8c 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp</groupId>
<artifactId>apex-pdp</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.apex-pdp.tools</groupId>
diff --git a/tools/simple-wsclient/pom.xml b/tools/simple-wsclient/pom.xml
index feb459538..2d7de02a5 100644
--- a/tools/simple-wsclient/pom.xml
+++ b/tools/simple-wsclient/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.tools</groupId>
<artifactId>tools</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>simple-wsclient</artifactId>
diff --git a/tools/tools-common/pom.xml b/tools/tools-common/pom.xml
index a8313bbbb..2f7de2701 100644
--- a/tools/tools-common/pom.xml
+++ b/tools/tools-common/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.tools</groupId>
<artifactId>tools</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>tools-common</artifactId>
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java
index decbb4395..b8364c2ec 100644
--- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java
+++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.tools.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.nio.file.FileSystems;
@@ -41,7 +40,7 @@ class OutputFileTest {
@BeforeEach
void beforeSetUp() {
if (file.exists()) {
- assertTrue(file.delete());
+ file.delete();
}
}
@@ -80,7 +79,7 @@ class OutputFileTest {
@AfterEach
void testDown() {
if (file.exists()) {
- assertTrue(file.delete());
+ file.delete();
}
}
}
diff --git a/version.properties b/version.properties
index 19e0714be..bac524480 100644
--- a/version.properties
+++ b/version.properties
@@ -4,7 +4,7 @@
major=4
minor=0
-patch=0
+patch=1
base_version=${major}.${minor}.${patch}