aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--context/context-management/pom.xml4
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java22
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java14
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java22
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java18
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java5
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java41
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java41
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java46
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java46
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java45
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java45
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java29
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java29
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java18
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java18
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java14
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java8
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java3
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java47
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java42
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java42
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java38
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java43
-rw-r--r--context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java41
-rw-r--r--core/core-engine/pom.xml4
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameterConstants.java (renamed from model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java)23
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java32
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java49
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java66
-rw-r--r--examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java52
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java53
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java53
-rw-r--r--examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java52
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java87
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java116
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java32
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java55
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java79
-rw-r--r--packages/apex-pdp-package-full/src/main/resources/infinispan/default-jgroups-tcp.xml76
-rw-r--r--packages/apex-pdp-package-full/src/main/resources/infinispan/infinispan.xml9
-rw-r--r--packages/apex-pdp-package-full/src/main/resources/infinispan/jgroups-apex.xml94
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java47
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java5
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java9
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml76
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml (renamed from plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml.sample)35
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java61
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java54
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java4
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java21
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java24
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java22
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java22
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java30
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java34
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java159
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java26
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java28
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java24
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java19
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java8
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java87
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java109
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java13
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java34
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java17
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java5
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java5
-rw-r--r--pom.xml6
-rw-r--r--services/services-engine/pom.xml4
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java7
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java15
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java60
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java8
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java7
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterConstants.java (renamed from services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterValidator.java)22
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java52
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java70
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java52
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java260
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java58
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java17
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java151
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java102
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java88
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java48
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java25
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java32
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java17
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java18
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java4
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java60
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java36
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java166
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java187
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java370
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java96
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java5
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java2
-rw-r--r--services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json74
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java9
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java55
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java55
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java54
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java55
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java55
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java52
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java52
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java50
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/KafkaEventProducer.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java27
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestFile2REST.java2
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestREST2File.java2
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restserver/TestRESTServer.java6
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java2
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java73
-rw-r--r--testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml37
121 files changed, 3267 insertions, 2117 deletions
diff --git a/context/context-management/pom.xml b/context/context-management/pom.xml
index 3826ba6dc..d9d9147e5 100644
--- a/context/context-management/pom.xml
+++ b/context/context-management/pom.xml
@@ -32,6 +32,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.apex-pdp.model</groupId>
<artifactId>context-model</artifactId>
<version>${project.version}</version>
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
index 1af13cbea..dba81d321 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
@@ -22,10 +22,11 @@ package org.onap.policy.apex.context.impl.distribution;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.ParameterService;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -51,24 +52,23 @@ public class DistributorFactory {
Assertions.argumentNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
// Get the class for the distributor using reflection
- final DistributorParameters distributorParameters = ParameterService.getParameters(DistributorParameters.class);
+ final DistributorParameters distributorParameters = ParameterService
+ .get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
final String pluginClass = distributorParameters.getPluginClass();
Object contextDistributorObject = null;
try {
contextDistributorObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOGGER.error(
- "Apex context distributor class not found for context distributor plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context distributor class not found for context distributor plugin \"" + pluginClass + "\"",
- e);
+ LOGGER.error("Apex context distributor class not found for context distributor plugin \"" + pluginClass
+ + "\"", e);
+ throw new ContextException("Apex context distributor class not found for context distributor plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a distributor
if (!(contextDistributorObject instanceof Distributor)) {
final String returnString = "Specified Apex context distributor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface";
+ + "\" does not implement the ContextDistributor interface";
LOGGER.error(returnString);
throw new ContextException(returnString);
}
@@ -79,8 +79,8 @@ public class DistributorFactory {
// Lock and load the context distributor
contextDistributor.init(key);
- LOGGER.exit(
- "Distributor factory, key=" + key + ", selected distributor of class " + contextDistributor.getClass());
+ LOGGER.exit("Distributor factory, key=" + key + ", selected distributor of class "
+ + contextDistributor.getClass());
return contextDistributor;
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
index 467d43f9d..19bb3602e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
@@ -25,8 +25,9 @@ import java.util.TimerTask;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.PersistorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -59,7 +60,8 @@ public class DistributorFlushTimerTask extends TimerTask {
this.contextDistributor = contextDistributor;
// Set the period for persistence flushing
- final PersistorParameters persistorParameters = ParameterService.getParameters(PersistorParameters.class);
+ final PersistorParameters persistorParameters = ParameterService
+ .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
period = persistorParameters.getFlushPeriod();
// Set up the timer
@@ -67,7 +69,7 @@ public class DistributorFlushTimerTask extends TimerTask {
timer.schedule(this, period, period);
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushing set up with interval: "
- + period + "ms");
+ + period + "ms");
}
/**
@@ -79,14 +81,14 @@ public class DistributorFlushTimerTask extends TimerTask {
flushCount++;
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushing: period=" + period
- + ": count=" + flushCount);
+ + ": count=" + flushCount);
try {
contextDistributor.flush();
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushed: period=" + period
- + ": count=" + flushCount);
+ + ": count=" + flushCount);
} catch (final ContextException e) {
LOGGER.error("flush error on context distributor " + contextDistributor.getKey().getID() + ": period="
- + period + ": count=" + flushCount, e);
+ + period + ": count=" + flushCount, e);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
index f3f4a6240..c45e3bd27 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
@@ -22,9 +22,10 @@ package org.onap.policy.apex.context.impl.locking;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.LockManager;
+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.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -48,7 +49,8 @@ public class LockManagerFactory {
public LockManager createLockManager(final AxArtifactKey key) throws ContextException {
LOGGER.entry("Lock Manager factory, key=" + key);
- final LockManagerParameters lockManagerParameters = ParameterService.getParameters(LockManagerParameters.class);
+ final LockManagerParameters lockManagerParameters = ParameterService
+ .get(ContextParameterConstants.LOCKING_GROUP_NAME);
// Get the class for the lock manager using reflection
Object lockManagerObject = null;
@@ -56,20 +58,18 @@ public class LockManagerFactory {
try {
lockManagerObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOGGER.error(
- "Apex context lock manager class not found for context lock manager plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context lock manager class not found for context lock manager plugin \"" + pluginClass + "\"",
- e);
+ LOGGER.error("Apex context lock manager class not found for context lock manager plugin \"" + pluginClass
+ + "\"", e);
+ throw new ContextException("Apex context lock manager class not found for context lock manager plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a lock manager
if (!(lockManagerObject instanceof LockManager)) {
- LOGGER.error("Specified Apex context lock manager plugin class \"" + pluginClass
- + "\" does not implement the LockManager interface");
+ LOGGER.error("Specified Apex context lock manager plugin class \"{}\" does not implement the LockManager interface",
+ pluginClass);
throw new ContextException("Specified Apex context lock manager plugin class \"" + pluginClass
- + "\" does not implement the LockManager interface");
+ + "\" does not implement the LockManager interface");
}
// The context lock manager to return
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
index af6f922d3..34fa15dcb 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
@@ -22,10 +22,11 @@ package org.onap.policy.apex.context.impl.persistence;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Persistor;
+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.service.ParameterService;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -49,7 +50,8 @@ public class PersistorFactory {
LOGGER.entry("persistor factory, key=" + key);
Assertions.argumentNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
- final PersistorParameters persistorParameters = ParameterService.getParameters(PersistorParameters.class);
+ final PersistorParameters persistorParameters = ParameterService
+ .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
// Get the class for the persistor using reflection
Object persistorObject = null;
@@ -58,17 +60,17 @@ public class PersistorFactory {
persistorObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
LOGGER.error("Apex context persistor class not found for context persistor plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context persistor class not found for context persistor plugin \"" + pluginClass + "\"", e);
+ e);
+ throw new ContextException("Apex context persistor class not found for context persistor plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a persistor
if (!(persistorObject instanceof Persistor)) {
- LOGGER.error("Specified Apex context persistor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface");
+ LOGGER.error("Specified Apex context persistor plugin class \"{}\" does not implement the ContextDistributor interface",
+ pluginClass);
throw new ContextException("Specified Apex context persistor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface");
+ + "\" does not implement the ContextDistributor interface");
}
// The persistor to return
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 54689e3fb..84025fc25 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
@@ -22,15 +22,16 @@ package org.onap.policy.apex.context.impl.schema;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
+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.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -67,7 +68,7 @@ public class SchemaHelperFactory {
}
// Get the schema class using the parameter service
- final SchemaParameters schemaParameters = ParameterService.getParameters(SchemaParameters.class);
+ final SchemaParameters schemaParameters = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
// Get the class for the schema helper from the schema parameters
final SchemaHelperParameters schemaHelperParameters =
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java
new file mode 100644
index 000000000..af712706d
--- /dev/null
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.context.parameters;
+
+/**
+ * This class holds constants used when managing context parameter groups in apex.
+ */
+public abstract class ContextParameterConstants {
+ public static final String MAIN_GROUP_NAME = "CONTEXT_PARAMETERS";
+ public static final String SCHEMA_GROUP_NAME = "CONTEXT_SCHEMA_PARAMETERS";
+ public static final String SCHEMA_HELPER_GROUP_NAME = "CONTEXT_SCHEMA_HELPER_PARAMETERS";
+ public static final String DISTRIBUTOR_GROUP_NAME = "CONTEXT_DISTRIBUTOR_PARAMETERS";
+ public static final String LOCKING_GROUP_NAME = "CONTEXT_LOCKING_PARAMETERS";
+ public static final String PERSISTENCE_GROUP_NAME = "CONTEXT_PERSISTENCE_PARAMETERS";
+
+ /**
+ * Private default constructor to prevent subclassing
+ */
+ private ContextParameterConstants() {
+ // Prevents subclassing
+ }
+
+}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
index 8bda76d21..2a109d48f 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* Bean class to hold parameters for context handling in Apex. This class contains all the context
@@ -43,9 +43,10 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ContextParameters extends AbstractParameters {
+public class ContextParameters implements ParameterGroup {
// @formatter:off
// Plugin Parameters
+ private String name;
private DistributorParameters distributorParameters = new DistributorParameters();
private SchemaParameters schemaParameters = new SchemaParameters();
private LockManagerParameters lockManagerParameters = new LockManagerParameters();
@@ -57,8 +58,10 @@ public class ContextParameters extends AbstractParameters {
* parameter service.
*/
public ContextParameters() {
- super(ContextParameters.class.getCanonicalName());
- ParameterService.registerParameters(ContextParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.MAIN_GROUP_NAME;
}
/**
@@ -132,16 +135,26 @@ public class ContextParameters extends AbstractParameters {
public void setPersistorParameters(final PersistorParameters persistorParameters) {
this.persistorParameters = persistorParameters;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "ContextParameters [distributorParameters=" + distributorParameters + ", schemaParameters="
- + schemaParameters + ", lockManagerParameters=" + lockManagerParameters + ", persistorParameters="
- + persistorParameters + "]";
+ return "ContextParameters [name=" + name + ", distributorParameters=" + distributorParameters
+ + ", schemaParameters=" + schemaParameters + ", lockManagerParameters=" + lockManagerParameters
+ + ", persistorParameters=" + persistorParameters + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
index cb4c6128e..e3f58cae4 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.parameters;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty distributor parameter class that may be specialized by context distributor plugins that
@@ -31,11 +31,11 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class DistributorParameters extends AbstractParameters {
+public class DistributorParameters implements ParameterGroup {
/** The default distributor makes context albums available to all threads in a single JVM. */
public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS = JVMLocalDistributor.class.getCanonicalName();
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
/**
@@ -43,18 +43,10 @@ public class DistributorParameters extends AbstractParameters {
* parameter service.
*/
public DistributorParameters() {
- super(DistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(DistributorParameters.class, this);
- }
-
- /**
- * Constructor to create a distributor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public DistributorParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.DISTRIBUTOR_GROUP_NAME;
}
/**
@@ -75,13 +67,23 @@ public class DistributorParameters extends AbstractParameters {
this.pluginClass = pluginClass;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "DistributorParameters [pluginClass=" + pluginClass + "]";
+ return "DistributorParameters [name=" + name + ", pluginClass=" + pluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
index 1aaee2cc7..27fc05a0b 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.parameters;
import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty lock manager parameter class that may be specialized by context lock manager plugins
@@ -31,13 +31,13 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class LockManagerParameters extends AbstractParameters {
+public class LockManagerParameters implements ParameterGroup {
/**
* The default lock manager can lock context album instance across all threads in a single JVM.
*/
public static final String DEFAULT_LOCK_MANAGER_PLUGIN_CLASS = JVMLocalLockManager.class.getCanonicalName();
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_LOCK_MANAGER_PLUGIN_CLASS;
/**
@@ -45,18 +45,10 @@ public class LockManagerParameters extends AbstractParameters {
* parameter service.
*/
public LockManagerParameters() {
- super(LockManagerParameters.class.getCanonicalName());
- ParameterService.registerParameters(LockManagerParameters.class, this);
- }
+ super();
- /**
- * Constructor to create a lock manager parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public LockManagerParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.LOCKING_GROUP_NAME;
}
/**
@@ -76,14 +68,24 @@ public class LockManagerParameters extends AbstractParameters {
public void setPluginClass(final String pluginClass) {
this.pluginClass = pluginClass;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "LockManagerParameters [pluginClass=" + pluginClass + "]";
+ return "LockManagerParameters [name=" + name + ", pluginClass=" + pluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
index 6fd320001..3616b526e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* A persistor parameter class that may be specialized by context persistor plugins that require
@@ -36,7 +36,7 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PersistorParameters extends AbstractParameters {
+public class PersistorParameters implements ParameterGroup {
/** The default persistor is a dummy persistor that stubs the Persistor interface. */
public static final String DEFAULT_PERSISTOR_PLUGIN_CLASS =
"org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor";
@@ -44,7 +44,7 @@ public class PersistorParameters extends AbstractParameters {
/** Default periodic flushing interval, 5 minutes in milliseconds. */
public static final long DEFAULT_FLUSH_PERIOD = 300000;
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_PERSISTOR_PLUGIN_CLASS;
// Parameters for flushing
@@ -55,18 +55,10 @@ public class PersistorParameters extends AbstractParameters {
* parameter service.
*/
public PersistorParameters() {
- super(PersistorParameters.class.getCanonicalName());
- ParameterService.registerParameters(PersistorParameters.class, this);
- }
+ super();
- /**
- * Constructor to create a persistor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public PersistorParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.PERSISTENCE_GROUP_NAME;
}
/**
@@ -109,13 +101,24 @@ public class PersistorParameters extends AbstractParameters {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "PersistorParameters [pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod + "]";
+ return "PersistorParameters [name=" + name + ", pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod
+ + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
index 9ccd431a5..e2bb4d6b9 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty schema helper parameter class that may be specialized by context schema helper plugins that require plugin
@@ -29,26 +29,15 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class SchemaHelperParameters extends AbstractParameters {
- // Schema helper plugin class for the schema
+public class SchemaHelperParameters implements ParameterGroup {
+ private String name;
private String schemaHelperPluginClass;
/**
* Constructor to create a schema helper parameters instance and register the instance with the parameter service.
*/
public SchemaHelperParameters() {
- super(SchemaHelperParameters.class.getCanonicalName());
- ParameterService.registerParameters(SchemaHelperParameters.class, this);
- }
-
- /**
- * Constructor to create a schema helper parameters instance with the name of a sub class of this class and register
- * the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public SchemaHelperParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
}
/**
@@ -68,14 +57,24 @@ public class SchemaHelperParameters extends AbstractParameters {
public void setSchemaHelperPluginClass(final String pluginClass) {
schemaHelperPluginClass = pluginClass;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "SchemaHelperParameters [schemaHelperPluginClass=" + schemaHelperPluginClass + "]";
+ return "SchemaHelperParameters [name=" + name + ", schemaHelperPluginClass=" + schemaHelperPluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
index 12e203c30..9992b9f3c 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
@@ -24,8 +24,8 @@ import java.util.Map;
import java.util.TreeMap;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* Bean class holding schema parameters for schemas and their helpers. As more than one schema can
@@ -38,10 +38,12 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class SchemaParameters extends AbstractParameters {
+public class SchemaParameters implements ParameterGroup {
/** The Java schema flavour is always available for use. */
public static final String DEFAULT_SCHEMA_FLAVOUR = "Java";
+ private String name;
+
// A map of parameters for executors of various logic types
private Map<String, SchemaHelperParameters> schemaHelperParameterMap;
@@ -50,8 +52,10 @@ public class SchemaParameters extends AbstractParameters {
* parameter service.
*/
public SchemaParameters() {
- super(SchemaParameters.class.getCanonicalName());
- ParameterService.registerParameters(SchemaParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.SCHEMA_GROUP_NAME;
schemaHelperParameterMap = new TreeMap<>();
@@ -86,4 +90,19 @@ public class SchemaParameters extends AbstractParameters {
public SchemaHelperParameters getSchemaHelperParameters(final String schemaFlavour) {
return schemaHelperParameterMap.get(schemaFlavour);
}
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
}
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 bf363058b..5f2b426bd 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
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.context.ContextAlbum;
@@ -35,6 +36,7 @@ import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
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.ApexRuntimeException;
@@ -42,10 +44,10 @@ 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.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
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;
public class ContextAlbumImplTest {
/**
@@ -56,11 +58,32 @@ public class ContextAlbumImplTest {
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters()
.setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager");
- ParameterService.registerParameters(ContextParameters.class, 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @AfterClass
+ public static void cleanUpAfterTest() {
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME);
+ ParameterService.clear();
}
@Test
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 fed79e713..7bf836c3c 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
@@ -24,15 +24,18 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.context.ContextRuntimeException;
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.SchemaParameters;
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.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
public class SchemaHelperFactoryTest {
private static AxContextSchema intSchema;
@@ -51,6 +54,11 @@ public class SchemaHelperFactoryTest {
badSchema = new AxContextSchema(new AxArtifactKey("IntSchema", "0.0.1"), "JAVA", "java.lang.Bad");
}
+ @AfterClass
+ public static void clearParameters() {
+ ParameterService.clear();
+ }
+
@Test
public void testSchemaHelperFactory() {
try {
@@ -76,15 +84,21 @@ public class SchemaHelperFactoryTest {
}
schemas.getSchemasMap().put(intSchema.getKey(), intSchema);
- new SchemaParameters();
+ SchemaParameters schemaParameters0 = new SchemaParameters();
+ schemaParameters0.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters0);
try {
new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey());
fail("this test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("context schema helper parameters not found for context schema \"JAVA\"", e.getMessage());
}
+ ParameterService.deregister(schemaParameters0);
- new SchemaParameters().getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+ SchemaParameters schemaParameters1 = new SchemaParameters();
+ schemaParameters1.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters1);
+ schemaParameters1.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
assertNotNull(new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey()));
schemas.getSchemasMap().put(intSchema.getKey(), badSchema);
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
index 1ca3702e8..a71ba3675 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
@@ -23,16 +23,21 @@ package org.onap.policy.apex.context.impl.schema.java;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
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;
/**
* JavaSchemaHelperInstanceCreationTest.
@@ -50,9 +55,20 @@ public class JavaSchemaHelperInstanceCreationTest {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters();
+
+ final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
}
+ @AfterClass
+ public static void cleanUpAfterTest() {
+ ParameterService.clear();
+ }
+
+
@Test
public void testNullEncoding() {
final AxContextSchema javaBooleanSchema =
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
index 3288f56dd..0f6900dbb 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
@@ -43,8 +43,8 @@ import org.onap.policy.apex.context.test.utils.Constants;
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.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -144,13 +144,13 @@ public final class ConcurrentContextJVM {
for (int p = 7; p < args.length - 1; p += 2) {
@SuppressWarnings("rawtypes")
final Class parametersClass = Class.forName(args[p]);
- final AbstractParameters parameters =
- (AbstractParameters) new Gson().fromJson(args[p + 1], parametersClass);
- ParameterService.registerParameters(parametersClass, parameters);
+ final ParameterGroup parameters =
+ (ParameterGroup) new Gson().fromJson(args[p + 1], parametersClass);
+ ParameterService.register(parameters);
}
- for (final Entry<Class<?>, AbstractParameters> parameterEntry : ParameterService.getAll()) {
- LOGGER.info("Parameter class " + parameterEntry.getKey().getCanonicalName() + "="
+ for (final Entry<String, ParameterGroup> parameterEntry : ParameterService.getAll()) {
+ LOGGER.info("Parameter class " + parameterEntry.getKey() + "="
+ parameterEntry.getValue().toString());
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
index 117a396dc..0c2aa7a90 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
@@ -31,8 +31,8 @@ import java.util.List;
import java.util.Map.Entry;
import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -79,8 +79,8 @@ public class ConcurrentContextJVMThread implements Runnable, Closeable {
commandList.add(new Integer(configrationProvider.getLockType().getValue()).toString());
commandList.add(System.getProperty("hazelcast.config", ""));
- for (final Entry<Class<?>, AbstractParameters> parameterServiceEntry : ParameterService.getAll()) {
- commandList.add(parameterServiceEntry.getKey().getCanonicalName());
+ for (final Entry<String, ParameterGroup> parameterServiceEntry : ParameterService.getAll()) {
+ commandList.add(parameterServiceEntry.getValue().getClass().getCanonicalName());
commandList.add(new Gson().toJson(parameterServiceEntry.getValue()));
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java
index 5a7813a7e..654040d3f 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java
@@ -26,8 +26,7 @@ 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.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
index 5487a0934..6b9ba15ad 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java
@@ -22,11 +22,16 @@ package org.onap.policy.apex.context.test.distribution;
import java.io.IOException;
import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.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.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -34,11 +39,44 @@ public class TestContextAlbumUpdate {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextAlbumUpdate.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @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);
+
+ 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
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
+
@Test
public void testContextAlbumUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextAlbumUpdate().testContextAlbumUpdate();
@@ -49,15 +87,8 @@ public class TestContextAlbumUpdate {
public void testContextAlbumUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateJVMLocalVarNotSet test . . .");
- new ContextParameters();
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateJVMLocalVarNotSet test");
}
-
- /**
- * Test context update cleardown.
- */
- @After
- public void testContextAlbumUpdateCleardown() {}
}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
index 409033ad4..b10bc685c 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java
@@ -25,9 +25,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.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.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -40,20 +44,44 @@ public class TestContextInstantiation {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextInstantiation.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
@Before
- public void beforeTest() {}
+ 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);
+
+ 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);
+ }
- /**
- * Test context instantiation clear down.
- */
@After
- public void afterTest() {}
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextInstantiation().testContextInstantiation();
@@ -64,10 +92,8 @@ public class TestContextInstantiation {
public void testContextInstantiationJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationJVMLocalVarNotSet test . . .");
- new ContextParameters();
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationJVMLocalVarNotSet test");
}
-
}
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
index 1a9bc29f1..07a0cbe47 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java
@@ -22,11 +22,17 @@ package org.onap.policy.apex.context.test.distribution;
import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.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.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -38,12 +44,45 @@ import org.slf4j.ext.XLoggerFactory;
public class TestContextUpdate {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdate.class);
+
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @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);
+
+ 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
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
new ContextUpdate().testContextUpdate();
@@ -54,7 +93,6 @@ public class TestContextUpdate {
public void testContextUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateJVMLocalVarNotSet test . . .");
- new ContextParameters();
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateJVMLocalVarNotSet test");
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
index 6e7430756..b37c8eafa 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java
@@ -25,9 +25,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
+import org.onap.policy.apex.context.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.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -39,20 +43,48 @@ import org.slf4j.ext.XLoggerFactory;
public class TestSequentialContextInstantiation {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestSequentialContextInstantiation.class);
+
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
@Before
- public void beforeTest() {}
+ 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);
+
+ 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
- public void afterTest() {}
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testSequentialContextInstantiationJVMLocalVarSet()
throws ApexModelException, IOException, ApexException {
logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
+
new SequentialContextInstantiation().testSequentialContextInstantiation();
logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test");
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
index 9d0210e38..8fca90b07 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java
@@ -28,14 +28,20 @@ import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE;
import java.util.Map;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
import org.onap.policy.apex.context.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.SchemaParameters;
import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.utils.ConfigrationProvider;
import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl;
import org.onap.policy.apex.context.test.utils.Constants;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -57,11 +63,44 @@ public class TestConcurrentContext {
private static final int TEST_THREAD_COUNT_MULTI_JVM = 20;
private static final int TEST_THREAD_LOOPS = 100;
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @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);
+
+ 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
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
+
@Test
public void testConcurrentContextJVMLocalVarSet() throws Exception {
logger.debug("Running testConcurrentContextJVMLocalVarSet test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet",
@@ -84,7 +123,6 @@ public class TestConcurrentContext {
public void testConcurrentContextJVMLocalNoVarSet() throws Exception {
logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . .");
- new ContextParameters();
final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalNoVarSet",
TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -104,7 +142,6 @@ public class TestConcurrentContext {
public void testConcurrentContextMultiJVMNoLock() throws Exception {
logger.debug("Running testConcurrentContextMultiJVMNoLock test . . .");
- final ContextParameters contextParameters = new ContextParameters();
contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName());
contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName());
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
index 80f06ead7..d3a8ba163 100644
--- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
+++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java
@@ -38,8 +38,10 @@ import org.junit.Test;
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.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.PersistorParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
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.TestContextLongItem;
@@ -53,6 +55,7 @@ import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestContextInstantiation.
@@ -65,6 +68,8 @@ public class TestPersistentContextInstantiation {
// XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class);
private Connection connection;
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
@Before
public void setup() throws Exception {
@@ -78,15 +83,40 @@ public class TestPersistentContextInstantiation {
new File("derby.log").delete();
}
+ @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);
+
+ 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
- public void afterTest() throws IOException {}
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextPersistentInstantiation() throws ApexModelException, IOException, ApexException {
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.setPersistorParameters(new PersistorParameters());
-
final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1");
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
@@ -181,6 +211,5 @@ public class TestPersistentContextInstantiation {
contextAlbumForLong.flush();
contextDistributor.clear();
-
}
}
diff --git a/core/core-engine/pom.xml b/core/core-engine/pom.xml
index a84e9d962..f527d46c1 100644
--- a/core/core-engine/pom.xml
+++ b/core/core-engine/pom.xml
@@ -32,6 +32,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.apex-pdp.model</groupId>
<artifactId>policy-model</artifactId>
<version>${project.version}</version>
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameterConstants.java
index 3a7fdf530..1678f57c7 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameterConstants.java
@@ -1,6 +1,6 @@
-/*
+/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
@@ -18,15 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.model.basicmodel.service;
-
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
+package org.onap.policy.apex.core.engine;
/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
+ * This class holds constants used when managing engine parameter groups in apex.
*/
-public class IllegalParameters extends AbstractParameters {
- public IllegalParameters() {
- super("somewhere.over.the.rainbow");
+public abstract class EngineParameterConstants {
+ public static final String MAIN_GROUP_NAME = "ENGINE_PARAMETERS";
+ public static final String EXECUTOR_GROUP_NAME = "EXECUTOR_PARAMETERS";
+
+ /**
+ * Private default constructor to prevent subclassing
+ */
+ private EngineParameterConstants() {
+ // Prevents subclassing
}
+
}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java
index 62fe6a552..e0b0349de 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java
@@ -24,8 +24,8 @@ import java.util.Map;
import java.util.TreeMap;
import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* This class holds the parameters for a single Apex engine. This parameter class holds parameters
@@ -43,19 +43,24 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EngineParameters extends AbstractParameters {
+public class EngineParameters implements ParameterGroup {
private ContextParameters contextParameters = new ContextParameters();
+ // Parameter group name
+ private String name;
+
// A map of parameters for executors of various logic types
- private Map<String, ExecutorParameters> executorParameterMap = new TreeMap<String, ExecutorParameters>();
+ private Map<String, ExecutorParameters> executorParameterMap = new TreeMap<>();
/**
* Constructor to create an engine parameters instance and register the instance with the
* parameter service.
*/
public EngineParameters() {
- super(EngineParameters.class.getCanonicalName());
- ParameterService.registerParameters(EngineParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = EngineParameterConstants.MAIN_GROUP_NAME;
}
/**
@@ -93,4 +98,19 @@ public class EngineParameters extends AbstractParameters {
public void setExecutorParameterMap(final Map<String, ExecutorParameters> executorParameterMap) {
this.executorParameterMap = executorParameterMap;
}
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java
index 53cac399e..7de121d66 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.core.engine;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* This class provides the executors for a logic flavour. Plugin classes for execution of task
@@ -32,7 +32,10 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ExecutorParameters extends AbstractParameters {
+public class ExecutorParameters implements ParameterGroup {
+ // Parameter group name
+ private String name;
+
// Executor Plugin classes for executors
private String taskExecutorPluginClass;
private String taskSelectionExecutorPluginClass;
@@ -43,18 +46,10 @@ public class ExecutorParameters extends AbstractParameters {
* parameter service.
*/
public ExecutorParameters() {
- super(ExecutorParameters.class.getCanonicalName());
- ParameterService.registerParameters(ExecutorParameters.class, this);
- }
+ super();
- /**
- * Constructor to create an executor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public ExecutorParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = EngineParameterConstants.EXECUTOR_GROUP_NAME;
}
/**
@@ -113,15 +108,25 @@ public class ExecutorParameters extends AbstractParameters {
this.stateFinalizerExecutorPluginClass = stateFinalizerExecutorPluginClass;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "ExecutorParameters [taskExecutorPluginClass=" + taskExecutorPluginClass
- + ", taskSelectionExecutorPluginClass=" + taskSelectionExecutorPluginClass
- + ", StateFinalizerExecutorPluginClass=" + stateFinalizerExecutorPluginClass + "]";
+ return "ExecutorParameters [name=" + name + ", taskExecutorPluginClass=" + taskExecutorPluginClass
+ + ", taskSelectionExecutorPluginClass=" + taskSelectionExecutorPluginClass
+ + ", stateFinalizerExecutorPluginClass=" + stateFinalizerExecutorPluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
index ae1f551a4..6bb9ce2a3 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
+import org.onap.policy.apex.core.engine.EngineParameterConstants;
import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -34,11 +35,11 @@ import org.onap.policy.apex.core.engine.executor.TaskExecutor;
import org.onap.policy.apex.core.engine.executor.TaskSelectExecutor;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineRuntimeException;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.policymodel.concepts.AxState;
import org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -53,16 +54,12 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ExecutorFactoryImpl.class);
// A map of logic flavours mapped to executor classes for plugins to executors for those logic flavours
- private Map<String, Class<Executor<?, ?, ?, ?>>> taskExecutorPluginClassMap =
- new TreeMap<String, Class<Executor<?, ?, ?, ?>>>();
- private Map<String, Class<Executor<?, ?, ?, ?>>> taskSelectionExecutorPluginClassMap =
- new TreeMap<String, Class<Executor<?, ?, ?, ?>>>();
- private Map<String, Class<Executor<?, ?, ?, ?>>> stateFinalizerExecutorPluginClassMap =
- new TreeMap<String, Class<Executor<?, ?, ?, ?>>>();
+ private Map<String, Class<Executor<?, ?, ?, ?>>> taskExecutorPluginClassMap = new TreeMap<>();
+ private Map<String, Class<Executor<?, ?, ?, ?>>> taskSelectionExecutorPluginClassMap = new TreeMap<>();
+ private Map<String, Class<Executor<?, ?, ?, ?>>> stateFinalizerExecutorPluginClassMap = new TreeMap<>();
// A map of parameters for executors
- private final Map<String, ExecutorParameters> implementationParameterMap =
- new TreeMap<String, ExecutorParameters>();
+ private final Map<String, ExecutorParameters> implementationParameterMap = new TreeMap<>();
/**
* Constructor, builds the class map for executors.
@@ -70,21 +67,21 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
* @throws StateMachineException on plugin creation errors
*/
public ExecutorFactoryImpl() throws StateMachineException {
- final EngineParameters engineParameters = ParameterService.getParameters(EngineParameters.class);
+ final EngineParameters engineParameters = ParameterService.get(EngineParameterConstants.MAIN_GROUP_NAME);
Assertions.argumentNotNull(engineParameters, StateMachineException.class,
- "Parameter \"engineParameters\" may not be null");
+ "Parameter \"engineParameters\" may not be null");
// Instantiate each executor class map entry
for (final Entry<String, ExecutorParameters> executorParameterEntry : engineParameters.getExecutorParameterMap()
- .entrySet()) {
+ .entrySet()) {
// Get classes for all types of executors for this logic type
taskExecutorPluginClassMap.put(executorParameterEntry.getKey(),
- getExecutorPluginClass(executorParameterEntry.getValue().getTaskExecutorPluginClass()));
- taskSelectionExecutorPluginClassMap.put(executorParameterEntry.getKey(),
- getExecutorPluginClass(executorParameterEntry.getValue().getTaskSelectionExecutorPluginClass()));
- stateFinalizerExecutorPluginClassMap.put(executorParameterEntry.getKey(),
- getExecutorPluginClass(executorParameterEntry.getValue().getStateFinalizerExecutorPluginClass()));
+ getExecutorPluginClass(executorParameterEntry.getValue().getTaskExecutorPluginClass()));
+ taskSelectionExecutorPluginClassMap.put(executorParameterEntry.getKey(), getExecutorPluginClass(
+ executorParameterEntry.getValue().getTaskSelectionExecutorPluginClass()));
+ stateFinalizerExecutorPluginClassMap.put(executorParameterEntry.getKey(), getExecutorPluginClass(
+ executorParameterEntry.getValue().getStateFinalizerExecutorPluginClass()));
// Save the executor implementation parameters
implementationParameterMap.put(executorParameterEntry.getKey(), executorParameterEntry.getValue());
@@ -100,14 +97,14 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
*/
@Override
public TaskSelectExecutor getTaskSelectionExecutor(final Executor<?, ?, ?, ?> parentExecutor, final AxState state,
- final ApexInternalContext context) {
+ final ApexInternalContext context) {
if (!state.checkSetTaskSelectionLogic()) {
return null;
}
// Create task selection executor
- final TaskSelectExecutor tsExecutor =
- (TaskSelectExecutor) createExecutor(state.getTaskSelectionLogic().getLogicFlavour(),
+ final TaskSelectExecutor tsExecutor = (TaskSelectExecutor) createExecutor(
+ state.getTaskSelectionLogic().getLogicFlavour(),
taskSelectionExecutorPluginClassMap.get(state.getTaskSelectionLogic().getLogicFlavour()),
TaskSelectExecutor.class);
tsExecutor.setParameters(implementationParameterMap.get(state.getTaskSelectionLogic().getLogicFlavour()));
@@ -124,10 +121,10 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
*/
@Override
public TaskExecutor getTaskExecutor(final Executor<?, ?, ?, ?> parentExecutor, final AxTask task,
- final ApexInternalContext context) {
+ final ApexInternalContext context) {
// Create task executor
final TaskExecutor taskExecutor = (TaskExecutor) createExecutor(task.getTaskLogic().getLogicFlavour(),
- taskExecutorPluginClassMap.get(task.getTaskLogic().getLogicFlavour()), TaskExecutor.class);
+ taskExecutorPluginClassMap.get(task.getTaskLogic().getLogicFlavour()), TaskExecutor.class);
taskExecutor.setParameters(implementationParameterMap.get(task.getTaskLogic().getLogicFlavour()));
taskExecutor.setContext(parentExecutor, task, context);
@@ -144,10 +141,11 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
*/
@Override
public StateFinalizerExecutor getStateFinalizerExecutor(final Executor<?, ?, ?, ?> parentExecutor,
- final AxStateFinalizerLogic logic, final ApexInternalContext context) {
+ final AxStateFinalizerLogic logic, final ApexInternalContext context) {
// Create state finalizer executor
final StateFinalizerExecutor sfExecutor = (StateFinalizerExecutor) createExecutor(logic.getLogicFlavour(),
- stateFinalizerExecutorPluginClassMap.get(logic.getLogicFlavour()), StateFinalizerExecutor.class);
+ stateFinalizerExecutorPluginClassMap.get(logic.getLogicFlavour()),
+ StateFinalizerExecutor.class);
sfExecutor.setParameters(implementationParameterMap.get(logic.getLogicFlavour()));
sfExecutor.setContext(parentExecutor, logic, context);
@@ -163,7 +161,7 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
*/
@SuppressWarnings("unchecked")
private Class<Executor<?, ?, ?, ?>> getExecutorPluginClass(final String executorClassName)
- throws StateMachineException {
+ throws StateMachineException {
// It's OK for an executor class not to be defined as long as it's not called
if (executorClassName == null) {
return null;
@@ -176,15 +174,15 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
} catch (final ClassNotFoundException e) {
LOGGER.error("Apex executor class not found for executor plugin \"" + executorClassName + "\"", e);
throw new StateMachineException(
- "Apex executor class not found for executor plugin \"" + executorClassName + "\"", e);
+ "Apex executor class not found for executor plugin \"" + executorClassName + "\"", e);
}
// Check the class is an executor
if (!Executor.class.isAssignableFrom(executorPluginClass)) {
- LOGGER.error("Specified Apex executor plugin class \"" + executorClassName
- + "\" does not implment the Executor interface");
+ LOGGER.error("Specified Apex executor plugin class \"{}\" does not implment the Executor interface",
+ executorClassName);
throw new StateMachineException("Specified Apex executor plugin class \"" + executorClassName
- + "\" does not implment the Executor interface");
+ + "\" does not implment the Executor interface");
}
return (Class<Executor<?, ?, ?, ?>>) executorPluginClass;
@@ -199,14 +197,14 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
* @return The instantiated class
*/
private Executor<?, ?, ?, ?> createExecutor(final String logicFlavour,
- final Class<Executor<?, ?, ?, ?>> executorClass,
- final Class<? extends Executor<?, ?, ?, ?>> executorSuperClass) {
+ final Class<Executor<?, ?, ?, ?>> executorClass,
+ final Class<? extends Executor<?, ?, ?, ?>> executorSuperClass) {
// It's OK for an executor class not to be defined but it's not all right to try and create
// a non-defined
// executor class
if (executorClass == null) {
final String errorMessage = "Executor plugin class not defined for \"" + logicFlavour
- + "\" executor of type \"" + executorSuperClass.getCanonicalName() + "\"";
+ + "\" executor of type \"" + executorSuperClass.getCanonicalName() + "\"";
LOGGER.error(errorMessage);
throw new StateMachineRuntimeException(errorMessage);
}
@@ -217,7 +215,7 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
executorObject = executorClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
final String errorMessage = "Instantiation error on \"" + logicFlavour + "\" executor of type \""
- + executorClass.getCanonicalName() + "\"";
+ + executorClass.getCanonicalName() + "\"";
LOGGER.error(errorMessage, e);
throw new StateMachineRuntimeException(errorMessage, e);
}
@@ -225,7 +223,7 @@ public class ExecutorFactoryImpl extends ExecutorFactory {
// Check the class is a Task Selection Executor
if (!(executorSuperClass.isAssignableFrom(executorObject.getClass()))) {
final String errorMessage = "Executor on \"" + logicFlavour + "\" of type \"" + executorClass
- + "\" is not an instance of \"" + executorSuperClass.getCanonicalName() + "\"";
+ + "\" is not an instance of \"" + executorSuperClass.getCanonicalName() + "\"";
LOGGER.error(errorMessage);
throw new StateMachineRuntimeException(errorMessage);
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java
index 58b1800ba..1f9b1087c 100644
--- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java
+++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java
@@ -30,6 +30,10 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.ContextAlbum;
+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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl;
@@ -41,6 +45,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -50,11 +55,47 @@ import org.slf4j.ext.XLoggerFactory;
public class TestAADMUseCase {
private static final XLogger logger = XLoggerFactory.getXLogger(TestAADMUseCase.class);
- /**
- * Test aadm use case setup.
- */
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
@Before
- public void testAADMUseCaseSetup() {}
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test aadm case.
@@ -69,9 +110,6 @@ public class TestAADMUseCase {
assertNotNull(apexPolicyModel);
final AxArtifactKey key = new AxArtifactKey("AADMApexEngine", "0.0.1");
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
-
final ApexEngineImpl apexEngine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(key);
final TestApexActionListener listener = new TestApexActionListener("Test");
apexEngine.addEventListener("listener", listener);
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java
index 7d9791d46..3d3fad973 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java
@@ -27,7 +27,13 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Random;
+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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
@@ -39,6 +45,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -55,6 +62,49 @@ public class TestAnomalyDetectionTSLUseCase {
private static final int MAXITERATIONS = 3660;
private static final Random RAND = new Random(System.currentTimeMillis());
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
+
@Test
// once through the long running test below
public void TestAnomalyDetectionTSL() throws ApexException, InterruptedException, IOException {
@@ -66,9 +116,6 @@ public class TestAnomalyDetectionTSLUseCase {
assertTrue(validationResult.isValid());
final AxArtifactKey key = new AxArtifactKey("AnomalyTSLApexEngine", "0.0.1");
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
- parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
final ApexEngine apexEngine1 = new ApexEngineFactory().createApexEngine(key);
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java
index 88b504cef..723b56653 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java
@@ -27,7 +27,13 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Random;
+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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
@@ -39,6 +45,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -53,6 +60,49 @@ public class TestAutoLearnTSLUseCase {
private static final int MAXITERATIONS = 1000;
private static final Random rand = new Random(System.currentTimeMillis());
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
+
@Test
// once through the long running test below
public void TestAutoLearnTSL() throws ApexException, InterruptedException, IOException {
@@ -64,9 +114,6 @@ public class TestAutoLearnTSLUseCase {
assertTrue(validationResult.isValid());
final AxArtifactKey key = new AxArtifactKey("AADMApexEngine", "0.0.1");
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
- parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
final ApexEngine apexEngine1 = new ApexEngineFactory().createApexEngine(key);
diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java
index f4030b208..22f985f80 100644
--- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java
+++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java
@@ -32,8 +32,13 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl;
@@ -46,6 +51,7 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.ResourceUtils;
/**
@@ -62,12 +68,52 @@ public class TestMFPUseCase {
@BeforeClass
public static void testMFPUseCaseSetup() {
final AxArtifactKey key = new AxArtifactKey("MyFirstPolicyApexEngine", "0.0.1");
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
- parameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
apexEngine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(key);
}
+ private static ContextParameters contextParameters;
+ private static SchemaParameters schemaParameters;
+ private static EngineParameters engineParameters;
+
+ @BeforeClass
+ public static void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @AfterClass
+ public static void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
+
/**
* Test MyFirstPolicy#1 use case.
*
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java
deleted file mode 100644
index cc7c7b06f..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java
+++ /dev/null
@@ -1,87 +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.model.basicmodel.service;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.policy.apex.model.utilities.Assertions;
-
-/**
- * This class defines an abstract parameter class that acts as a base class for all parameters in Apex. The abstract parameter class holds the name of a
- * subclass of this abstract parameter class {@link AbstractParameters}. The class of the parameter class is checked at construction and on calls to the
- * {@link #getParameterClass()} method.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public abstract class AbstractParameters {
- // The name of the parameter subclass
- private final String parameterClassName;
-
- /**
- * Constructor, creates a parameter class that must be a subclass of {@link AbstractParameters}.
- *
- * @param parameterClassName the full canonical class name of the parameter class
- */
- public AbstractParameters(final String parameterClassName) {
- try {
- Assertions.assignableFrom(Class.forName(parameterClassName), AbstractParameters.class);
- }
- catch (IllegalArgumentException | ClassNotFoundException e) {
- throw new ApexRuntimeException(
- "class \"" + parameterClassName + "\" not found or not an instance of \"" + this.getClass().getCanonicalName() + "\"", e);
- }
-
- this.parameterClassName = parameterClassName;
- }
-
- /**
- * Gets the parameter class.
- *
- * @return the parameter class
- */
- @SuppressWarnings("unchecked")
- public final Class<? extends AbstractParameters> getParameterClass() {
- try {
- return (Class<? extends AbstractParameters>) Class.forName(parameterClassName);
- }
- catch (final ClassNotFoundException e) {
- throw new ApexRuntimeException("class not found for parameter class name \"" + parameterClassName + "\"", e);
- }
- }
-
- /**
- * Gets the parameter class name.
- *
- * @return the parameter class name
- */
- public final String getParameterClassName() {
- return parameterClassName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "AbstractParameters [parameterClassName=" + parameterClassName + "]";
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java
deleted file mode 100644
index 062213093..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java
+++ /dev/null
@@ -1,116 +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.model.basicmodel.service;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-
-/**
- * The parameter service makes Apex parameters available to all classes in a JVM.
- *
- * The reason for having a parameter service is to avoid having to pass parameters down long call chains in modules such as the Apex engine and editor. The
- * parameter service makes parameters available statically.
- *
- * The parameter service must be used with care because changing a parameter set anywhere in a JVM will affect all users of those parameters anywhere in the
- * JVM.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public abstract class ParameterService {
- // The map holding the parameters
- private static Map<Class<?>, AbstractParameters> parameterMap = new ConcurrentHashMap<>();
-
- /**
- * This class is an abstract static class that cannot be extended.
- */
- private ParameterService() {
- }
-
- /**
- * Register parameters with the parameter service.
- *
- * @param <P> the generic type
- * @param parametersClass the class of the parameter, used to index the parameter
- * @param parameters the parameters
- */
- public static <P extends AbstractParameters> void registerParameters(final Class<P> parametersClass, final P parameters) {
- parameterMap.put(parametersClass, parameters);
- }
-
- /**
- * Remove parameters from the parameter service.
- *
- * @param <P> the generic type
- * @param parametersClass the class of the parameter, used to index the parameter
- */
- public static <P extends AbstractParameters> void deregisterParameters(final Class<P> parametersClass) {
- parameterMap.remove(parametersClass);
- }
-
- /**
- * Get parameters from the parameter service.
- *
- * @param <P> the generic type
- * @param parametersClass the class of the parameter, used to index the parameter
- * @return The parameter
- */
- @SuppressWarnings("unchecked")
- public static <P extends AbstractParameters> P getParameters(final Class<P> parametersClass) {
- final P parameter = (P) parameterMap.get(parametersClass);
-
- if (parameter == null) {
- throw new ApexRuntimeException("Parameters for " + parametersClass.getCanonicalName() + " not found in parameter service");
- }
-
- return parameter;
- }
-
- /**
- * Check if parameters is defined on the parameter service.
- *
- * @param <P> the generic type
- * @param parametersClass the class of the parameter, used to index the parameter
- * @return true if the parameter is defined
- */
- public static <P extends AbstractParameters> boolean existsParameters(final Class<P> parametersClass) {
- return parameterMap.get(parametersClass) != null;
- }
-
- /**
- * Get all the entries in the parameters map.
- *
- * @return The entries
- */
- public static Set<Entry<Class<?>, AbstractParameters>> getAll() {
- return parameterMap.entrySet();
- }
-
- /**
- * Clear all parameters in the parameter service.
- */
- public static void clear() {
- parameterMap.clear();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java
deleted file mode 100644
index 3de3ecb58..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java
+++ /dev/null
@@ -1,32 +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.model.basicmodel.service;
-
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class LegalParameters extends AbstractParameters {
- public LegalParameters() {
- super(LegalParameters.class.getCanonicalName());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java
deleted file mode 100644
index 7afa14440..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java
+++ /dev/null
@@ -1,55 +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.model.basicmodel.service;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestAbstractParameters {
-
- @Test
- public void testAbstractParameters() {
- final LegalParameters parameters = new LegalParameters();
- assertNotNull(parameters);
- assertEquals(
- "AbstractParameters [parameterClassName=org.onap.policy.apex.model.basicmodel.service.LegalParameters]",
- parameters.toString());
-
- assertEquals(LegalParameters.class, parameters.getParameterClass());
- assertEquals("org.onap.policy.apex.model.basicmodel.service.LegalParameters",
- parameters.getParameterClassName());
-
- try {
- new IllegalParameters();
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals(
- "class \"somewhere.over.the.rainbow\" not found or not an instance of \"org.onap.policy.apex.model.basicmodel.service.IllegalParameters\"",
- e.getMessage());
- }
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java
deleted file mode 100644
index e84b3e252..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java
+++ /dev/null
@@ -1,79 +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.model.basicmodel.service;
-
-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 org.junit.Test;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestParameterService {
-
- @Test
- public void testParameterService() {
- ParameterService.clear();
-
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
- try {
- ParameterService.getParameters(LegalParameters.class);
- } catch (final Exception e) {
- assertEquals(
- "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
- e.getMessage());
- }
-
- ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
- assertTrue(ParameterService.existsParameters(LegalParameters.class));
- assertNotNull(ParameterService.getParameters(LegalParameters.class));
-
- ParameterService.deregisterParameters(LegalParameters.class);
-
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
- try {
- ParameterService.getParameters(LegalParameters.class);
- } catch (final Exception e) {
- assertEquals(
- "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
- e.getMessage());
- }
-
- ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
- assertTrue(ParameterService.existsParameters(LegalParameters.class));
- assertNotNull(ParameterService.getParameters(LegalParameters.class));
-
- assertNotNull(ParameterService.getAll());
- ParameterService.clear();
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
- try {
- ParameterService.getParameters(LegalParameters.class);
- } catch (final Exception e) {
- assertEquals(
- "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
- e.getMessage());
- }
-
- }
-}
diff --git a/packages/apex-pdp-package-full/src/main/resources/infinispan/default-jgroups-tcp.xml b/packages/apex-pdp-package-full/src/main/resources/infinispan/default-jgroups-tcp.xml
new file mode 100644
index 000000000..028cf1df6
--- /dev/null
+++ b/packages/apex-pdp-package-full/src/main/resources/infinispan/default-jgroups-tcp.xml
@@ -0,0 +1,76 @@
+<?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/packages/apex-pdp-package-full/src/main/resources/infinispan/infinispan.xml b/packages/apex-pdp-package-full/src/main/resources/infinispan/infinispan.xml
index fcb57ae8a..5b416f50d 100644
--- a/packages/apex-pdp-package-full/src/main/resources/infinispan/infinispan.xml
+++ b/packages/apex-pdp-package-full/src/main/resources/infinispan/infinispan.xml
@@ -22,15 +22,18 @@
<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="apex" path="infinispan/jgroups-apex.xml" />
+ <stack-file name="external-file" path="infinispan/default-jgroups-tcp.xml" />
</jgroups>
- <cache-container name="ApexCacheContainer" default-cache="default">
- <transport cluster="apexCluster" stack="apex" />
+ <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
+ <transport cluster="apexCluster" stack="external-file" />
<jmx />
<replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
<state-transfer enabled="true" />
</replicated-cache>
+ <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
<replicated-cache name="TestContext_0.0.1" mode="SYNC">
<state-transfer enabled="true" />
</replicated-cache>
diff --git a/packages/apex-pdp-package-full/src/main/resources/infinispan/jgroups-apex.xml b/packages/apex-pdp-package-full/src/main/resources/infinispan/jgroups-apex.xml
deleted file mode 100644
index c97406abe..000000000
--- a/packages/apex-pdp-package-full/src/main/resources/infinispan/jgroups-apex.xml
+++ /dev/null
@@ -1,94 +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=========================================================
--->
-
-<!--
- Fast configuration for local mode, ie. all members reside on the same host. Setting ip_ttl to 0 means that
- no multicast packet will make it outside the local host.
- Therefore, this configuration will NOT work to cluster members residing on different hosts !
-
- Author: Bela Ban
- Version: $Id: fast-local.xml,v 1.9 2009/12/18 14:50:00 belaban Exp $
--->
-
-<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-3.4.xsd">
- <UDP mcast_addr="239.1.1.1"
- mcast_port="${jgroups.udp.mcast_port:45111}"
- tos="8"
- ucast_recv_buf_size="20000000"
- ucast_send_buf_size="640000"
- mcast_recv_buf_size="25000000"
- mcast_send_buf_size="640000"
- loopback="true"
- max_bundle_size="64k"
- bundler_type="sender-sends-with-timer"
- ip_ttl="${jgroups.udp.ip_ttl:0}"
- enable_diagnostics="true"
- thread_naming_pattern="cl"
-
- timer_type="new"
- timer.min_threads="2"
- timer.max_threads="4"
- timer.keep_alive_time="3000"
- timer.queue_max_size="1000"
- timer.wheel_size="200"
- timer.tick_time="50"
-
- thread_pool.enabled="true"
- thread_pool.min_threads="2"
- thread_pool.max_threads="8"
- thread_pool.keep_alive_time="5000"
- thread_pool.queue_enabled="true"
- thread_pool.queue_max_size="100000"
- thread_pool.rejection_policy="discard"
-
- oob_thread_pool.enabled="true"
- oob_thread_pool.min_threads="1"
- oob_thread_pool.max_threads="8"
- oob_thread_pool.keep_alive_time="5000"
- oob_thread_pool.queue_enabled="false"
- oob_thread_pool.queue_max_size="100"
- oob_thread_pool.rejection_policy="discard"/>
-
- <PING timeout="2000"
- num_initial_members="3"/>
- <MERGE3/>
- <FD_SOCK />
- <FD_ALL />
- <VERIFY_SUSPECT timeout="1500" />
- <BARRIER />
- <pbcast.NAKACK use_mcast_xmit="true"
- retransmit_timeout="100,300,600,1200"
- discard_delivered_msgs="true"/>
- <UNICAST3 conn_expiry_timeout="0"/>
- <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
- max_bytes="1000000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="5000"
- max_bundling_time="200"
- view_bundling="true"/>
- <FC max_credits="2M"
- min_threshold="0.40"/>
- <FRAG2 frag_size="60000" />
- <pbcast.FLUSH />
- <RELAY site="apex" bridge_props="xml/jgroups-tcp.xml" />
-
-</config>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
index c999c95f0..c3c137349 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
@@ -22,13 +22,19 @@ package org.onap.policy.apex.plugins.context.distribution.hazelcast;
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.context.test.distribution.ContextAlbumUpdate;
import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
import org.onap.policy.apex.context.test.distribution.ContextUpdate;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -37,13 +43,45 @@ public class HazelcastContextDistributorTest {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(HazelcastContextDistributorTest.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ @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
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateHazelcast test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateHazelcast test");
@@ -53,8 +91,6 @@ public class HazelcastContextDistributorTest {
public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationHazelcast test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationHazelcast test");
@@ -64,11 +100,8 @@ public class HazelcastContextDistributorTest {
public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateHazelcast test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateHazelcast test");
}
-
}
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
index 9361d0b4c..d6a04dd7c 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
@@ -25,8 +25,9 @@ import java.util.Map;
import org.infinispan.Cache;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.impl.distribution.AbstractDistributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -71,7 +72,7 @@ public class InfinispanContextDistributor extends AbstractDistributor {
if (infinispanManager == null) {
// Get the parameters from the parameter service
final InfinispanDistributorParameters parameters =
- ParameterService.getParameters(InfinispanDistributorParameters.class);
+ ParameterService.get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
LOGGER.debug("initiating Infinispan with the parameters: " + parameters);
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
index d73955224..539a732cf 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.plugins.context.distribution.infinispan;
import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Distributor parameters for the Infinspan Distributor.
@@ -30,9 +29,9 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*/
public class InfinispanDistributorParameters extends DistributorParameters {
// @formatter:off
-
+
/** The default Infinispan configuration file location. */
- public static final String DEFAULT_INFINISPAN_DISTRIBUTION_CONFIG_FILE = "/infinispan/infinispan.xml";
+ public static final String DEFAULT_INFINISPAN_DISTRIBUTION_CONFIG_FILE = "infinispan/infinispan.xml";
/** The default Infinispan jgroups configuration file location. */
public static final String DEFAULT_INFINISPAN_DISTRIBUTION_JGROUPS_FILE = null;
@@ -54,9 +53,7 @@ public class InfinispanDistributorParameters extends DistributorParameters {
* The Constructor.
*/
public InfinispanDistributorParameters() {
- super(InfinispanDistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(InfinispanDistributorParameters.class, this);
- ParameterService.registerParameters(DistributorParameters.class, this);
+ super();
}
/**
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml
new file mode 100644
index 000000000..028cf1df6
--- /dev/null
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml
@@ -0,0 +1,76 @@
+<?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/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml.sample b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml
index 302eac935..5b416f50d 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml.sample
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml
@@ -19,22 +19,23 @@
============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="default-configs/default-jgroups-tcp.xml" />
- </jgroups>
+<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="external-file" path="infinispan/default-jgroups-tcp.xml" />
+ </jgroups>
- <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
- <transport cluster="apexCluster" stack="tcpStack" />
- <jmx />
- <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- <replicated-cache name="TestContext_0.0.1" mode="SYNC">
- <state-transfer enabled="true" />
- </replicated-cache>
- </cache-container>
+ <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
+ <transport cluster="apexCluster" stack="external-file" />
+ <jmx />
+ <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ <replicated-cache name="TestContext_0.0.1" mode="SYNC">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ </cache-container>
</infinispan>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
index 34fa7d439..862dcef83 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
@@ -21,14 +21,20 @@ package org.onap.policy.apex.plugins.context.distribution.infinispan;
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.context.test.distribution.ContextAlbumUpdate;
import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
import org.onap.policy.apex.context.test.distribution.ContextUpdate;
import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -37,14 +43,47 @@ public class InfinispanContextDistributorTest {
private static final String PLUGIN_CLASS = InfinispanContextDistributor.class.getCanonicalName();
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @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
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
+
@Test
public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateInfinispan test");
@@ -54,10 +93,6 @@ public class InfinispanContextDistributorTest {
public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationInfinispan test");
@@ -67,10 +102,6 @@ public class InfinispanContextDistributorTest {
public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateInfinispan test");
@@ -80,14 +111,8 @@ public class InfinispanContextDistributorTest {
public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testSequentialContextInstantiationInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new SequentialContextInstantiation().testSequentialContextInstantiation();
logger.debug("Ran testSequentialContextInstantiationInfinispan test");
}
-
-
}
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
index 477a010fa..d2976d799 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
@@ -33,13 +33,13 @@ import org.apache.zookeeper.CreateMode;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.impl.locking.AbstractLockManager;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class CuratorLockManager manages the Curator interface towards Zookeeper for administering
- * the Apex Context Album instance locks..
+ * The Class CuratorLockManager manages the Curator interface towards Zookeeper for administering the Apex Context Album
+ * instance locks..
*/
public class CuratorLockManager extends AbstractLockManager {
// Logger for this class
@@ -65,8 +65,8 @@ public class CuratorLockManager extends AbstractLockManager {
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.context.impl.locking.AbstractLockManager#init(org.onap.policy.apex.
- * model. basicmodel.concepts.AxArtifactKey)
+ * @see org.onap.policy.apex.context.impl.locking.AbstractLockManager#init(org.onap.policy.apex. model.
+ * basicmodel.concepts.AxArtifactKey)
*/
@Override
public void init(final AxArtifactKey key) throws ContextException {
@@ -75,23 +75,22 @@ public class CuratorLockManager extends AbstractLockManager {
super.init(key);
// Get the lock manager parameters
- final CuratorLockManagerParameters lockParameters =
- ParameterService.getParameters(CuratorLockManagerParameters.class);
+ final CuratorLockManagerParameters lockParameters = ParameterService
+ .get(CuratorLockManagerParameters.class.getSimpleName());
// Check if the curator address has been set
curatorZookeeperAddress = lockParameters.getZookeeperAddress();
if (curatorZookeeperAddress == null || curatorZookeeperAddress.trim().length() == 0) {
- LOGGER.warn(
- "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
+ LOGGER.warn("could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
throw new ContextException(
- "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
+ "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
}
// Set up the curator framework we'll use
curatorFramework = CuratorFrameworkFactory.builder().connectString(curatorZookeeperAddress)
- .retryPolicy(new ExponentialBackoffRetry(lockParameters.getZookeeperConnectSleepTime(),
- lockParameters.getZookeeperContextRetries()))
- .build();
+ .retryPolicy(new ExponentialBackoffRetry(lockParameters.getZookeeperConnectSleepTime(),
+ lockParameters.getZookeeperContextRetries()))
+ .build();
// Listen for changes on the Curator connection
curatorFramework.getConnectionStateListenable().addListener(new CuratorManagerConnectionStateListener());
@@ -102,22 +101,22 @@ public class CuratorLockManager extends AbstractLockManager {
// Wait for the connection to be made
try {
curatorFramework.blockUntilConnected(
- lockParameters.getZookeeperConnectSleepTime() * lockParameters.getZookeeperContextRetries(),
- TimeUnit.MILLISECONDS);
+ lockParameters.getZookeeperConnectSleepTime() * lockParameters.getZookeeperContextRetries(),
+ TimeUnit.MILLISECONDS);
} catch (final InterruptedException e) {
// restore the interrupt status
Thread.currentThread().interrupt();
- LOGGER.warn("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", wait for connection timed out");
- throw new ContextException("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", wait for connection timed out");
+ String message = "error connecting to Zookeeper server at \"" + curatorZookeeperAddress
+ + "\", wait for connection timed out";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
if (!curatorFramework.getZookeeperClient().isConnected()) {
- LOGGER.warn("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", see error log for details");
- throw new ContextException("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", see error log for details");
+ String message = "could not connect to Zookeeper server at \"" + curatorZookeeperAddress
+ + "\", see error log for details";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
// We'll use Ephemeral nodes for locks on the Zookeeper server
@@ -129,8 +128,7 @@ public class CuratorLockManager extends AbstractLockManager {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.core.context.impl.locking.AbstractLockManager#getReentrantReadWriteLock(
+ * @see org.onap.policy.apex.core.context.impl.locking.AbstractLockManager#getReentrantReadWriteLock(
* java.lang.String)
*/
@Override
@@ -140,7 +138,7 @@ public class CuratorLockManager extends AbstractLockManager {
return new CuratorReentrantReadWriteLock(curatorFramework, "/" + lockId);
} else {
throw new ContextException("creation of lock using Zookeeper server at \"" + curatorZookeeperAddress
- + "\", failed, see error log for details");
+ + "\", failed, see error log for details");
}
}
@@ -176,8 +174,8 @@ public class CuratorLockManager extends AbstractLockManager {
return;
}
- LOGGER.info("curator state of client \"" + curatorFramework + "\" connected to \"" + curatorZookeeperAddress
- + "\" changed to " + newState);
+ LOGGER.info("curator state of client \"{}\" connected to \"{}\" changed to {}", curatorFramework,
+ curatorZookeeperAddress, newState);
if (newState != ConnectionState.CONNECTED) {
shutdown();
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
index 9e8d5d2af..ac936d436 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.plugins.context.locking.curator;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Bean class for Curator locking parameters.
@@ -49,8 +48,7 @@ public class CuratorLockManagerParameters extends LockManagerParameters {
* The Constructor.
*/
public CuratorLockManagerParameters() {
- super(CuratorLockManagerParameters.class.getCanonicalName());
- ParameterService.registerParameters(CuratorLockManagerParameters.class, this);
+ super();
}
/**
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java
index 65eef39c2..5198e82e0 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java
@@ -26,10 +26,12 @@ import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,29 @@ public class TestAvroSchemaAAI {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
+
aaiInventoryResponseSchema =
TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testAAIResponsePolicy() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", aaiInventoryResponseSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java
index 21fab66d9..b72b2ca10 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java
@@ -25,10 +25,12 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -36,6 +38,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,28 @@ public class TestAvroSchemaArray {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
longArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleLong.avsc");
addressArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleAddress.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testArrayInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -77,7 +93,7 @@ public class TestAvroSchemaArray {
@Test
public void testLongArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", longArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", longArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -89,7 +105,7 @@ public class TestAvroSchemaArray {
@Test
public void testAddressArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java
index ae19cd31a..47a5c969c 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java
@@ -26,10 +26,12 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.avro.generic.GenericData.EnumSymbol;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,14 +54,27 @@ public class TestAvroSchemaEnum {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
enumSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/EnumSchema.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testEnumInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -73,7 +89,7 @@ public class TestAvroSchemaEnum {
@Test
public void testEnumUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java
index 41f622115..6d709645f 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java
@@ -27,10 +27,12 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Fixed;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -38,6 +40,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -52,14 +55,27 @@ public class TestAvroSchemaFixed {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
fixedSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/FixedSchema.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testFixedInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -82,7 +98,7 @@ public class TestAvroSchemaFixed {
@Test
public void testFixedUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java
index 1e1a0bee0..9cb027acf 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java
@@ -23,15 +23,18 @@ package org.onap.policy.apex.plugins.context.schema.avro;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
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;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -45,12 +48,25 @@ public class TestAvroSchemaHelperBadSchemas {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
+ }
+
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
public void badSchemaTest() {
- final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "Avro", "}");
+ final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "AVRO", "}");
schemas.getSchemasMap().put(avroBadSchema0.getKey(), avroBadSchema0);
try {
@@ -61,7 +77,7 @@ public class TestAvroSchemaHelperBadSchemas {
.startsWith("AvroTest:0.0.1: avro context schema \"AvroBad0:0.0.1\" schema is invalid"));
}
- final AxContextSchema avroBadSchema1 = new AxContextSchema(new AxArtifactKey("AvroBad1", "0.0.1"), "Avro", "");
+ final AxContextSchema avroBadSchema1 = new AxContextSchema(new AxArtifactKey("AvroBad1", "0.0.1"), "AVRO", "");
schemas.getSchemasMap().put(avroBadSchema1.getKey(), avroBadSchema1);
try {
@@ -73,7 +89,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema2 =
- new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "Avro", "{}");
+ new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "AVRO", "{}");
schemas.getSchemasMap().put(avroBadSchema2.getKey(), avroBadSchema2);
try {
@@ -85,7 +101,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema3 =
- new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "Avro", "{zooby}");
+ new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "AVRO", "{zooby}");
schemas.getSchemasMap().put(avroBadSchema3.getKey(), avroBadSchema3);
try {
@@ -97,7 +113,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema4 =
- new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "Avro", "{\"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "AVRO", "{\"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema4.getKey(), avroBadSchema4);
try {
@@ -109,7 +125,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema5 =
- new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "Avro", "{\"type\": \"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "AVRO", "{\"type\": \"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema5.getKey(), avroBadSchema5);
try {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java
index a710a2376..1f078879d 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java
@@ -24,16 +24,19 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
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;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -47,13 +50,26 @@ public class TestAvroSchemaHelperMarshal {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
+ }
+
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
public void testNullMarshal() {
final AxContextSchema avroNullSchema =
- new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "Avro", "{\"type\": \"null\"}");
+ new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
final SchemaHelper schemaHelper0 =
@@ -67,7 +83,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testBooleanMarshal() {
final AxContextSchema avroBooleanSchema =
- new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "Avro", "{\"type\": \"boolean\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
final SchemaHelper schemaHelper1 =
@@ -98,7 +114,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testIntMarshal() {
final AxContextSchema avroIntSchema =
- new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "Avro", "{\"type\": \"int\"}");
+ new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
final SchemaHelper schemaHelper2 =
@@ -130,7 +146,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testLongMarshal() {
final AxContextSchema avroLongSchema =
- new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "Avro", "{\"type\": \"long\"}");
+ new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
final SchemaHelper schemaHelper3 =
@@ -160,7 +176,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testFloatMarshal() {
final AxContextSchema avroFloatSchema =
- new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "Avro", "{\"type\": \"float\"}");
+ new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
final SchemaHelper schemaHelper4 =
@@ -195,7 +211,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testDoubleMarshal() {
final AxContextSchema avroDoubleSchema =
- new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "Avro", "{\"type\": \"double\"}");
+ new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
final SchemaHelper schemaHelper5 =
@@ -229,7 +245,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testStringMarshal() {
final AxContextSchema avroStringSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"string\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
final SchemaHelper schemaHelper7 =
@@ -257,7 +273,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testBytesMarshal() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"bytes\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java
index 725ebb221..db7edd673 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java
@@ -25,16 +25,19 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.apache.avro.util.Utf8;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
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;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -48,24 +51,37 @@ public class TestAvroSchemaHelperUnmarshal {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
}
- // @Test
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
+ @Test
public void testNullUnmarshal() {
- final AxContextSchema avroNullSchema =
- new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "Avro", "{\"type\": \"null\"}");
+ final AxContextSchema avroNullSchema = new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO",
+ "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
- final SchemaHelper schemaHelper0 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey());
+ final SchemaHelper schemaHelper0 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroNullSchema.getKey());
try {
schemaHelper0.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
assertEquals("AvroTest:0.0.1: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
assertEquals(null, schemaHelper0.unmarshal("null"));
@@ -74,28 +90,26 @@ public class TestAvroSchemaHelperUnmarshal {
schemaHelper0.unmarshal("123");
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: object \"123\" Avro unmarshalling failed: Expected null. Got VALUE_NUMBER_INT",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: object \"123\" Avro unmarshalling failed: Expected null. Got VALUE_NUMBER_INT",
+ e.getMessage());
}
}
- // @Test
+ @Test
public void testBooleanUnmarshal() {
- final AxContextSchema avroBooleanSchema =
- new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "Avro", "{\"type\": \"boolean\"}");
+ final AxContextSchema avroBooleanSchema = new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO",
+ "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
- final SchemaHelper schemaHelper1 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey());
+ final SchemaHelper schemaHelper1 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroBooleanSchema.getKey());
try {
schemaHelper1.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default constructor \"Boolean()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default constructor \"Boolean()\"",
+ e.getMessage());
}
assertEquals(true, schemaHelper1.createNewInstance("true"));
@@ -105,28 +119,27 @@ public class TestAvroSchemaHelperUnmarshal {
schemaHelper1.unmarshal(0);
fail("Test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: object \"0\" Avro unmarshalling failed: Expected boolean. Got VALUE_NUMBER_INT",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: object \"0\" of type \"java.lang.Integer\" must be assignable to "
+ + "\"java.lang.Boolean\" or be a Json string representation of it for "
+ + "Avro unmarshalling", e.getMessage());
}
}
- // @Test
+ @Test
public void testIntUnmarshal() {
- final AxContextSchema avroIntSchema =
- new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "Avro", "{\"type\": \"int\"}");
+ final AxContextSchema avroIntSchema = new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO",
+ "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
- final SchemaHelper schemaHelper2 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey());
+ final SchemaHelper schemaHelper2 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroIntSchema.getKey());
try {
schemaHelper2.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" using the default constructor \"Integer()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" using the default constructor \"Integer()\"",
+ e.getMessage());
}
assertEquals(123, schemaHelper2.createNewInstance("123"));
@@ -142,40 +155,39 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"2147483648\" Avro unmarshalling failed: Numeric value (2147483648) out of range of int"));
+ "AvroTest:0.0.1: object \"2147483648\" Avro unmarshalling failed: Numeric value (2147483648) out of range of int"));
}
try {
schemaHelper2.unmarshal("-2147483649");
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"-2147483649\" Avro unmarshalling failed: Numeric value (-2147483649) out of range of int"));
+ "AvroTest:0.0.1: object \"-2147483649\" Avro unmarshalling failed: Numeric value (-2147483649) out of range of int"));
}
try {
schemaHelper2.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
- // @Test
+ @Test
public void testLongUnmarshal() {
- final AxContextSchema avroLongSchema =
- new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "Avro", "{\"type\": \"long\"}");
+ final AxContextSchema avroLongSchema = new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO",
+ "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
- final SchemaHelper schemaHelper3 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey());
+ final SchemaHelper schemaHelper3 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroLongSchema.getKey());
try {
schemaHelper3.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default constructor \"Long()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default constructor \"Long()\"",
+ e.getMessage());
}
assertEquals(123456789L, schemaHelper3.createNewInstance("123456789"));
@@ -191,47 +203,46 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"9223372036854775808\" Avro unmarshalling failed: Numeric value (9223372036854775808) out of range of long"));
+ "AvroTest:0.0.1: object \"9223372036854775808\" Avro unmarshalling failed: Numeric value (9223372036854775808) out of range of long"));
}
try {
schemaHelper3.unmarshal("-9223372036854775809");
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"-9223372036854775809\" Avro unmarshalling failed: Numeric value (-9223372036854775809) out of range of long"));
+ "AvroTest:0.0.1: object \"-9223372036854775809\" Avro unmarshalling failed: Numeric value (-9223372036854775809) out of range of long"));
}
try {
schemaHelper3.unmarshal("\"Hello\"");
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected long. Got VALUE_STRING"));
+ "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected long. Got VALUE_STRING"));
}
try {
schemaHelper3.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
- // @Test
+ @Test
public void testFloatUnmarshal() {
- final AxContextSchema avroFloatSchema =
- new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "Avro", "{\"type\": \"float\"}");
+ final AxContextSchema avroFloatSchema = new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO",
+ "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
- final SchemaHelper schemaHelper4 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey());
+ final SchemaHelper schemaHelper4 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroFloatSchema.getKey());
try {
schemaHelper4.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" using the default constructor \"Float()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" using the default constructor \"Float()\"",
+ e.getMessage());
}
assertEquals(1.2345F, schemaHelper4.createNewInstance("1.2345"));
@@ -249,33 +260,32 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected float. Got VALUE_STRING"));
+ "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected float. Got VALUE_STRING"));
}
try {
schemaHelper4.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
- // @Test
+ @Test
public void testDoubleUnmarshal() {
- final AxContextSchema avroDoubleSchema =
- new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "Avro", "{\"type\": \"double\"}");
+ final AxContextSchema avroDoubleSchema = new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO",
+ "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
- final SchemaHelper schemaHelper5 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey());
+ final SchemaHelper schemaHelper5 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroDoubleSchema.getKey());
try {
schemaHelper5.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" using the default constructor \"Double()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" using the default constructor \"Double()\"",
+ e.getMessage());
}
assertEquals(1.2345E06, schemaHelper5.createNewInstance("1.2345E06"));
@@ -293,25 +303,25 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected double. Got VALUE_STRING"));
+ "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected double. Got VALUE_STRING"));
}
try {
schemaHelper5.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
@Test
public void testStringUnmarshal() {
- final AxContextSchema avroStringSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"string\"}");
+ final AxContextSchema avroStringSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
+ "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
- final SchemaHelper schemaHelper7 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey());
+ final SchemaHelper schemaHelper7 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroStringSchema.getKey());
assertEquals("", schemaHelper7.createNewInstance(""));
assertEquals("1.2345E06", schemaHelper7.createNewInstance("1.2345E06"));
@@ -332,14 +342,14 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
@Test
public void testBytesUnmarshal() {
- final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"bytes\"}");
+ final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
+ "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -348,9 +358,8 @@ public class TestAvroSchemaHelperUnmarshal {
schemaHelper.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" using the default constructor \"Byte[]()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" using the default constructor \"Byte[]()\"",
+ e.getMessage());
}
final byte[] newBytes = (byte[]) schemaHelper.createNewInstance("\"hello\"");
assertEquals(5, newBytes.length);
@@ -365,7 +374,7 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java
index 33ca512b9..7bf6b0029 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java
@@ -27,10 +27,12 @@ import java.io.IOException;
import java.util.HashMap;
import org.apache.avro.util.Utf8;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -38,6 +40,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -54,17 +57,30 @@ public class TestAvroSchemaMap {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
longMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleLong.avsc");
addressMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddress.avsc");
addressMapSchemaInvalidFields =
TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testMapInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -82,7 +98,7 @@ public class TestAvroSchemaMap {
@Test
public void testLongMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "Avro", longMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", longMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -94,7 +110,7 @@ public class TestAvroSchemaMap {
@Test
public void testAddressMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "Avro", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -106,7 +122,7 @@ public class TestAvroSchemaMap {
@Test
public void testAddressMapUnmarshalMarshalInvalidFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "Avro", addressMapSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java
index e14236064..000dcc9fd 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java
@@ -25,10 +25,12 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -36,6 +38,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -53,7 +56,6 @@ public class TestAvroSchemaRecord {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
recordSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExample.avsc");
recordSchemaVPN = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPN.avsc");
recordSchemaVPNReuse = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPNReuse.avsc");
@@ -61,10 +63,24 @@ public class TestAvroSchemaRecord {
TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testRecordInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -80,7 +96,7 @@ public class TestAvroSchemaRecord {
@Test
public void testRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -92,7 +108,7 @@ public class TestAvroSchemaRecord {
@Test
public void testRecordUnmarshalMarshalInvalid() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -103,7 +119,7 @@ public class TestAvroSchemaRecord {
@Test
public void testVPNRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchemaVPN);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVPN);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -114,7 +130,7 @@ public class TestAvroSchemaRecord {
@Test
public void testVPNRecordReuse() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchemaVPNReuse);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVPNReuse);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
index 100b51d44..33cb20328 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
@@ -25,11 +25,13 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,28 @@ public class TestAvroSchemaUnion {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
uinionSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/UnionExample.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Ignore
@Test
public void testUnionAllFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -76,7 +92,7 @@ public class TestAvroSchemaUnion {
@Test
public void testUnionOptionalField() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -94,7 +110,7 @@ public class TestAvroSchemaUnion {
@Test
public void testUnionNullField() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java
index 026125af9..42764a1ca 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java
@@ -28,10 +28,12 @@ import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.Record;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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.AxKey;
@@ -39,6 +41,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -53,15 +56,27 @@ public class TestHealthCheckSchema {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
healthCheckSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/HealthCheckBodyType.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
@Test
public void testHealthCheck() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", healthCheckSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", healthCheckSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
index 878882d6b..93174b941 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
@@ -96,7 +96,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
InitialContext jmsContext = null;
ConnectionFactory connectionFactory = null;
try {
- jmsContext = new InitialContext(jmsConsumerProperties.getJMSConsumerProperties());
+ jmsContext = new InitialContext(jmsConsumerProperties.getJmsConsumerProperties());
connectionFactory = (ConnectionFactory) jmsContext.lookup(jmsConsumerProperties.getConnectionFactory());
// Check if we actually got a connection factory
@@ -107,7 +107,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
+ jmsConsumerProperties.getConnectionFactory() + "\" failed for JMS consumer properties \""
- + jmsConsumerProperties.getJMSConsumerProperties() + "\"";
+ + jmsConsumerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -123,7 +123,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsConsumerProperties.getConsumerTopic()
- + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJMSConsumerProperties()
+ + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJmsConsumerProperties()
+ "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -136,7 +136,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to the JMS server failed for JMS properties \""
- + jmsConsumerProperties.getJMSConsumerProperties() + "\"";
+ + jmsConsumerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
index edf78637d..86e9555f9 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
@@ -58,9 +58,6 @@ public class ApexJMSProducer implements ApexEventProducer {
// The connection to the JMS server
private Connection connection;
- // The topic on which we send events to JMS
- private Topic jmsOutgoingTopic;
-
// The JMS session on which we will send events
private Session jmsSession;
@@ -96,7 +93,7 @@ public class ApexJMSProducer implements ApexEventProducer {
InitialContext jmsContext = null;
ConnectionFactory connectionFactory = null;
try {
- jmsContext = new InitialContext(jmsProducerProperties.getJMSProducerProperties());
+ jmsContext = new InitialContext(jmsProducerProperties.getJmsProducerProperties());
connectionFactory = (ConnectionFactory) jmsContext.lookup(jmsProducerProperties.getConnectionFactory());
// Check if we actually got a connection factory
@@ -107,12 +104,13 @@ public class ApexJMSProducer implements ApexEventProducer {
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
+ jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Lookup the topic on which we will send events
+ Topic jmsOutgoingTopic;
try {
jmsOutgoingTopic = (Topic) jmsContext.lookup(jmsProducerProperties.getProducerTopic());
@@ -123,7 +121,7 @@ public class ApexJMSProducer implements ApexEventProducer {
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJMSProducerProperties()
+ + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
+ "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -136,7 +134,7 @@ public class ApexJMSProducer implements ApexEventProducer {
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -146,7 +144,7 @@ public class ApexJMSProducer implements ApexEventProducer {
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -157,7 +155,7 @@ public class ApexJMSProducer implements ApexEventProducer {
} catch (final Exception e) {
final String errorMessage =
"creation of producer for sending events to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\"";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
index dfa8dc28a..80977b5d8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
@@ -25,6 +25,8 @@ import java.util.Properties;
import javax.naming.Context;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for JMS as an event carrier technology.
@@ -99,7 +101,7 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
// JMS carrier parameters
private String connectionFactory = DEFAULT_CONNECTION_FACTORY;
private String initialContextFactory = DEFAULT_INITIAL_CONTEXT_FACTORY;
- private String providerURL = DEFAULT_PROVIDER_URL;
+ private String providerUrl = DEFAULT_PROVIDER_URL;
private String securityPrincipal = DEFAULT_SECURITY_PRINCIPAL;
private String securityCredentials = DEFAULT_SECURITY_CREDENTIALS;
private String producerTopic = DEFAULT_PRODUCER_TOPIC;
@@ -113,7 +115,7 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
* service.
*/
public JMSCarrierTechnologyParameters() {
- super(JMSCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the JMS carrier technology
this.setLabel(JMS_CARRIER_TECHNOLOGY_LABEL);
@@ -126,15 +128,8 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the JMS producer properties
*/
- public Properties getJMSProducerProperties() {
- final Properties jmsProperties = new Properties();
-
- jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
- jmsProperties.put(PROPERTY_PROVIDER_URL, providerURL);
- jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal);
- jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials);
-
- return jmsProperties;
+ public Properties getJmsProducerProperties() {
+ return getJmsProperties();
}
/**
@@ -142,11 +137,20 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the jms consumer properties
*/
- public Properties getJMSConsumerProperties() {
+ public Properties getJmsConsumerProperties() {
+ return getJmsProperties();
+ }
+
+ /**
+ * Gets the JMS consumer properties.
+ *
+ * @return the jms consumer properties
+ */
+ private Properties getJmsProperties() {
final Properties jmsProperties = new Properties();
jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
- jmsProperties.put(PROPERTY_PROVIDER_URL, providerURL);
+ jmsProperties.put(PROPERTY_PROVIDER_URL, providerUrl);
jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal);
jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials);
@@ -176,8 +180,8 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the provider URL
*/
- public String getProviderURL() {
- return providerURL;
+ public String getProviderUrl() {
+ return providerUrl;
}
/**
@@ -246,10 +250,10 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
/**
* Sets the provider URL.
*
- * @param providerURL the provider URL
+ * @param providerUrl the provider URL
*/
- public void setProviderURL(final String providerURL) {
- this.providerURL = providerURL;
+ public void setProviderUrl(final String providerUrl) {
+ this.providerUrl = providerUrl;
}
/**
@@ -321,48 +325,51 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (initialContextFactory == null || initialContextFactory.trim().length() == 0) {
- errorMessageBuilder
- .append(" initialContextFactory not specified, must be specified as a string that is a class"
- + " that implements the interface org.jboss.naming.remote.client.InitialContextFactory\n");
+ result.setResult("initialContextFactory", ValidationStatus.INVALID,
+ "initialContextFactory must be specified as a string that is a class that implements the "
+ + "interface org.jboss.naming.remote.client.InitialContextFactory");
}
- if (providerURL == null || providerURL.trim().length() == 0) {
- errorMessageBuilder.append(
- " providerURL not specified, must be specified as a URL string that specifies the location of "
- + "configuration information for the service provider to use such as remote://localhost:4447\n");
+ if (providerUrl == null || providerUrl.trim().length() == 0) {
+ result.setResult("providerUrl", ValidationStatus.INVALID,
+ "providerUrl must be specified as a URL string that specifies the location of "
+ + "configuration information for the service provider to use "
+ + "such as remote://localhost:4447");
}
if (securityPrincipal == null || securityPrincipal.trim().length() == 0) {
- errorMessageBuilder.append(
- " securityPrincipal not specified, must be specified the identity of the principal for authenticating the caller to the service\n");
+ result.setResult("securityPrincipal", ValidationStatus.INVALID,
+ "securityPrincipal must be specified the identity of the principal for authenticating "
+ + "the caller to the service");
}
if (securityCredentials == null || securityCredentials.trim().length() == 0) {
- errorMessageBuilder.append(" securityCredentials not specified, must be specified as "
- + "the credentials of the principal for authenticating the caller to the service\n");
+ result.setResult("securityCredentials", ValidationStatus.INVALID,
+ " securityCredentials must be specified as the credentials of the "
+ + "principal for authenticating the caller to the service");
}
if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(
- " producerTopic not specified, must be a string that identifies the JMS topic on which Apex will send events\n");
+ result.setResult("producerTopic", ValidationStatus.INVALID,
+ " producerTopic must be a string that identifies the JMS topic "
+ + "on which Apex will send events");
}
if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(
- " consumerTopic not specified, must be a string that identifies the JMS topic on which Apex will recieve events\n");
+ result.setResult("consumerTopic", ValidationStatus.INVALID,
+ " consumerTopic must be a string that identifies the JMS topic "
+ + "on which Apex will recieve events");
}
if (consumerWaitTime < 0) {
- errorMessageBuilder.append(" consumerWaitTime [" + consumerWaitTime
- + "] invalid, must be specified as consumerWaitTime >= 0\n");
+ result.setResult("consumerWaitTime", ValidationStatus.INVALID,
+ "[" + consumerWaitTime + "] invalid, must be specified as consumerWaitTime >= 0");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
index 2357b1807..5ce96662e 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
@@ -25,6 +25,8 @@ import java.util.Collection;
import java.util.Properties;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for Kafka as an event carrier technology.
@@ -42,6 +44,9 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
/** The consumer plugin class for the Kafka carrier technology. */
public static final String KAFKA_EVENT_CONSUMER_PLUGIN_CLASS = ApexKafkaConsumer.class.getCanonicalName();
+ // Repeated strings in messages
+ private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string";
+
// Default parameter values
private static final String DEFAULT_ACKS = "all";
private static final String DEFAULT_BOOTSTRAP_SERVERS = "localhost:9092";
@@ -102,7 +107,7 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
* service.
*/
public KAFKACarrierTechnologyParameters() {
- super(KAFKACarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the kafka carrier technology
this.setLabel(KAFKA_CARRIER_TECHNOLOGY_LABEL);
@@ -308,89 +313,107 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
- if (bootstrapServers == null || bootstrapServers.trim().length() == 0) {
- errorMessageBuilder
- .append(" bootstrapServers not specified, must be specified as a string of form host:port\n");
+ if (isNullOrBlank(bootstrapServers)) {
+ result.setResult("bootstrapServers", ValidationStatus.INVALID,
+ "not specified, must be specified as a string of form host:port");
}
- if (acks == null || acks.trim().length() == 0) {
- errorMessageBuilder.append(" acks not specified, must be specified as a string with values [0|1|all]\n");
+ if (isNullOrBlank(acks)) {
+ result.setResult("acks", ValidationStatus.INVALID,
+ "not specified, must be specified as a string with values [0|1|all]");
}
if (retries < 0) {
- errorMessageBuilder.append(" retries [" + retries + "] invalid, must be specified as retries >= 0\n");
+ result.setResult(PROPERTY_RETRIES, ValidationStatus.INVALID,
+ "[" + retries + "] invalid, must be specified as retries >= 0");
}
if (batchSize < 0) {
- errorMessageBuilder
- .append(" batchSize [" + batchSize + "] invalid, must be specified as batchSize >= 0\n");
+ result.setResult("batchSize", ValidationStatus.INVALID,
+ "[" + batchSize + "] invalid, must be specified as batchSize >= 0");
}
if (lingerTime < 0) {
- errorMessageBuilder
- .append(" lingerTime [" + lingerTime + "] invalid, must be specified as lingerTime >= 0\n");
+ result.setResult("lingerTime", ValidationStatus.INVALID,
+ "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0");
}
if (bufferMemory < 0) {
- errorMessageBuilder
- .append(" bufferMemory [" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0\n");
+ result.setResult("bufferMemory", ValidationStatus.INVALID,
+ "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0");
}
- if (groupId == null || groupId.trim().length() == 0) {
- errorMessageBuilder.append(" groupId not specified, must be specified as a string\n");
+ if (isNullOrBlank(groupId)) {
+ result.setResult("groupId", ValidationStatus.INVALID, SPECIFY_AS_STRING_MESSAGE);
}
if (autoCommitTime < 0) {
- errorMessageBuilder.append(
- " autoCommitTime [" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0\n");
+ result.setResult("autoCommitTime", ValidationStatus.INVALID,
+ "[" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0");
}
if (sessionTimeout < 0) {
- errorMessageBuilder.append(
- " sessionTimeout [" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0\n");
+ result.setResult("sessionTimeout", ValidationStatus.INVALID,
+ "[" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0");
}
- if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" producerTopic not specified, must be specified as a string\n");
+ if (isNullOrBlank(producerTopic)) {
+ result.setResult("producerTopic", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
if (consumerPollTime < 0) {
- errorMessageBuilder.append(" consumerPollTime [" + consumerPollTime
- + "] invalid, must be specified as consumerPollTime >= 0\n");
+ result.setResult("consumerPollTime", ValidationStatus.INVALID,
+ "[" + consumerPollTime + "] invalid, must be specified as consumerPollTime >= 0");
}
- if (consumerTopicList == null || consumerTopicList.length == 0) {
- errorMessageBuilder.append(" consumerTopicList not specified, must be specified as a list of strings\n");
+ validateConsumerTopicList(result);
+
+ if (isNullOrBlank(keySerializer)) {
+ result.setResult("keySerializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- for (final String consumerTopic : consumerTopicList) {
- if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
- + "\" specified on consumerTopicList, consumer topics must be specified as strings\n");
- }
+ if (isNullOrBlank(valueSerializer)) {
+ result.setResult("valueSerializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (keySerializer == null || keySerializer.trim().length() == 0) {
- errorMessageBuilder.append(" keySerializer not specified, must be specified as a string\n");
+ if (isNullOrBlank(keyDeserializer)) {
+ result.setResult("keyDeserializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (valueSerializer == null || valueSerializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueSerializer not specified, must be specified as a string\n");
+ if (isNullOrBlank(valueDeserializer)) {
+ result.setResult("valueDeserializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (keyDeserializer == null || keyDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" keyDeserializer not specified, must be specified as a string\n");
+ return result;
+ }
+
+ private void validateConsumerTopicList(final GroupValidationResult result) {
+ if (consumerTopicList == null || consumerTopicList.length == 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ "not specified, must be specified as a list of strings");
}
- if (valueDeserializer == null || valueDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueDeserializer not specified, must be specified as a string\n");
+ StringBuilder consumerTopicStringBuilder = new StringBuilder();
+ for (final String consumerTopic : consumerTopicList) {
+ if (consumerTopic == null || consumerTopic.trim().length() == 0) {
+ consumerTopicStringBuilder.append(consumerTopic + "/");
+ }
+ }
+ if (consumerTopicStringBuilder.length() > 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ "invalid consumer topic list entries found: /" + consumerTopicStringBuilder.toString());
}
+ }
- return errorMessageBuilder.toString();
+ private boolean isNullOrBlank(final String stringValue) {
+ return stringValue == null || stringValue.trim().length() == 0;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
index e07593c55..59d19f76b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -60,7 +62,7 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
* service.
*/
public RESTClientCarrierTechnologyParameters() {
- super(RESTClientCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTCLIENT_CARRIER_TECHNOLOGY_LABEL);
@@ -115,20 +117,19 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
return "RESTClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
}
-
/*
*
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
// Check if the URL has been set for event output
if (getURL() == null) {
- errorMessageBuilder.append(" no URL has been set for event sending on REST client");
+ result.setResult("url", ValidationStatus.INVALID, "no URL has been set for event sending on REST client");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
index eb5870058..9b841d768 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
@@ -68,7 +68,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
* service.
*/
public RESTRequestorCarrierTechnologyParameters() {
- super(RESTRequestorCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTREQUESTOR_CARRIER_TECHNOLOGY_LABEL);
@@ -122,14 +122,4 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
public String toString() {
return "RESTRequestorCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
- */
- @Override
- public String validate() {
- return "";
- }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
index d4eb434c7..70d567b0d 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
@@ -286,6 +286,6 @@ public class TestRESTRequestor {
System.setErr(stderr);
assertTrue(outString.contains(
- "event input for peered mode \"REQUESTOR\": peer \"RestRequestorProducer\" for event handler \"RestRequestorConsumer\" does not exist or is not defined as being synchronous"));
+ "peer \"RestRequestorProducer for peered mode REQUESTOR does not exist or is not defined with the same peered mode"));
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
index 47e31fffa..cd7f388f2 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -63,7 +65,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* service.
*/
public RESTServerCarrierTechnologyParameters() {
- super(RESTServerCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTSERVER_CARRIER_TECHNOLOGY_LABEL);
@@ -105,32 +107,30 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
// Check if host is defined, it is only defined on REST server consumers
if (standalone) {
- if (host != null) {
- if (host.trim().length() == 0) {
- errorMessageBuilder.append(" host not specified, must be host as a string\n");
- }
+ if (host != null && host.trim().length() == 0) {
+ result.setResult("host", ValidationStatus.INVALID,
+ "host not specified, host must be specified as a string");
}
// Check if port is defined, it is only defined on REST server consumers
- if (port != -1) {
- if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
- errorMessageBuilder
- .append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
- }
+ if (port != -1 && port < MIN_USER_PORT || port > MAX_USER_PORT) {
+ result.setResult("port", ValidationStatus.INVALID,
+ "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
}
} else {
- if (host != null || port != -1) {
- errorMessageBuilder.append(" host and port are specified only in standalone mode\n");
+ if (host != null) {
+ result.setResult("host", ValidationStatus.INVALID, "host is specified only in standalone mode");
+ }
+ if (port != -1) {
+ result.setResult("port", ValidationStatus.INVALID, "port is specified only in standalone mode");
}
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
index e8009a5d8..e04a81d1d 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.websocket;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for Kafka as an event carrier technology.
@@ -56,7 +58,7 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* parameter service.
*/
public WEBSOCKETCarrierTechnologyParameters() {
- super(WEBSOCKETCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
@@ -97,19 +99,18 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (wsClient && (host == null || host.trim().length() == 0)) {
- errorMessageBuilder.append(" host not specified, must be host as a string\n");
+ result.setResult("host", ValidationStatus.INVALID, "host not specified, must be host as a string");
}
if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
- errorMessageBuilder.append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
+ result.setResult("port", ValidationStatus.INVALID,
+ "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
index 40196eb8a..c5f6cb781 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
@@ -37,7 +37,6 @@ 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.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -48,13 +47,14 @@ import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.HeaderDelimitedTextBlockReader;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock;
+import org.onap.policy.common.parameters.ParameterService;
public class TestYamlEventProtocol {
@BeforeClass
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+ ParameterService.register(schemaParameters, true);
AxContextSchemas schemas = new AxContextSchemas();
@@ -199,6 +199,7 @@ public class TestYamlEventProtocol {
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
+ ParameterService.clear();
}
@Test
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
index 126a01df7..57b4b72d6 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
@@ -34,7 +34,6 @@ 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.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -43,6 +42,7 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
+import org.onap.policy.common.parameters.ParameterService;
public class TestYamlPluginStability {
static AxEvent testEvent;
@@ -51,7 +51,7 @@ public class TestYamlPluginStability {
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+ ParameterService.register(schemaParameters);
AxContextSchemas schemas = new AxContextSchemas();
@@ -89,6 +89,7 @@ public class TestYamlPluginStability {
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
+ ParameterService.clear();
}
@Test
diff --git a/pom.xml b/pom.xml
index 3a34680af..c7431a26c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,7 @@
<version.hibernate>5.3.1.Final</version.hibernate>
<version.dom4j>1.6</version.dom4j>
<version.policy.common>1.3.0-SNAPSHOT</version.policy.common>
+ <version.policy.parameters>1.3.0-SNAPSHOT</version.policy.parameters>
</properties>
<distributionManagement>
@@ -88,6 +89,11 @@
<artifactId>utils</artifactId>
<version>${version.policy.common}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ <version>${version.policy.parameters}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
diff --git a/services/services-engine/pom.xml b/services/services-engine/pom.xml
index face719f8..2b40baa6a 100644
--- a/services/services-engine/pom.xml
+++ b/services/services-engine/pom.xml
@@ -36,6 +36,10 @@
<artifactId>utils</artifactId>
</dependency>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.apex-pdp.core</groupId>
<artifactId>core-engine</artifactId>
<version>${project.version}</version>
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java
index 10cd58eb7..27970f982 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/ApexEventProtocolParameters.java
@@ -32,16 +32,15 @@ public class ApexEventProtocolParameters extends EventProtocolParameters {
public static final String APEX_EVENT_PROTOCOL_LABEL = "APEX";
/**
- * Constructor to create a JSON event protocol parameter instance and register the instance with
- * the parameter service.
+ * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter
+ * service.
*/
public ApexEventProtocolParameters() {
this(ApexEventProtocolParameters.class.getCanonicalName(), APEX_EVENT_PROTOCOL_LABEL);
}
/**
- * Constructor to create an event protocol parameters instance with the name of a sub class of
- * this class.
+ * Constructor to create an event protocol parameters instance with the name of a sub class of this class.
*
* @param parameterClassName the class name of a sub class of this class
* @param eventProtocolLabel the name of the event protocol for this plugin
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java
index fb722ea2f..839b4bffe 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorCarrierTechnologyParameters.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.service.engine.event.impl.eventrequestor;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
/**
* This class holds the parameters that allows an output event to to be sent back into APEX as one
@@ -47,7 +48,7 @@ public class EventRequestorCarrierTechnologyParameters extends CarrierTechnology
* the instance with the parameter service.
*/
public EventRequestorCarrierTechnologyParameters() {
- super(EventRequestorCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the EVENT_REQUESTOR carrier technology
this.setLabel(EVENT_REQUESTOR_CARRIER_TECHNOLOGY_LABEL);
@@ -61,7 +62,15 @@ public class EventRequestorCarrierTechnologyParameters extends CarrierTechnology
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- return "";
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.policy.common.parameters.ParameterGroup#getName()
+ */
+ @Override
+ public String getName() {
+ return this.getLabel();
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java
index 76f9b4bb3..84d19fc62 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java
@@ -23,23 +23,25 @@ package org.onap.policy.apex.service.engine.event.impl.filecarrierplugin;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.producer.ApexFileEventProducer;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.utils.resources.ResourceUtils;
/**
- * This class holds the parameters that allows transport of events into and out of Apex using files
- * and standard input and output.
+ * This class holds the parameters that allows transport of events into and out of Apex using files and standard input
+ * and output.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
* <li>fileName: The full path to the file from which to read events or to which to write events.
- * <li>standardIO: If this flag is set to true, then standard input is used to read events in or
- * standard output is used to write events and the fileName parameter is ignored if present
+ * <li>standardIO: If this flag is set to true, then standard input is used to read events in or standard output is used
+ * to write events and the fileName parameter is ignored if present
* <li>standardError: If this flag is set to true, then standard error is used to write events
- * <li>streamingMode: If this flag is set to true, then streaming mode is set for reading events and
- * event handling will wait on the input stream for events until the stream is closed. If streaming
- * model is off, then event reading completes when the end of input is detected.
- * <li>startDelay: The amount of milliseconds to wait at startup startup before processing the first
- * event.
+ * <li>streamingMode: If this flag is set to true, then streaming mode is set for reading events and event handling will
+ * wait on the input stream for events until the stream is closed. If streaming model is off, then event reading
+ * completes when the end of input is detected.
+ * <li>startDelay: The amount of milliseconds to wait at startup startup before processing the first event.
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -63,11 +65,11 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters
// @formatter:on
/**
- * Constructor to create a file carrier technology parameters instance and register the instance
- * with the parameter service.
+ * Constructor to create a file carrier technology parameters instance and register the instance with the parameter
+ * service.
*/
public FILECarrierTechnologyParameters() {
- super(FILECarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the FILE carrier technology
this.setLabel(FILE_CARRIER_TECHNOLOGY_LABEL);
@@ -168,14 +170,23 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters#
- * toString()
+ * @see org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters# toString()
*/
@Override
public String toString() {
return "FILECarrierTechnologyParameters [fileName=" + fileName + ", standardIO=" + standardIO
- + ", standardError=" + standardError + ", streamingMode=" + streamingMode + ", startDelay=" + startDelay
- + "]";
+ + ", standardError=" + standardError + ", streamingMode=" + streamingMode + ", startDelay="
+ + startDelay + "]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.common.parameters.ParameterGroup#getName()
+ */
+ @Override
+ public String getName() {
+ return this.getLabel();
}
/*
@@ -184,14 +195,12 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (!standardIO && !standardError && (fileName == null || fileName.trim().length() == 0)) {
- errorMessageBuilder.append(
- " fileName not specified or is blank or null, it must be specified as a valid file location\n");
+ result.setResult("fileName", ValidationStatus.INVALID,
+ "fileName not specified or is blank or null, it must be specified as a valid file location");
}
if (standardIO || standardError) {
@@ -199,9 +208,10 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters
}
if (startDelay < 0) {
- errorMessageBuilder.append(" startDelay must be zero or a positive number of milliseconds\n");
+ result.setResult("startDelay", ValidationStatus.INVALID,
+ "startDelay must be zero or a positive number of milliseconds");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java
index 56eaa4a1e..6efcceb43 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java
@@ -87,6 +87,14 @@ public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedP
this.setEventProtocolPluginClass(Apex2JSONEventConverter.class.getCanonicalName());
}
+ /* (non-Javadoc)
+ * @see org.onap.policy.common.parameters.ParameterGroup#getName()
+ */
+ @Override
+ public String getName() {
+ return this.getLabel();
+ }
+
/**
* Gets the name alias.
*
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
index 2124b3118..ee5f9ae72 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
@@ -45,6 +45,7 @@ import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
import org.onap.policy.apex.service.engine.runtime.EngineService;
import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -156,9 +157,9 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
LOGGER.warn("Engine service configuration parameters is null");
throw new ApexException("engine service configuration parameters is null");
}
- final String validation = config.validate();
- if (validation != null && validation.length() > 0) {
- LOGGER.warn("Invalid engine service configuration parameters: " + validation);
+ final GroupValidationResult validation = config.validate();
+ if (!validation.isValid()) {
+ LOGGER.warn("Invalid engine service configuration parameters: {}" + validation.getResult());
throw new ApexException("Invalid engine service configuration parameters: " + validation);
}
final AxArtifactKey engineServiceKey = config.getEngineKey();
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterValidator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterConstants.java
index a8cbe3b46..1937fd2bf 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterValidator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterConstants.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
@@ -21,16 +21,18 @@
package org.onap.policy.apex.service.parameters;
/**
- * This interface is implemented by Apex parameter classes so that they can be validated.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
+ * This class holds constants used when managing parameter groups in apex.
*/
-public interface ApexParameterValidator {
+public abstract class ApexParameterConstants {
+ public static final String MAIN_GROUP_NAME = "APEX_PARAMETERS";
+ public static final String ENGINE_SERVICE_GROUP_NAME = "ENGINE_SERVICE_PARAMETERS";
+ public static final String EVENT_HANDLER_GROUP_NAME = "EVENT_HANDLER_PARAMETERS";
+
/**
- * Validate a parameter java bean, if the parameter bean is valid, an empty string is returned,
- * otherwise the string gives details of the invalid parameters.
- *
- * @return the string with validation errors
+ * Private default constructor to prevent subclassing
*/
- String validate();
+ private ApexParameterConstants() {
+ // Prevents subclassing
+ }
+
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java
deleted file mode 100644
index 2bc064593..000000000
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java
+++ /dev/null
@@ -1,52 +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.service.parameters;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-
-/**
- * This exception will be called if an error occurs in Apex parameter handling.
- *
- * @author Liam Fallon
- */
-public class ApexParameterException extends ApexException {
- private static final long serialVersionUID = -8507246953751956974L;
-
- /**
- * Instantiates a new apex parameter handling exception with a message.
- *
- * @param message the message
- */
- public ApexParameterException(final String message) {
- super(message);
- }
-
- /**
- * Instantiates a new apex parameter handling exception with a message and a caused by
- * exception.
- *
- * @param message the message
- * @param ex the exception that caused this exception to be thrown
- */
- public ApexParameterException(final String message, final Exception ex) {
- super(message, ex);
- }
-}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
index 31209bf08..c93e52118 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
@@ -29,6 +29,9 @@ import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnolo
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParametersJSONAdapter;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParametersJSONAdapter;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -48,9 +51,12 @@ public class ApexParameterHandler {
*
* @param arguments the arguments passed to Apex
* @return the parameters read from the configuration file
- * @throws ApexParameterException on parameter exceptions
+ * @throws ParameterException on parameter exceptions
*/
- public ApexParameters getParameters(final ApexCommandLineArguments arguments) throws ApexParameterException {
+ public ApexParameters getParameters(final ApexCommandLineArguments arguments) throws ParameterException {
+ // Clear all existing parameters
+ ParameterService.clear();
+
ApexParameters parameters = null;
// Read the parameters
@@ -58,27 +64,27 @@ public class ApexParameterHandler {
// Register the adapters for our carrier technologies and event protocols with GSON
// @formatter:off
final Gson gson = new GsonBuilder()
- .registerTypeAdapter(EngineParameters .class,
- new EngineServiceParametersJSONAdapter())
- .registerTypeAdapter(CarrierTechnologyParameters.class,
- new CarrierTechnologyParametersJSONAdapter())
- .registerTypeAdapter(EventProtocolParameters .class,
- new EventProtocolParametersJSONAdapter())
- .create();
+ .registerTypeAdapter(EngineParameters .class,
+ new EngineServiceParametersJSONAdapter())
+ .registerTypeAdapter(CarrierTechnologyParameters.class,
+ new CarrierTechnologyParametersJSONAdapter())
+ .registerTypeAdapter(EventProtocolParameters .class,
+ new EventProtocolParametersJSONAdapter())
+ .create();
// @formatter:on
parameters = gson.fromJson(new FileReader(arguments.getFullConfigurationFilePath()), ApexParameters.class);
} catch (final Exception e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
- + "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
+ + "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
LOGGER.error(errorMessage, e);
- throw new ApexParameterException(errorMessage, e);
+ throw new ParameterException(errorMessage, e);
}
// The JSON processing returns null if there is an empty file
if (parameters == null) {
final String errorMessage = "no parameters found in \"" + arguments.getConfigurationFilePath() + "\"";
LOGGER.error(errorMessage);
- throw new ApexParameterException(errorMessage);
+ throw new ParameterException(errorMessage);
}
// Check if we should override the model file parameter
@@ -87,17 +93,43 @@ public class ApexParameterHandler {
parameters.getEngineServiceParameters().setPolicyModelFileName(modelFilePath);
}
- // validate the parameters
- final String validationResult = parameters.validate();
- if (!validationResult.isEmpty()) {
- String returnMessage =
- "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
- returnMessage += validationResult;
+ // Validate the parameters
+ final GroupValidationResult validationResult = parameters.validate();
+ if (!validationResult.isValid()) {
+ String returnMessage = "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath()
+ + "\"\n";
+ returnMessage += validationResult.getResult();
LOGGER.error(returnMessage);
- throw new ApexParameterException(returnMessage);
+ throw new ParameterException(returnMessage);
}
+ if (!validationResult.isClean()) {
+ String returnMessage = "validation messages(s) on parameters from \"" + arguments.getConfigurationFilePath()
+ + "\"\n";
+ returnMessage += validationResult.getResult();
+
+ LOGGER.info(returnMessage);
+ }
+
+ // Register the parameters with the parameter service
+ registerParameters(parameters);
+
return parameters;
}
+
+ /**
+ * Register all the incoming parameters with the parameter service
+ * @param parameters The parameters to register
+ */
+ private void registerParameters(ApexParameters parameters) {
+ ParameterService.register(parameters);
+ ParameterService.register(parameters.getEngineServiceParameters());
+ ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters());
+ ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters());
+ ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getSchemaParameters());
+ ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getDistributorParameters());
+ ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getLockManagerParameters());
+ ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getPersistorParameters());
+ }
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java
deleted file mode 100644
index a4917f1b6..000000000
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java
+++ /dev/null
@@ -1,52 +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.service.parameters;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-
-/**
- * This exception will be called if an error occurs in Apex parameter handling.
- *
- * @author Liam Fallon
- */
-public class ApexParameterRuntimeException extends ApexRuntimeException {
- private static final long serialVersionUID = -8507246953751956974L;
-
- /**
- * Instantiates a new apex parameter handling exception with a message.
- *
- * @param message the message
- */
- public ApexParameterRuntimeException(final String message) {
- super(message);
- }
-
- /**
- * Instantiates a new apex parameter handling exception with a message and a caused by
- * exception.
- *
- * @param message the message
- * @param ex the exception that caused this exception to be thrown
- */
- public ApexParameterRuntimeException(final String message, final Exception ex) {
- super(message, ex);
- }
-}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
index 9c65c0b32..069bcc9a8 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
@@ -27,38 +27,47 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* The main container parameter class for an Apex service.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
- * <li>engineServiceParameters: The parameters for the Apex engine service itself, such as the
- * number of engine threads to run and the deployment port number to use.
- * <li>eventOutputParameters: A map of parameters for event outputs that Apex will use to emit
- * events. Apex emits events on all outputs
- * <li>eventInputParameters: A map or parameters for event inputs from which Apex will consume
- * events. Apex reads events from all its event inputs.
- * <li>synchronousEventHandlerParameters: A map of parameters for synchronous event handlers That
- * Apex receives events from and replies immediately to those events.
+ * <li>engineServiceParameters: The parameters for the Apex engine service itself, such as the number of engine threads
+ * to run and the deployment port number to use.
+ * <li>eventOutputParameters: A map of parameters for event outputs that Apex will use to emit events. Apex emits events
+ * on all outputs
+ * <li>eventInputParameters: A map or parameters for event inputs from which Apex will consume events. Apex reads events
+ * from all its event inputs.
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexParameters extends AbstractParameters implements ApexParameterValidator {
+public class ApexParameters implements ParameterGroup {
+ // Parameter group name
+ private String name;
+
+ // Constants for recurring strings
+ private static final String PEER_STRING = "peer ";
+ private static final String EVENT_INPUT_PARAMETERS_STRING = "eventInputParameters";
+ private static final String EVENT_OUTPUT_PARAMETERS_STRING = "eventOutputParameters";
+ private static final String FOR_PEERED_MODE_STRING = " for peered mode ";
+
/**
- * Constructor to create an apex parameters instance and register the instance with the
- * parameter service.
+ * Constructor to create an apex parameters instance and register the instance with the parameter service.
*/
public ApexParameters() {
- super(ContextParameters.class.getCanonicalName());
- ParameterService.registerParameters(ApexParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ApexParameterConstants.MAIN_GROUP_NAME;
}
// Parameters for the engine service and the engine threads in the engine service
@@ -124,92 +133,78 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV
this.eventInputParameters = eventInputParameters;
}
- /**
- * This method formats a validation result with a header if the result is not empty.
- *
- * @param validationResultMessage The incoming message
- * @param heading The heading to prepend on the message
- * @return the formatted message
- */
- private String validationResultFormatter(final String validationResultMessage, final String heading) {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- if (validationResultMessage.length() > 0) {
- errorMessageBuilder.append(heading);
- errorMessageBuilder.append(validationResultMessage);
- }
+ @Override
+ public String getName() {
+ return name;
+ }
- return errorMessageBuilder.toString();
+ @Override
+ public void setName(final String name) {
+ this.name = name;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
- */
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ GroupValidationResult result = new GroupValidationResult(this);
if (engineServiceParameters == null) {
- errorMessageBuilder.append(" engine service parameters are not specified\n");
+ result.setResult("engineServiceParameters", ValidationStatus.INVALID,
+ "engine service parameters are not specified");
} else {
- errorMessageBuilder.append(validationResultFormatter(engineServiceParameters.validate(),
- " engine service parameters invalid\n"));
+ result.setResult("engineServiceParameters", engineServiceParameters.validate());
}
// Sanity check, we must have an entry in both output and input maps
- if (eventOutputParameters.isEmpty() || eventInputParameters.isEmpty()) {
- errorMessageBuilder.append(" at least one event output and one event input must be specified\n");
+ if (eventInputParameters.isEmpty()) {
+ result.setResult(EVENT_INPUT_PARAMETERS_STRING, ValidationStatus.INVALID,
+ "at least one event input must be specified");
+ }
+
+ if (eventOutputParameters.isEmpty()) {
+ result.setResult(EVENT_OUTPUT_PARAMETERS_STRING, ValidationStatus.INVALID,
+ "at least one event output must be specified");
}
// Validate that the values of all parameters are ok
- validateEventHandlerMap("event input", errorMessageBuilder, eventInputParameters);
- validateEventHandlerMap("event output", errorMessageBuilder, eventOutputParameters);
+ validateEventHandlerMap(EVENT_INPUT_PARAMETERS_STRING, result, eventInputParameters);
+ validateEventHandlerMap(EVENT_OUTPUT_PARAMETERS_STRING, result, eventOutputParameters);
// Only do peer mode validate if there are no other errors
- if (errorMessageBuilder.length() == 0) {
+ if (result.isValid()) {
for (final EventHandlerPeeredMode peeredMode : EventHandlerPeeredMode.values()) {
- validatePeeredMode(errorMessageBuilder, peeredMode);
+ validatePeeredMode(result, peeredMode);
}
}
- // Check if we have any errors
- if (errorMessageBuilder.length() > 0) {
- errorMessageBuilder.insert(0, "Apex parameters invalid\n");
- }
-
- return errorMessageBuilder.toString().trim();
+ return result;
}
/**
* This method validates the parameters in an event handler map.
*
* @param eventHandlerType the type of the event handler to use on error messages
- * @param errorMessageBuilder the builder to use to return validation messages
+ * @param result the result object to use to return validation messages
* @param parsForValidation The event handler parameters to validate (input or output)
*/
- // CHECKSTYLE:OFF: checkstyle:finalParameter
- private void validateEventHandlerMap(final String eventHandlerType, final StringBuilder errorMessageBuilder,
- final Map<String, EventHandlerParameters> parsForValidation) {
- // CHECKSTYLE:ON: checkstyle:finalParameter
+ private void validateEventHandlerMap(final String eventHandlerType, final GroupValidationResult result,
+ final Map<String, EventHandlerParameters> parsForValidation) {
for (final Entry<String, EventHandlerParameters> parameterEntry : parsForValidation.entrySet()) {
if (parameterEntry.getKey() == null || parameterEntry.getKey().trim().isEmpty()) {
- errorMessageBuilder
- .append(" invalid " + eventHandlerType + " name \"" + parameterEntry.getKey() + "\" \n");
+ result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ "invalid " + eventHandlerType + " name \"" + parameterEntry.getKey() + "\"");
} else if (parameterEntry.getValue() == null) {
- errorMessageBuilder.append(" invalid/Null event input prameters specified for " + eventHandlerType
- + " name \"" + parameterEntry.getKey() + "\" \n");
+ result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ "invalid/Null event input prameters specified for " + eventHandlerType + " name \""
+ + parameterEntry.getKey() + "\" ");
} else {
- errorMessageBuilder.append(validationResultFormatter(parameterEntry.getValue().validate(),
- " " + eventHandlerType + " (" + parameterEntry.getKey() + ") parameters invalid\n"));
+ result.setResult(eventHandlerType, parameterEntry.getKey(), parameterEntry.getValue().validate());
}
parameterEntry.getValue().setName(parameterEntry.getKey());
// Validate parameters for peered mode settings
for (final EventHandlerPeeredMode peeredMode : EventHandlerPeeredMode.values()) {
- validatePeeredModeParameters(eventHandlerType, errorMessageBuilder, parameterEntry, peeredMode);
+ validatePeeredModeParameters(eventHandlerType, result, parameterEntry, peeredMode);
}
}
}
@@ -218,34 +213,36 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV
* Validate parameter values for event handlers in a peered mode.
*
* @param eventHandlerType The event handler type we are checking
- * @param errorMessageBuilder The builder to which to append any error messages
+ * @param result The result object to which to append any error messages
* @param parameterEntry The entry to check the peered mode on
* @param peeredMode The mode to check
*/
- private void validatePeeredModeParameters(final String eventHandlerType, final StringBuilder errorMessageBuilder,
- final Entry<String, EventHandlerParameters> parameterEntry, final EventHandlerPeeredMode peeredMode) {
- final String messagePreamble = " specified peered mode \"" + peeredMode + "\"";
+ private void validatePeeredModeParameters(final String eventHandlerType, final GroupValidationResult result,
+ final Entry<String, EventHandlerParameters> parameterEntry,
+ final EventHandlerPeeredMode peeredMode) {
+ final String messagePreamble = "specified peered mode \"" + peeredMode + "\"";
final String peer = parameterEntry.getValue().getPeer(peeredMode);
if (parameterEntry.getValue().isPeeredMode(peeredMode)) {
if (peer == null || peer.trim().isEmpty()) {
- errorMessageBuilder.append(messagePreamble + " mandatory parameter not specified or is null on "
- + eventHandlerType + " \"" + parameterEntry.getKey() + "\" \n");
+ result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ messagePreamble + " mandatory parameter not specified or is null");
}
if (parameterEntry.getValue().getPeerTimeout(peeredMode) < 0) {
- errorMessageBuilder.append(
- messagePreamble + " timeout value \"" + parameterEntry.getValue().getPeerTimeout(peeredMode)
- + "\" is illegal on " + eventHandlerType + " \"" + parameterEntry.getKey()
- + "\", specify a non-negative timeout value in milliseconds\n");
+ result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, messagePreamble
+ + " timeout value \"" + parameterEntry.getValue().getPeerTimeout(peeredMode)
+ + "\" is illegal, specify a non-negative timeout value in milliseconds");
}
} else {
if (peer != null) {
- errorMessageBuilder.append(messagePreamble + " peer is illegal on non synchronous " + eventHandlerType
- + " \"" + parameterEntry.getKey() + "\" \n");
+ result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ messagePreamble + " peer is illegal on " + eventHandlerType + " \""
+ + parameterEntry.getKey() + "\" ");
}
if (parameterEntry.getValue().getPeerTimeout(peeredMode) != 0) {
- errorMessageBuilder.append(messagePreamble + " timeout is illegal on non synchronous "
- + eventHandlerType + " \"" + parameterEntry.getKey() + "\" \n");
+ result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID,
+ messagePreamble + " timeout is illegal on " + eventHandlerType + " \""
+ + parameterEntry.getKey() + "\"");
}
}
}
@@ -253,10 +250,10 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV
/**
* This method validates that the settings are valid for the given peered mode.
*
- * @param errorMessageBuilder The builder to which to append any error messages
+ * @param result The result object to which to append any error messages
* @param peeredMode The peered mode to check
*/
- private void validatePeeredMode(final StringBuilder errorMessageBuilder, final EventHandlerPeeredMode peeredMode) {
+ private void validatePeeredMode(final GroupValidationResult result, final EventHandlerPeeredMode peeredMode) {
// Find the input and output event handlers that use this peered mode
final Map<String, EventHandlerParameters> inputParametersUsingMode = new HashMap<>();
final Map<String, EventHandlerParameters> outputParametersUsingMode = new HashMap<>();
@@ -274,23 +271,24 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV
}
// Validate the parameters for each side of the peered mode parameters
- validatePeeredModePeers(" event input for peered mode \"" + peeredMode + "\": ", errorMessageBuilder,
- peeredMode, inputParametersUsingMode, outputParametersUsingMode);
- validatePeeredModePeers(" event output for peered mode \"" + peeredMode + "\": ", errorMessageBuilder,
- peeredMode, outputParametersUsingMode, inputParametersUsingMode);
+ validatePeeredModePeers(EVENT_INPUT_PARAMETERS_STRING, result, peeredMode, inputParametersUsingMode,
+ outputParametersUsingMode);
+ validatePeeredModePeers(EVENT_OUTPUT_PARAMETERS_STRING, result, peeredMode, outputParametersUsingMode,
+ inputParametersUsingMode);
}
/**
* This method validates that the settings are valid for the event handlers on one.
*
- * @param messagePreamble the preamble for messages indicating the peered mode side
- * @param errorMessageBuilder The builder to which to append any error messages
+ * @param handlerMapVariableName the variable name of the map on which the paired parameters are being checked
+ * @param result The result object to which to append any error messages
* @param leftModeParameters The mode parameters being checked
* @param rightModeParameters The mode parameters being referenced by the checked parameters
*/
- private void validatePeeredModePeers(final String messagePreamble, final StringBuilder errorMessageBuilder,
- final EventHandlerPeeredMode peeredMode, final Map<String, EventHandlerParameters> leftModeParameterMap,
- final Map<String, EventHandlerParameters> rightModeParameterMap) {
+ private void validatePeeredModePeers(final String handlerMapVariableName, final GroupValidationResult result,
+ final EventHandlerPeeredMode peeredMode,
+ final Map<String, EventHandlerParameters> leftModeParameterMap,
+ final Map<String, EventHandlerParameters> rightModeParameterMap) {
// These sets are used to check for duplicate references on the both sides
final Set<String> leftCheckDuplicateSet = new HashSet<>();
@@ -306,52 +304,74 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV
// Check that the peer reference is OK
if (rightModeParameters == null) {
- errorMessageBuilder.append(messagePreamble + "peer \"" + leftModeParameters.getPeer(peeredMode)
- + "\" for event handler \"" + leftModeParameterEntry.getKey()
- + "\" does not exist or is not defined as being synchronous\n");
+ result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
+ + " does not exist or is not defined with the same peered mode");
continue;
}
// Now check that the right side peer is the left side event handler
final String rightSidePeer = rightModeParameters.getPeer(peeredMode);
if (!rightSidePeer.equals(leftModeParameterEntry.getKey())) {
- errorMessageBuilder
- .append(messagePreamble + "peer value \"" + rightSidePeer + "\" on peer \"" + leftSidePeer
- + "\" does not equal event handler \"" + leftModeParameterEntry.getKey() + "\"\n");
+ result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
+ + ", value \"" + rightSidePeer + "\" on peer \"" + leftSidePeer
+ + "\" does not equal event handler \"" + leftModeParameterEntry.getKey()
+ + "\"");
} else {
// Check for duplicates
if (!leftCheckDuplicateSet.add(leftSidePeer)) {
- errorMessageBuilder
- .append(messagePreamble + "peer value \"" + leftSidePeer + "\" on event handler \""
- + leftModeParameterEntry.getKey() + "\" is used more than once\n");
+ result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING
+ + peeredMode + ", peer value \"" + leftSidePeer
+ + "\" on event handler \"" + leftModeParameterEntry.getKey()
+ + "\" is used more than once");
}
if (!rightCheckDuplicateSet.add(rightSidePeer)) {
- errorMessageBuilder.append(messagePreamble + "peer value \"" + rightSidePeer + "\" on peer \""
- + leftSidePeer + "\" on event handler \"" + leftModeParameterEntry.getKey()
- + "\" is used more than once\n");
+ result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING
+ + peeredMode + ", peer value \"" + rightSidePeer + "\" on peer \""
+ + leftSidePeer + "\" on event handler \""
+ + leftModeParameterEntry.getKey() + "\" is used more than once");
}
}
- // Cross-set the timeouts if they are not specified
- if (leftModeParameters.getPeerTimeout(peeredMode) != 0) {
- if (rightModeParameters.getPeerTimeout(peeredMode) != 0) {
- if (leftModeParameters.getPeerTimeout(peeredMode) != rightModeParameters
- .getPeerTimeout(peeredMode)) {
- errorMessageBuilder.append(messagePreamble + "timeout "
- + leftModeParameters.getPeerTimeout(peeredMode) + "on event handler \""
- + leftModeParameters.getName() + "\" does not equal timeout value "
- + rightModeParameters.getPeerTimeout(peeredMode) + "on event handler \""
- + rightModeParameters.getName() + "\"\n");
- }
- } else {
- rightModeParameters.setPeerTimeout(peeredMode, leftModeParameters.getPeerTimeout(peeredMode));
+ if (!crossCheckPeeredTimeoutValues(leftModeParameters, rightModeParameters, peeredMode)) {
+ result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID,
+ PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode
+ + " timeout " + leftModeParameters.getPeerTimeout(peeredMode)
+ + " on event handler \"" + leftModeParameters.getName()
+ + "\" does not equal timeout "
+ + rightModeParameters.getPeerTimeout(peeredMode) + " on event handler \""
+ + rightModeParameters.getName() + "\"");
+
+ }
+ }
+ }
+
+ /**
+ * Validate the timeout values on two peers.
+ *
+ * @param leftModeParameters The parameters of the left hand peer
+ * @param peeredMode The peered mode being checked
+ * @return true if the timeout values are cross checked as being OK
+ */
+ private boolean crossCheckPeeredTimeoutValues(final EventHandlerParameters leftModeParameters,
+ final EventHandlerParameters rightModeParameters, final EventHandlerPeeredMode peeredMode) {
+ // Cross-set the timeouts if they are not specified
+ if (leftModeParameters.getPeerTimeout(peeredMode) != 0) {
+ if (rightModeParameters.getPeerTimeout(peeredMode) != 0) {
+ if (leftModeParameters.getPeerTimeout(peeredMode) != rightModeParameters.getPeerTimeout(peeredMode)) {
+ return false;
}
} else {
- if (rightModeParameters.getPeerTimeout(peeredMode) != 0) {
- leftModeParameters.setPeerTimeout(peeredMode, rightModeParameters.getPeerTimeout(peeredMode));
- }
+ rightModeParameters.setPeerTimeout(peeredMode, leftModeParameters.getPeerTimeout(peeredMode));
+ }
+ } else {
+ if (rightModeParameters.getPeerTimeout(peeredMode) != 0) {
+ leftModeParameters.setPeerTimeout(peeredMode, rightModeParameters.getPeerTimeout(peeredMode));
}
}
-
+ return true;
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java
index 025183328..0c10df706 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java
@@ -20,25 +20,28 @@
package org.onap.policy.apex.service.parameters.carriertechnology;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterValidator;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterRuntimeException;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
- * The default carrier technology parameter class that may be specialized by carrier technology
- * plugins that require plugin specific parameters.
+ * The default carrier technology parameter class that may be specialized by carrier technology plugins that require
+ * plugin specific parameters.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
* <li>label: The label of the carrier technology.
- * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce
- * and emit output events for this carrier technology
- * <li>eventConsumerPluginClass: The name of the plugin class that will be used by Apex to receive
- * and process input events from this carrier technology carrier technology
+ * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
+ * events for this carrier technology
+ * <li>eventConsumerPluginClass: The name of the plugin class that will be used by Apex to receive and process input
+ * events from this carrier technology carrier technology
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class CarrierTechnologyParameters extends AbstractParameters implements ApexParameterValidator {
+public abstract class CarrierTechnologyParameters implements ParameterGroup {
// The carrier technology label
private String label = null;
@@ -49,13 +52,13 @@ public abstract class CarrierTechnologyParameters extends AbstractParameters imp
private String eventConsumerPluginClass = null;
/**
- * Constructor to create a carrier technology parameters instance with the name of a sub class
- * of this class and register the instance with the parameter service.
+ * Constructor to create a carrier technology parameters instance with the name of a sub class of this class and
+ * register the instance with the parameter service.
*
* @param parameterClassName the class name of a sub class of this class
*/
- public CarrierTechnologyParameters(final String parameterClassName) {
- super(parameterClassName);
+ public CarrierTechnologyParameters() {
+ super();
}
/**
@@ -132,7 +135,7 @@ public abstract class CarrierTechnologyParameters extends AbstractParameters imp
@Override
public String toString() {
return "CarrierTechnologyParameters [label=" + label + ", eventProducerPluginClass=" + eventProducerPluginClass
- + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
+ + ", eventConsumerPluginClass=" + eventConsumerPluginClass + "]";
}
/*
@@ -141,21 +144,34 @@ public abstract class CarrierTechnologyParameters extends AbstractParameters imp
* @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = new GroupValidationResult(this);
if (label == null || label.length() == 0) {
- errorMessageBuilder.append(" carrier technology label not specified or is blank\n");
+ result.setResult("label", ValidationStatus.INVALID, "carrier technology label not specified or is blank");
}
if (eventProducerPluginClass == null || eventProducerPluginClass.length() == 0) {
- errorMessageBuilder.append(" carrier technology eventProducerPluginClass not specified or is blank\n");
+ result.setResult("eventProducerPluginClass", ValidationStatus.INVALID,
+ "carrier technology eventProducerPluginClass not specified or is blank");
}
if (eventConsumerPluginClass == null || eventConsumerPluginClass.length() == 0) {
- errorMessageBuilder.append(" carrier technology eventConsumerPluginClass not specified or is blank\n");
+ result.setResult("eventConsumerPluginClass", ValidationStatus.INVALID,
+ "carrier technology eventConsumerPluginClass not specified or is blank");
}
- return errorMessageBuilder.toString();
+ return result;
}
+
+ @Override
+ public String getName() {
+ return this.getLabel();
+ }
+
+ @Override
+ public void setName(final String name) {
+ throw new ParameterRuntimeException("the name/label of this carrier technology is always \"" + getLabel() + "\"");
+ }
+
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java
index 38abd3c6c..e443c1eb0 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java
@@ -26,7 +26,7 @@ import java.util.Map;
import org.onap.policy.apex.service.engine.event.impl.eventrequestor.EventRequestorCarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterRuntimeException;
+import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -34,7 +34,6 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -74,7 +73,7 @@ public class CarrierTechnologyParametersJSONAdapter
final JsonSerializationContext context) {
final String returnMessage = "serialization of Apex carrier technology parameters to Json is not supported";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
/*
@@ -85,7 +84,7 @@ public class CarrierTechnologyParametersJSONAdapter
*/
@Override
public CarrierTechnologyParameters deserialize(final JsonElement json, final Type typeOfT,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) {
final JsonObject jsonObject = json.getAsJsonObject();
// Get the carrier technology label primitive
@@ -103,7 +102,7 @@ public class CarrierTechnologyParametersJSONAdapter
final String errorMessage = "carrier technology parameter \"" + CARRIER_TECHNOLOGY_TOKEN + "\" value \""
+ labelJsonPrimitive.getAsString() + "\" invalid in JSON file";
LOGGER.warn(errorMessage);
- throw new ApexParameterRuntimeException(errorMessage);
+ throw new ParameterRuntimeException(errorMessage);
}
// We now get the technology carrier parameter class
@@ -130,7 +129,7 @@ public class CarrierTechnologyParametersJSONAdapter
+ (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null")
+ "\" invalid in JSON file";
LOGGER.warn(errorMessage);
- throw new ApexParameterRuntimeException(errorMessage);
+ throw new ParameterRuntimeException(errorMessage);
}
// Get the class for the carrier technology
@@ -142,7 +141,7 @@ public class CarrierTechnologyParametersJSONAdapter
"carrier technology \"" + carrierTechnologyLabel + "\" parameter \"" + PARAMETER_CLASS_NAME
+ "\" value \"" + carrierTechnologyParameterClassName + "\", could not find class";
LOGGER.warn(errorMessage, e);
- throw new ApexParameterRuntimeException(errorMessage, e);
+ throw new ParameterRuntimeException(errorMessage, e);
}
// Deserialise the class
@@ -158,7 +157,7 @@ public class CarrierTechnologyParametersJSONAdapter
final String errorMessage = "could not create default parameters for carrier technology \""
+ carrierTechnologyLabel + "\"\n" + e.getMessage();
LOGGER.warn(errorMessage, e);
- throw new ApexParameterRuntimeException(errorMessage, e);
+ throw new ParameterRuntimeException(errorMessage, e);
}
}
@@ -170,7 +169,7 @@ public class CarrierTechnologyParametersJSONAdapter
+ "\", specify correct carrier technology parameter plugin in parameter \"" + PARAMETER_CLASS_NAME
+ "\"";
LOGGER.warn(errorMessage);
- throw new ApexParameterRuntimeException(errorMessage);
+ throw new ParameterRuntimeException(errorMessage);
}
return carrierTechnologyParameters;
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java
index 3a53b59cb..70badae93 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java
@@ -24,42 +24,42 @@ import java.io.File;
import java.net.URL;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
-import org.onap.policy.apex.service.parameters.ApexParameterValidator;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.service.parameters.ApexParameterConstants;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.apex.core.engine.EngineParameters;
/**
- * This class holds the parameters for an Apex Engine Service with multiple engine threads running
- * multiple engines.
+ * This class holds the parameters for an Apex Engine Service with multiple engine threads running multiple engines.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
- * <li>name: The name of the Apex engine service, which can be set to any value that matches the
- * regular expression {@link org.onap.policy.apex.model.basicmodel.concepts.AxKey#NAME_REGEXP}.
- * <li>version: The name of the Apex engine service, which can be set to any value that matches the
- * regular expression {@link org.onap.policy.apex.model.basicmodel.concepts.AxKey#VERSION_REGEXP}.
+ * <li>name: The name of the Apex engine service, which can be set to any value that matches the regular expression
+ * {@link org.onap.policy.apex.model.basicmodel.concepts.AxKey#NAME_REGEXP}.
+ * <li>version: The name of the Apex engine service, which can be set to any value that matches the regular expression
+ * {@link org.onap.policy.apex.model.basicmodel.concepts.AxKey#VERSION_REGEXP}.
* <li>id: The ID of the Apex engine service, which can be set to any integer value by a user.
- * <li>instanceCount: The number of Apex engines to spawn in this engine service. Each engine
- * executes in its own thread.
- * <li>deploymentPort: The port that the Apex Engine Service will open so that it can be managed
- * using the EngDep protocol. The EngDep protocol allows the engine service to be monitored, to
- * start and stop engines in the engine service, and to update the policy model of the engine
- * service.
- * <li>engineParameters: Parameters (a {@link EngineParameters} instance) that all of the engines in
- * the engine service will use. All engine threads use the same parameters and act as a pool of
- * engines. Engine parameters specify the executors and context management for the engines.
- * <li>policyModelFileName: The full path to the policy model file name to deploy on the engine
- * service.
- * <li>periodicEventPeriod: The period in milliseconds at which the periodic event PERIOIC_EVENT
- * will be generated by APEX, 0 means no periodic event generation, negative values are illegal.
+ * <li>instanceCount: The number of Apex engines to spawn in this engine service. Each engine executes in its own
+ * thread.
+ * <li>deploymentPort: The port that the Apex Engine Service will open so that it can be managed using the EngDep
+ * protocol. The EngDep protocol allows the engine service to be monitored, to start and stop engines in the engine
+ * service, and to update the policy model of the engine service.
+ * <li>engineParameters: Parameters (a {@link EngineParameters} instance) that all of the engines in the engine service
+ * will use. All engine threads use the same parameters and act as a pool of engines. Engine parameters specify the
+ * executors and context management for the engines.
+ * <li>policyModelFileName: The full path to the policy model file name to deploy on the engine service.
+ * <li>periodicEventPeriod: The period in milliseconds at which the periodic event PERIOIC_EVENT will be generated by
+ * APEX, 0 means no periodic event generation, negative values are illegal.
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EngineServiceParameters extends AbstractParameters implements ApexParameterValidator {
+public class EngineServiceParameters implements ParameterGroup {
private static final int MAX_PORT = 65535;
// @formatter:off
@@ -78,6 +78,9 @@ public class EngineServiceParameters extends AbstractParameters implements ApexP
/** The default EngDep deployment port of the Apex engine service. */
public static final int DEFAULT_DEPLOYMENT_PORT = 34421;
+ // Constants for repeated strings
+ private static final String POLICY_MODEL_FILE_NAME = "policyModelFileName";
+
// Apex engine service parameters
private String name = DEFAULT_NAME;
private String version = DEFAULT_VERSION;
@@ -92,12 +95,14 @@ public class EngineServiceParameters extends AbstractParameters implements ApexP
private EngineParameters engineParameters = new EngineParameters();
/**
- * Constructor to create an apex engine service parameters instance and register the instance
- * with the parameter service.
+ * Constructor to create an apex engine service parameters instance and register the instance with the parameter
+ * service.
*/
public EngineServiceParameters() {
- super(EngineServiceParameters.class.getCanonicalName());
- ParameterService.registerParameters(EngineServiceParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME;
}
/**
@@ -221,16 +226,14 @@ public class EngineServiceParameters extends AbstractParameters implements ApexP
/**
* Sets the file name of the policy engine for deployment on the engine service.
*
- * @param policyModelFileName the file name of the policy engine for deployment on the engine
- * service
+ * @param policyModelFileName the file name of the policy engine for deployment on the engine service
*/
public void setPolicyModelFileName(final String policyModelFileName) {
this.policyModelFileName = policyModelFileName;
}
/**
- * Get the period in milliseconds at which periodic events are sent, zero means no periodic
- * events are being sent.
+ * Get the period in milliseconds at which periodic events are sent, zero means no periodic events are being sent.
*
* @return the periodic period
*/
@@ -239,8 +242,8 @@ public class EngineServiceParameters extends AbstractParameters implements ApexP
}
/**
- * Set the period in milliseconds at which periodic events are sent, zero means no periodic
- * events are to be sent, negative values are illegal.
+ * Set the period in milliseconds at which periodic events are sent, zero means no periodic events are to be sent,
+ * negative values are illegal.
*
* @param periodicEventPeriod the periodic period
*/
@@ -272,57 +275,67 @@ public class EngineServiceParameters extends AbstractParameters implements ApexP
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- try {
- new AxArtifactKey(name, version);
- } catch (final Exception e) {
- errorMessageBuilder.append(" name [" + name + "] and/or version [" + version + "] invalid\n");
- errorMessageBuilder.append(" " + e.getMessage() + "\n");
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = new GroupValidationResult(this);
+
+ if (name == null || !name.matches(AxKey.NAME_REGEXP)) {
+ result.setResult("name", ValidationStatus.INVALID,
+ "name is invalid, it must match regular expression" + AxKey.NAME_REGEXP);
+ }
+
+ if (version == null || !version.matches(AxKey.VERSION_REGEXP)) {
+ result.setResult("version", ValidationStatus.INVALID,
+ "version is invalid, it must match regular expression" + AxKey.VERSION_REGEXP);
}
if (id < 0) {
- errorMessageBuilder.append(
- " id not specified or specified value [" + id + "] invalid, must be specified as id >= 0\n");
+ result.setResult("id", ValidationStatus.INVALID,
+ "id not specified or specified value [" + id + "] invalid, must be specified as id >= 0");
}
if (instanceCount < 1) {
- errorMessageBuilder.append(
- " instanceCount [" + instanceCount + "] invalid, must be specified as instanceCount >= 1\n");
+ result.setResult("instanceCount", ValidationStatus.INVALID,
+ "instanceCount [" + instanceCount + "] invalid, must be specified as instanceCount >= 1");
}
if (deploymentPort < 1 || deploymentPort > MAX_PORT) {
- errorMessageBuilder.append(
- " deploymentPort [" + deploymentPort + "] invalid, must be specified as 1024 <= port <= 65535\n");
+ result.setResult("deploymentPort", ValidationStatus.INVALID, "deploymentPort [" + deploymentPort
+ + "] invalid, must be specified as 1024 <= port <= 65535");
}
if (policyModelFileName != null) {
- if (policyModelFileName.trim().length() == 0) {
- errorMessageBuilder.append(" policyModelFileName [" + policyModelFileName
- + "] invalid, must be specified as a non-empty string\n");
- } else {
- // The file name can refer to a resource on the local file system or on the class
- // path
- final URL fileURL = ResourceUtils.getUrl4Resource(policyModelFileName);
- if (fileURL == null) {
- errorMessageBuilder.append(
- " policyModelFileName [" + policyModelFileName + "] not found or is not a plain file\n");
- } else {
- final File policyModelFile = new File(fileURL.getPath());
- if (!policyModelFile.isFile()) {
- errorMessageBuilder.append(" policyModelFileName [" + policyModelFileName
- + "] not found or is not a plain file\n");
- }
- }
- }
+ validatePolicyModelFileName(result);
}
if (periodicEventPeriod < 0) {
- errorMessageBuilder.append(" periodicEventPeriod [" + periodicEventPeriod
- + "] invalid, must be specified in milliseconds as >=0\n");
+ result.setResult("periodicEventPeriod", ValidationStatus.INVALID, "periodicEventPeriod ["
+ + periodicEventPeriod + "] invalid, must be specified in milliseconds as >=0");
}
- return errorMessageBuilder.toString();
+ return result;
+ }
+
+ /**
+ * Validate the policy model file name parameter
+ * @param result the variable in which to store the result of the validation
+ */
+ private void validatePolicyModelFileName(final GroupValidationResult result) {
+ if (policyModelFileName.trim().length() == 0) {
+ result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, "\""
+ + policyModelFileName + "\" invalid, must be specified as a non-empty string");
+ return;
+ }
+
+ // The file name can refer to a resource on the local file system or on the class
+ // path
+ final URL fileURL = ResourceUtils.getUrl4Resource(policyModelFileName);
+ if (fileURL == null) {
+ result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, "not found or is not a plain file");
+ } else {
+ final File policyModelFile = new File(fileURL.getPath());
+ if (!policyModelFile.isFile()) {
+ result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, "not found or is not a plain file");
+ }
+ }
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java
index 9fca2fd19..98e41f6af 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java
@@ -32,8 +32,8 @@ import org.onap.policy.apex.context.parameters.SchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.ExecutorParameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterRuntimeException;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -47,13 +47,12 @@ import com.google.gson.JsonSerializer;
/**
* This class deserializes engine service parameters from JSON format. The class produces an
- * {@link EngineServiceParameters} instance from incoming JSON read from a configuration file in
- * JSON format.
+ * {@link EngineServiceParameters} instance from incoming JSON read from a configuration file in JSON format.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class EngineServiceParametersJSONAdapter
- implements JsonSerializer<EngineParameters>, JsonDeserializer<EngineParameters> {
+ implements JsonSerializer<EngineParameters>, JsonDeserializer<EngineParameters> {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngineServiceParametersJSONAdapter.class);
private static final String PARAMETER_CLASS_NAME = "parameterClassName";
@@ -75,28 +74,28 @@ public class EngineServiceParametersJSONAdapter
*/
@Override
public JsonElement serialize(final EngineParameters src, final Type typeOfSrc,
- final JsonSerializationContext context) {
+ final JsonSerializationContext context) {
final String returnMessage = "serialization of Apex parameters to Json is not supported";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
/*
* (non-Javadoc)
*
- * @see com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement,
- * java.lang.reflect.Type, com.google.gson.JsonDeserializationContext)
+ * @see com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type,
+ * com.google.gson.JsonDeserializationContext)
*/
@Override
public EngineParameters deserialize(final JsonElement json, final Type typeOfT,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) {
final JsonObject engineParametersJsonObject = json.getAsJsonObject();
final EngineParameters engineParameters = new EngineParameters();
// Deserialise context parameters, they may be a subclass of the ContextParameters class
engineParameters.setContextParameters(
- (ContextParameters) context.deserialize(engineParametersJsonObject, ContextParameters.class));
+ (ContextParameters) context.deserialize(engineParametersJsonObject, ContextParameters.class));
// Context parameter wrangling
getContextParameters(engineParametersJsonObject, engineParameters, context);
@@ -115,7 +114,7 @@ public class EngineServiceParametersJSONAdapter
* @param context the JSON context
*/
private void getContextParameters(final JsonObject engineParametersJsonObject,
- final EngineParameters engineParameters, final JsonDeserializationContext context) {
+ final EngineParameters engineParameters, final JsonDeserializationContext context) {
final JsonElement contextParametersElement = engineParametersJsonObject.get(CONTEXT_PARAMETERS);
// Context parameters are optional so if the element does not exist, just return
@@ -124,8 +123,8 @@ public class EngineServiceParametersJSONAdapter
}
// We do this because the JSON parameters may be for a subclass of ContextParameters
- final ContextParameters contextParameters =
- (ContextParameters) deserializeParameters(CONTEXT_PARAMETERS, contextParametersElement, context);
+ final ContextParameters contextParameters = (ContextParameters) deserializeParameters(CONTEXT_PARAMETERS,
+ contextParametersElement, context);
// We know this will work because if the context parameters was not a Json object, the
// previous deserializeParameters() call would not have worked
@@ -134,22 +133,20 @@ public class EngineServiceParametersJSONAdapter
// Now get the distributor, lock manager, and persistence parameters
final JsonElement distributorParametersElement = contextParametersObject.get(DISTRIBUTOR_PARAMETERS);
if (distributorParametersElement != null) {
- contextParameters
- .setDistributorParameters((DistributorParameters) deserializeParameters(DISTRIBUTOR_PARAMETERS,
- distributorParametersElement, context));
+ contextParameters.setDistributorParameters((DistributorParameters) deserializeParameters(
+ DISTRIBUTOR_PARAMETERS, distributorParametersElement, context));
}
final JsonElement lockManagerParametersElement = contextParametersObject.get(LOCK_MANAGER_PARAMETERS);
if (lockManagerParametersElement != null) {
- contextParameters
- .setLockManagerParameters((LockManagerParameters) deserializeParameters(LOCK_MANAGER_PARAMETERS,
- lockManagerParametersElement, context));
+ contextParameters.setLockManagerParameters((LockManagerParameters) deserializeParameters(
+ LOCK_MANAGER_PARAMETERS, lockManagerParametersElement, context));
}
final JsonElement persistorParametersElement = contextParametersObject.get(PERSISTOR_PARAMETERS);
if (persistorParametersElement != null) {
contextParameters.setPersistorParameters((PersistorParameters) deserializeParameters(PERSISTOR_PARAMETERS,
- persistorParametersElement, context));
+ persistorParametersElement, context));
}
// Schema Handler parameter wrangling
@@ -167,25 +164,24 @@ public class EngineServiceParametersJSONAdapter
* @param context the JSON context
*/
private void getExecutorParameters(final JsonObject engineParametersJsonObject,
- final EngineParameters engineParameters, final JsonDeserializationContext context) {
+ final EngineParameters engineParameters, final JsonDeserializationContext context) {
final JsonElement executorParametersElement = engineParametersJsonObject.get(EXECUTOR_PARAMETERS);
// Executor parameters are mandatory so if the element does not exist throw an exception
if (executorParametersElement == null) {
final String returnMessage = "no \"" + EXECUTOR_PARAMETERS
- + "\" entry found in parameters, at least one executor parameter entry must be specified";
+ + "\" entry found in parameters, at least one executor parameter entry must be specified";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
// Deserialize the executor parameters
- final JsonObject executorParametersJsonObject =
- engineParametersJsonObject.get(EXECUTOR_PARAMETERS).getAsJsonObject();
+ final JsonObject executorParametersJsonObject = engineParametersJsonObject.get(EXECUTOR_PARAMETERS)
+ .getAsJsonObject();
for (final Entry<String, JsonElement> executorEntries : executorParametersJsonObject.entrySet()) {
- final ExecutorParameters executorParameters =
- (ExecutorParameters) deserializeParameters(EXECUTOR_PARAMETERS + ':' + executorEntries.getKey(),
- executorEntries.getValue(), context);
+ final ExecutorParameters executorParameters = (ExecutorParameters) deserializeParameters(
+ EXECUTOR_PARAMETERS + ':' + executorEntries.getKey(), executorEntries.getValue(), context);
engineParameters.getExecutorParameterMap().put(executorEntries.getKey(), executorParameters);
}
}
@@ -198,12 +194,12 @@ public class EngineServiceParametersJSONAdapter
* @param context the JSON context
*/
private void getSchemaHandlerParameters(final JsonObject contextParametersJsonObject,
- final ContextParameters contextParameters, final JsonDeserializationContext context) {
+ final ContextParameters contextParameters, final JsonDeserializationContext context) {
final JsonElement schemaParametersElement = contextParametersJsonObject.get(SCHEMA_PARAMETERS);
// Insert the default Java schema helper
contextParameters.getSchemaParameters().getSchemaHelperParameterMap()
- .put(SchemaParameters.DEFAULT_SCHEMA_FLAVOUR, new JavaSchemaHelperParameters());
+ .put(SchemaParameters.DEFAULT_SCHEMA_FLAVOUR, new JavaSchemaHelperParameters());
// Context parameters are optional so if the element does not exist, just return
if (schemaParametersElement == null) {
@@ -211,14 +207,14 @@ public class EngineServiceParametersJSONAdapter
}
// Deserialize the executor parameters
- final JsonObject schemaHelperParametersJsonObject =
- contextParametersJsonObject.get(SCHEMA_PARAMETERS).getAsJsonObject();
+ final JsonObject schemaHelperParametersJsonObject = contextParametersJsonObject.get(SCHEMA_PARAMETERS)
+ .getAsJsonObject();
for (final Entry<String, JsonElement> schemaHelperEntries : schemaHelperParametersJsonObject.entrySet()) {
contextParameters.getSchemaParameters().getSchemaHelperParameterMap().put(schemaHelperEntries.getKey(),
- (SchemaHelperParameters) deserializeParameters(
- SCHEMA_PARAMETERS + ':' + schemaHelperEntries.getKey(), schemaHelperEntries.getValue(),
- context));
+ (SchemaHelperParameters) deserializeParameters(
+ SCHEMA_PARAMETERS + ':' + schemaHelperEntries.getKey(),
+ schemaHelperEntries.getValue(), context));
}
}
@@ -229,10 +225,10 @@ public class EngineServiceParametersJSONAdapter
* @param parametersElement The JSON object holding the parameters
* @param context The GSON context
* @return the parameters
- * @throws ApexParameterRuntimeException on errors reading the parameters
+ * @throws ParameterRuntimeException on errors reading the parameters
*/
- private AbstractParameters deserializeParameters(final String parametersLabel, final JsonElement parametersElement,
- final JsonDeserializationContext context) throws ApexParameterRuntimeException {
+ private ParameterGroup deserializeParameters(final String parametersLabel, final JsonElement parametersElement,
+ final JsonDeserializationContext context) {
JsonObject parametersObject = null;
// Check that the JSON element is a JSON object
@@ -241,45 +237,45 @@ public class EngineServiceParametersJSONAdapter
} else {
final String returnMessage = "value of \"" + parametersLabel + "\" entry is not a parameter JSON object";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
// Get the parameter class name for instantiation in deserialization
final JsonElement parameterClassNameElement = parametersObject.get(PARAMETER_CLASS_NAME);
if (parameterClassNameElement == null) {
- final String returnMessage =
- "could not find field \"" + PARAMETER_CLASS_NAME + "\" in \"" + parametersLabel + "\" entry";
+ final String returnMessage = "could not find field \"" + PARAMETER_CLASS_NAME + "\" in \"" + parametersLabel
+ + "\" entry";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
// Check the parameter is a JSON primitive
if (!parameterClassNameElement.isJsonPrimitive()) {
- final String returnMessage = "value for field \"" + PARAMETER_CLASS_NAME + "\" in \"" + parametersLabel
- + "\" entry is not a plain string";
+ final String returnMessage = "value for field \"" + PARAMETER_CLASS_NAME + "\" of \"" + parametersLabel
+ + "\" entry is not a plain string";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
// Check the parameter has a value
final String parameterClassName = parameterClassNameElement.getAsString();
if (parameterClassName == null || parameterClassName.trim().length() == 0) {
final String returnMessage = "value for field \"" + PARAMETER_CLASS_NAME + "\" in \"" + parametersLabel
- + "\" entry is not specified or is blank";
+ + "\" entry is not specified or is blank";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
// Deserialize the parameters using GSON
- AbstractParameters parameters = null;
+ ParameterGroup parameters = null;
try {
parameters = context.deserialize(parametersObject, Class.forName(parameterClassName));
} catch (JsonParseException | ClassNotFoundException e) {
- final String returnMessage =
- "failed to deserialize the parameters for \"" + parametersLabel + "\" " + "to parameter class \""
- + parameterClassName + "\"\n" + e.getClass().getCanonicalName() + ": " + e.getMessage();
+ final String returnMessage = "failed to deserialize the parameters for \"" + parametersLabel + "\" "
+ + "to parameter class \"" + parameterClassName + "\"\n" + e.getClass().getCanonicalName()
+ + ": " + e.getMessage();
LOGGER.error(returnMessage, e);
- throw new ApexParameterRuntimeException(returnMessage, e);
+ throw new ParameterRuntimeException(returnMessage, e);
}
return parameters;
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
index 164544b4e..76ccd683c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java
@@ -23,42 +23,42 @@ package org.onap.policy.apex.service.parameters.eventhandler;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterValidator;
+import org.onap.policy.apex.service.parameters.ApexParameterConstants;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* The parameters for a single event producer, event consumer or synchronous event handler.
*
- * <p>Event producers, consumers, and synchronous event handlers all use a carrier technology and an
- * event protocol so the actual parameters for each one are the same. Therefore, we use the same
- * class for the parameters of each one.
+ * <p>
+ * Event producers, consumers, and synchronous event handlers all use a carrier technology and an event protocol so the
+ * actual parameters for each one are the same. Therefore, we use the same class for the parameters of each one.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
- * <li>carrierTechnologyParameters: The carrier technology is the type of messaging infrastructure
- * used to carry events. Examples are File, Kafka or REST.
- * <li>eventProtocolParameters: The format that the events are in when being carried. Examples are
- * JSON, XML, or Java Beans. carrier technology
+ * <li>carrierTechnologyParameters: The carrier technology is the type of messaging infrastructure used to carry events.
+ * Examples are File, Kafka or REST.
+ * <li>eventProtocolParameters: The format that the events are in when being carried. Examples are JSON, XML, or Java
+ * Beans. carrier technology
* <li>synchronousMode: true if the event handler is working in synchronous mode, defaults to false
- * <li>synchronousPeer: the peer event handler (consumer for producer or producer for consumer) of
- * this event handler in synchronous mode
- * <li>synchronousTimeout: the amount of time to wait for the reply to synchronous events before
- * they are timed out
+ * <li>synchronousPeer: the peer event handler (consumer for producer or producer for consumer) of this event handler in
+ * synchronous mode
+ * <li>synchronousTimeout: the amount of time to wait for the reply to synchronous events before they are timed out
* <li>requestorMode: true if the event handler is working in requestor mode, defaults to false
- * <li>requestorPeer: the peer event handler (consumer for producer or producer for consumer) of
- * this event handler in requestor mode
- * <li>requestorTimeout: the amount of time to wait for the reply to synchronous events before they
- * are timed out
- * <li>eventNameFilter: a regular expression to apply to events on this event handler. If specified,
- * events not matching the given regular expression are ignored. If it is null, all events are
- * handledDefaults to null.
+ * <li>requestorPeer: the peer event handler (consumer for producer or producer for consumer) of this event handler in
+ * requestor mode
+ * <li>requestorTimeout: the amount of time to wait for the reply to synchronous events before they are timed out
+ * <li>eventNameFilter: a regular expression to apply to events on this event handler. If specified, events not matching
+ * the given regular expression are ignored. If it is null, all events are handledDefaults to null.
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EventHandlerParameters extends AbstractParameters implements ApexParameterValidator {
+public class EventHandlerParameters implements ParameterGroup {
private String name = null;
private CarrierTechnologyParameters carrierTechnologyParameters = null;
private EventProtocolParameters eventProtocolParameters = null;
@@ -75,17 +75,10 @@ public class EventHandlerParameters extends AbstractParameters implements ApexPa
* Constructor to create an event handler parameters instance.
*/
public EventHandlerParameters() {
- super(EventHandlerParameters.class.getCanonicalName());
- }
+ super();
- /**
- * Constructor to create an event handler parameters instance with the name of a sub class of
- * this class.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public EventHandlerParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ApexParameterConstants.EVENT_HANDLER_GROUP_NAME;
}
/**
@@ -151,7 +144,6 @@ public class EventHandlerParameters extends AbstractParameters implements ApexPa
this.eventProtocolParameters = eventProtocolParameters;
}
-
/**
* Checks if the event handler is in the given peered mode.
*
@@ -320,30 +312,33 @@ public class EventHandlerParameters extends AbstractParameters implements ApexPa
* @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = new GroupValidationResult(this);
if (eventProtocolParameters == null) {
- errorMessageBuilder.append(" event handler eventProtocolParameters not specified or blank\n");
+ result.setResult("eventProtocolParameters", ValidationStatus.INVALID,
+ "event handler eventProtocolParameters not specified or blank");
} else {
- errorMessageBuilder.append(eventProtocolParameters.validate());
+ result.setResult("eventProtocolParameters", eventProtocolParameters.validate());
}
if (carrierTechnologyParameters == null) {
- errorMessageBuilder.append(" event handler carrierTechnologyParameters not specified or blank\n");
+ result.setResult("carrierTechnologyParameters", ValidationStatus.INVALID,
+ "event handler carrierTechnologyParameters not specified or blank");
} else {
- errorMessageBuilder.append(carrierTechnologyParameters.validate());
+ result.setResult("carrierTechnologyParameters", carrierTechnologyParameters.validate());
}
if (eventNameFilter != null) {
try {
Pattern.compile(eventNameFilter);
} catch (final PatternSyntaxException pse) {
- errorMessageBuilder.append(" event handler eventNameFilter is not a valid regular expression: "
- + pse.getMessage() + "\n");
+ result.setResult("eventNameFilter", ValidationStatus.INVALID,
+ "event handler eventNameFilter is not a valid regular expression: " + pse.getMessage());
}
}
- return errorMessageBuilder.toString();
+
+ return result;
}
/*
@@ -354,9 +349,10 @@ public class EventHandlerParameters extends AbstractParameters implements ApexPa
@Override
public String toString() {
return "EventHandlerParameters [name=" + name + ", carrierTechnologyParameters=" + carrierTechnologyParameters
- + ", eventProtocolParameters=" + eventProtocolParameters + ", synchronousMode=" + synchronousMode
- + ", synchronousPeer=" + synchronousPeer + ", synchronousTimeout=" + synchronousTimeout
- + ", requestorMode=" + requestorMode + ", requestorPeer=" + requestorPeer + ", requestorTimeout="
- + requestorTimeout + ", eventName=" + eventName + ", eventNameFilter=" + eventNameFilter + "]";
+ + ", eventProtocolParameters=" + eventProtocolParameters + ", synchronousMode="
+ + synchronousMode + ", synchronousPeer=" + synchronousPeer + ", synchronousTimeout="
+ + synchronousTimeout + ", requestorMode=" + requestorMode + ", requestorPeer=" + requestorPeer
+ + ", requestorTimeout=" + requestorTimeout + ", eventName=" + eventName + ", eventNameFilter="
+ + eventNameFilter + "]";
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
index 66b5c0aae..06b5e41f5 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java
@@ -20,23 +20,26 @@
package org.onap.policy.apex.service.parameters.eventprotocol;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterValidator;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterRuntimeException;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
- * A default event protocol parameter class that may be specialized by event protocol plugins that
- * require plugin specific parameters.
+ * A default event protocol parameter class that may be specialized by event protocol plugins that require plugin
+ * specific parameters.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
* <li>label: The label of the event protocol technology.
- * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce
- * and emit output events for this carrier technology
+ * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output
+ * events for this carrier technology
* </ol>
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class EventProtocolParameters extends AbstractParameters implements ApexParameterValidator {
+public abstract class EventProtocolParameters implements ParameterGroup {
// The event protocol label
private String label = null;
@@ -44,13 +47,13 @@ public abstract class EventProtocolParameters extends AbstractParameters impleme
private String eventProtocolPluginClass;
/**
- * Constructor to create an event protocol parameters instance with the name of a sub class of
- * this class and register the instance with the parameter service.
+ * Constructor to create an event protocol parameters instance with the name of a sub class of this class and
+ * register the instance with the parameter service.
*
* @param parameterClassName the class name of a sub class of this class
*/
public EventProtocolParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
}
/**
@@ -97,7 +100,7 @@ public abstract class EventProtocolParameters extends AbstractParameters impleme
@Override
public String toString() {
return "CarrierTechnologyParameters [label=" + label + ", EventProtocolPluginClass=" + eventProtocolPluginClass
- + "]";
+ + "]";
}
/*
@@ -106,17 +109,28 @@ public abstract class EventProtocolParameters extends AbstractParameters impleme
* @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = new GroupValidationResult(this);
if (label == null || label.length() == 0) {
- errorMessageBuilder.append(" event protocol label not specified or is blank\n");
+ result.setResult("label", ValidationStatus.INVALID, "event protocol label not specified or is blank");
}
if (eventProtocolPluginClass == null || eventProtocolPluginClass.length() == 0) {
- errorMessageBuilder.append(" event protocol eventProtocolPluginClass not specified or is blank\n");
+ result.setResult("eventProtocolPluginClass", ValidationStatus.INVALID,
+ "event protocol eventProtocolPluginClass not specified or is blank");
}
- return errorMessageBuilder.toString();
+ return result;
+ }
+
+ @Override
+ public String getName() {
+ return this.getLabel();
+ }
+
+ @Override
+ public void setName(final String name) {
+ throw new ParameterRuntimeException("the name/label of this event protocol is always \"" + getLabel() + "\"");
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java
index 9d087bf31..2f09e0a65 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java
@@ -26,7 +26,7 @@ import java.util.Map;
import org.onap.policy.apex.service.engine.event.impl.apexprotocolplugin.ApexEventProtocolParameters;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterRuntimeException;
+import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -34,7 +34,6 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -55,11 +54,11 @@ public class EventProtocolParametersJSONAdapter
private static final String EVENT_PROTOCOL_PARAMETERS = "parameters";
// Built in event protocol parameters
- private static final Map<String, String> BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP = new HashMap<>();
+ private static final Map<String, String> BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP = new HashMap<>();
static {
- BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP.put("JSON", JSONEventProtocolParameters.class.getCanonicalName());
- BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP.put("APEX", ApexEventProtocolParameters.class.getCanonicalName());
+ BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP.put("JSON", JSONEventProtocolParameters.class.getCanonicalName());
+ BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP.put("APEX", ApexEventProtocolParameters.class.getCanonicalName());
}
/*
@@ -73,7 +72,7 @@ public class EventProtocolParametersJSONAdapter
final JsonSerializationContext context) {
final String returnMessage = "serialization of Apex event protocol parameters to Json is not supported";
LOGGER.error(returnMessage);
- throw new ApexParameterRuntimeException(returnMessage);
+ throw new ParameterRuntimeException(returnMessage);
}
/*
@@ -84,7 +83,7 @@ public class EventProtocolParametersJSONAdapter
*/
@Override
public EventProtocolParameters deserialize(final JsonElement json, final Type typeOfT,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) {
final JsonObject jsonObject = json.getAsJsonObject();
// Get the event protocol label primitive
@@ -102,7 +101,7 @@ public class EventProtocolParametersJSONAdapter
final String errorMessage = "event protocol parameter \"" + EVENT_PROTOCOL_TOKEN + "\" value \""
+ labelJsonPrimitive.getAsString() + "\" invalid in JSON file";
LOGGER.warn(errorMessage);
- throw new ApexParameterRuntimeException(errorMessage);
+ throw new ParameterRuntimeException(errorMessage);
}
// We now get the event protocol parameter class
@@ -114,7 +113,7 @@ public class EventProtocolParametersJSONAdapter
// If no event protocol parameter class was specified, we use the default
if (classNameJsonPrimitive == null) {
- eventProtocolParameterClassName = BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP.get(eventProtocolLabel);
+ eventProtocolParameterClassName = BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP.get(eventProtocolLabel);
} else {
// We use the specified one
eventProtocolParameterClassName = classNameJsonPrimitive.getAsString().replaceAll("\\s+", "");
@@ -127,7 +126,7 @@ public class EventProtocolParametersJSONAdapter
+ (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null")
+ "\" invalid in JSON file";
LOGGER.warn(errorMessage);
- throw new ApexParameterRuntimeException(errorMessage);
+ throw new ParameterRuntimeException(errorMessage);
}
// Get the class for the event protocol
@@ -139,7 +138,7 @@ public class EventProtocolParametersJSONAdapter
"event protocol \"" + eventProtocolLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ eventProtocolParameterClassName + "\", could not find class";
LOGGER.warn(errorMessage, e);
- throw new ApexParameterRuntimeException(errorMessage, e);
+ throw new ParameterRuntimeException(errorMessage, e);
}
// Deserialise the class
@@ -154,7 +153,7 @@ public class EventProtocolParametersJSONAdapter
final String errorMessage = "could not create default parameters for event protocol \""
+ eventProtocolLabel + "\"\n" + e.getMessage();
LOGGER.warn(errorMessage, e);
- throw new ApexParameterRuntimeException(errorMessage, e);
+ throw new ParameterRuntimeException(errorMessage, e);
}
}
@@ -166,7 +165,7 @@ public class EventProtocolParametersJSONAdapter
+ "\", specify correct event protocol parameter plugin in parameter \"" + PARAMETER_CLASS_NAME
+ "\"";
LOGGER.warn(errorMessage);
- throw new ApexParameterRuntimeException(errorMessage);
+ throw new ParameterRuntimeException(errorMessage);
}
return eventProtocolParameters;
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
index 7094a3d3f..d10d81ce2 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java
@@ -20,13 +20,15 @@
package org.onap.policy.apex.service.parameters.eventprotocol;
-import org.onap.policy.apex.service.parameters.ApexParameterValidator;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
- * An event protocol parameter class for character delimited textual event protocols that may be
- * specialized by event protocol plugins that require plugin specific parameters.
+ * An event protocol parameter class for character delimited textual event protocols that may be specialized by event
+ * protocol plugins that require plugin specific parameters.
*
- * <p>The following parameters are defined:
+ * <p>
+ * The following parameters are defined:
* <ol>
* <li>startChar: starting character delimiter for text blocks containing an event.
* <li>endChar: ending character delimiter for text blocks containing an event.
@@ -34,15 +36,13 @@ import org.onap.policy.apex.service.parameters.ApexParameterValidator;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class EventProtocolTextCharDelimitedParameters extends EventProtocolParameters
- implements ApexParameterValidator {
+public abstract class EventProtocolTextCharDelimitedParameters extends EventProtocolParameters {
// The starting and ending character delimiter
private char startChar = '\0';
private char endChar = '\0';
/**
- * Constructor to create an event protocol parameters instance with the name of a sub class of
- * this class.
+ * Constructor to create an event protocol parameters instance with the name of a sub class of this class.
*
* @param parameterClassName the class name of a sub class of this class
*/
@@ -94,7 +94,7 @@ public abstract class EventProtocolTextCharDelimitedParameters extends EventProt
@Override
public String toString() {
return "EventProtocolTextCharDelimitedParameters {" + super.toString() + "} [startChar=" + startChar
- + ", endChar=" + endChar + "]";
+ + ", endChar=" + endChar + "]";
}
/*
@@ -103,19 +103,19 @@ public abstract class EventProtocolTextCharDelimitedParameters extends EventProt
* @see org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (startChar == '\0') {
- errorMessageBuilder.append(" text character delimited start character has not been specified\n");
+ result.setResult("startChar", ValidationStatus.INVALID,
+ "text character delimited start character has not been specified");
}
if (endChar == '\0') {
- errorMessageBuilder.append(" text character delimited end character has not been specified\n");
+ result.setResult("endChar", ValidationStatus.INVALID,
+ "text character delimited end character has not been specified\n");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
index f71ebc6d8..dce2ee2c3 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java
@@ -20,7 +20,8 @@
package org.onap.policy.apex.service.parameters.eventprotocol;
-import org.onap.policy.apex.service.parameters.ApexParameterValidator;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* An event protocol parameter class for token delimited textual event protocols that may be specialized by event
@@ -38,8 +39,7 @@ import org.onap.policy.apex.service.parameters.ApexParameterValidator;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class EventProtocolTextTokenDelimitedParameters extends EventProtocolParameters
- implements ApexParameterValidator {
+public abstract class EventProtocolTextTokenDelimitedParameters extends EventProtocolParameters {
// The delimiter token for text blocks
private String startDelimiterToken = null;
private String endDelimiterToken = null;
@@ -124,15 +124,14 @@ public abstract class EventProtocolTextTokenDelimitedParameters extends EventPro
* @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (startDelimiterToken == null || startDelimiterToken.length() == 0) {
- errorMessageBuilder.append(" text start delimiter token not specified or is blank\n");
+ result.setResult("startDelimiterToken", ValidationStatus.INVALID,
+ "text start delimiter token not specified or is blank\n");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java
index decec767f..4f1089229 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java
@@ -32,9 +32,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
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;
@@ -46,6 +47,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -67,9 +69,17 @@ public class TestJSONEventHandler {
apexPolicyModel.register();
}
- @Before
- public void initializeDefaultSchemaParameters() {
- new SchemaParameters();
+ @BeforeClass
+ public static void initializeDefaultSchemaParameters() {
+ ParameterService.clear();
+ final SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ ParameterService.register(schemaParameters);
+ }
+
+ @AfterClass
+ public static void teardownDefaultSchemaParameters() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java
index 8ecf9b745..db60b229d 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestPluginFactories.java
@@ -29,10 +29,10 @@ import org.onap.policy.apex.service.engine.event.impl.EventConsumerFactory;
import org.onap.policy.apex.service.engine.event.impl.EventProducerFactory;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test Plugin Factories.
@@ -42,7 +42,7 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParamete
public class TestPluginFactories {
@Test
- public void testEventConsumerFactory() throws ApexEventException, ApexParameterException {
+ public void testEventConsumerFactory() throws ApexEventException, ParameterException {
final String[] args = {"-c", "src/test/resources/parameters/factoryGoodParams.json"};
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java
index d22d528c8..37f15777b 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java
@@ -26,9 +26,9 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperDistributorParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -45,9 +45,9 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextNoParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" in "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" in "
+ "\"contextParameters\" entry", e.getMessage());
}
}
@@ -60,9 +60,9 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextBadParams.json\""
- + "\n(ApexParameterRuntimeException):failed to deserialize the parameters for "
+ + "\n(ParameterRuntimeException):failed to deserialize the parameters for "
+ "\"contextParameters\" to parameter class \"hello\"\njava.lang.ClassNotFoundException: hello",
e.getMessage());
}
@@ -76,10 +76,10 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadPluginNameParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" in "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" in "
+ "\"contextParameters\" entry", e.getMessage());
}
}
@@ -92,10 +92,10 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals(
"error reading parameters from \"src/test/resources/parameters/serviceContextBadClassParams.json\""
- + "\n(ApexParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\""
+ + "\n(ParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\""
+ " to parameter class \"java.lang.Integer\"\ncom.google.gson.JsonSyntaxException: "
+ "java.lang.IllegalStateException: Expected NUMBER but was BEGIN_OBJECT at path $",
e.getMessage());
@@ -110,7 +110,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadPluginClassParams.json\""
+ "\n(ClassCastException):org.onap.policy.apex.service.engine.parameters.dummyclasses."
@@ -127,10 +127,10 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -143,10 +143,10 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -159,11 +159,11 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getDistributorParameters().getParameterClassName());
- } catch (final ApexParameterException e) {
+ .getDistributorParameters().getClass().getCanonicalName());
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -176,19 +176,19 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getDistributorParameters().getParameterClassName());
+ .getDistributorParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getLockManagerParameters().getParameterClassName());
+ .getLockManagerParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getPersistorParameters().getParameterClassName());
+ .getPersistorParameters().getClass().getCanonicalName());
assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -201,13 +201,13 @@ public class ContextParameterTests {
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters
- .getEngineServiceParameters().getEngineParameters().getContextParameters().getParameterClassName());
+ .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getLockManagerParameters().getParameterClassName());
+ .getLockManagerParameters().getClass().getCanonicalName());
assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters",
parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
- .getPersistorParameters().getParameterClassName());
+ .getPersistorParameters().getClass().getCanonicalName());
assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()
.getPersistorParameters().getFlushPeriod());
@@ -215,13 +215,13 @@ public class ContextParameterTests {
(SuperDooperDistributorParameters) parameters.getEngineServiceParameters().getEngineParameters()
.getContextParameters().getDistributorParameters();
assertEquals("org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperDistributorParameters",
- infinispanParameters.getParameterClassName());
+ infinispanParameters.getClass().getCanonicalName());
assertEquals("my/lovely/configFile.xml", infinispanParameters.getConfigFile());
assertEquals("holy/stone.xml", infinispanParameters.getJgroupsFile());
assertEquals(false, infinispanParameters.preferIPv4Stack());
assertEquals("fatherted", infinispanParameters.getjGroupsBindAddress());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -234,7 +234,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadClassDistParams.json\"\n"
+ "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to"
@@ -250,7 +250,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadClassLockParams.json\"\n"
+ "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to"
@@ -266,7 +266,7 @@ public class ContextParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceContextBadClassPersistParams.json\"\n"
+ "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to"
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java
index aa106a695..5e42ede1a 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ExecutorParameterTests.java
@@ -25,9 +25,9 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -45,7 +45,7 @@ public class ExecutorParameterTests {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(0,
parameters.getEngineServiceParameters().getEngineParameters().getExecutorParameterMap().size());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
@@ -58,10 +58,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals(
"error reading parameters from \"src/test/resources/parameters/serviceExecutorBadParams.json\"\n"
- + "(ApexParameterRuntimeException):value of \"executorParameters:ZOOBY\" entry is not "
+ + "(ParameterRuntimeException):value of \"executorParameters:ZOOBY\" entry is not "
+ "a parameter JSON object",
e.getMessage());
}
@@ -75,10 +75,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorNoExecutorParams.json\"\n"
- + "(ApexParameterRuntimeException):no \"executorParameters\" entry found in parameters,"
+ + "(ParameterRuntimeException):no \"executorParameters\" entry found in parameters,"
+ " at least one executor parameter entry must be specified", e.getMessage());
}
}
@@ -91,10 +91,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorEmptyParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" "
+ "in \"executorParameters:ZOOBY\" entry", e.getMessage());
}
}
@@ -107,10 +107,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorBadPluginNameParams.json\"\n"
- + "(ApexParameterRuntimeException):could not find field \"parameterClassName\" "
+ + "(ParameterRuntimeException):could not find field \"parameterClassName\" "
+ "in \"executorParameters:ZOOBY\" entry", e.getMessage());
}
}
@@ -123,11 +123,11 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorBadPluginValueObjectParams.json\"\n"
- + "(ApexParameterRuntimeException):value for field \"parameterClassName\" "
- + "in \"executorParameters:LOOBY\" entry is not a plain string", e.getMessage());
+ + "(ParameterRuntimeException):value for field \"parameterClassName\" "
+ + "of \"executorParameters:LOOBY\" entry is not a plain string", e.getMessage());
}
}
@@ -139,10 +139,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
+ "\"src/test/resources/parameters/serviceExecutorBadPluginValueBlankParams.json\"\n"
- + "(ApexParameterRuntimeException):value for field \"parameterClassName\" "
+ + "(ParameterRuntimeException):value for field \"parameterClassName\" "
+ "in \"executorParameters:LOOBY\" entry is not specified or is blank", e.getMessage());
}
}
@@ -156,10 +156,10 @@ public class ExecutorParameterTests {
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from"
+ " \"src/test/resources/parameters/serviceExecutorBadPluginValueParams.json\"\n"
- + "(ApexParameterRuntimeException):failed to deserialize the parameters "
+ + "(ParameterRuntimeException):failed to deserialize the parameters "
+ "for \"executorParameters:LOOBY\" to parameter class \"helloworld\"\n"
+ "java.lang.ClassNotFoundException: helloworld", e.getMessage());
}
@@ -178,7 +178,7 @@ public class ExecutorParameterTests {
assertEquals(45, parameters.getEngineServiceParameters().getId());
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw any exception: " + e.getMessage());
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java
index 6d3d7ee20..31ccd913f 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java
@@ -34,11 +34,11 @@ import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventProducer;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventSubscriber;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -47,14 +47,14 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
*/
public class ParameterTests {
@Test
- public void invalidParametersNoFileTest() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/invalidNoFile.json"};
+ public void invalidParametersNoFileTest() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/invalidNoFile.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertTrue(e.getMessage().startsWith("error reading parameters from \"src"));
assertTrue(e.getMessage().contains("FileNotFoundException"));
}
@@ -62,79 +62,116 @@ public class ParameterTests {
@Test
public void invalidParametersEmptyTest() {
- final String[] args = {"-c", "src/test/resources/parameters/empty.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/empty.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
- assertTrue(e.getMessage()
- .startsWith("validation error(s) on parameters from \"src/test/resources/parameters/empty.json\""));
+ } catch (final ParameterException e) {
+ assertTrue(e.getMessage().startsWith(
+ "validation error(s) on parameters from \"src/test/resources/parameters/empty.json\""));
}
}
@Test
public void invalidParametersNoParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/noParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/noParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/noParams.json\"\n"
- + "Apex parameters invalid\n" + " engine service parameters are not specified\n"
- + " at least one event output and one event input must be specified", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
+ + "engine service parameters are not specified\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "at least one event output must be specified\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "at least one event input must be specified\n", e.getMessage());
}
}
@Test
public void invalidParametersBlankParamsTest() {
- final String[] args = {"-c", "src/test/resources/parameters/blankParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/blankParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/blankParams.json\"\n"
- + "Apex parameters invalid\n" + " engine service parameters invalid\n"
- + " id not specified or specified value [-1] invalid, must be specified as id >= 0\n"
- + " at least one event output and one event input must be specified", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group \"ENGINE_SERVICE_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " field \"id\" type \"int\" value \"-1\" INVALID, "
+ + "id not specified or specified value [-1] invalid, must be specified as id >= 0\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "at least one event output must be specified\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "at least one event input must be specified\n", e.getMessage());
}
}
@Test
public void invalidParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/badParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/badParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/badParams.json\"\n"
- + "Apex parameters invalid\n" + " engine service parameters invalid\n"
- + " name [hello there] and/or version [PA1] invalid\n"
- + " parameter \"name\": value \"hello there\","
- + " does not match regular expression \"[A-Za-z0-9\\-_\\.]+\"\n"
- + " id not specified or specified value [-45] invalid, must be specified as id >= 0\n"
- + " instanceCount [-345] invalid, must be specified as instanceCount >= 1\n"
- + " deploymentPort [65536] invalid, must be specified as 1024 <= port <= 65535\n"
- + " policyModelFileName [/some/file/name.xml] not found or is not a plain file\n"
- + " event input (TheFileConsumer1) parameters invalid\n"
- + " fileName not specified or is blank or null, it must be specified as a valid file location\n"
- + " event output (FirstProducer) parameters invalid\n"
- + " fileName not specified or is blank or null, it must be specified as a valid file location",
- e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"hello there\" type "
+ + "\"org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " field \"name\" type \"java.lang.String\" value \"hello there\" INVALID, "
+ + "name is invalid, it must match regular expression[A-Za-z0-9\\-_\\.]+\n"
+ + " field \"id\" type \"int\" value \"-45\" INVALID, id not specified or "
+ + "specified value [-45] invalid, must be specified as id >= 0\n"
+ + " field \"instanceCount\" type \"int\" value \"-345\" INVALID, "
+ + "instanceCount [-345] invalid, must be specified as instanceCount >= 1\n"
+ + " field \"deploymentPort\" type \"int\" value \"65536\" INVALID, "
+ + "deploymentPort [65536] invalid, must be specified as 1024 <= port <= 65535\n"
+ + " field \"policyModelFileName\" type \"java.lang.String\" "
+ + "value \"/some/file/name.xml\" INVALID, not found or is not a plain file\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"FirstProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, "
+ + "fileName not specified or is blank or null, "
+ + "it must be specified as a valid file location\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"TheFileConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, "
+ + "fileName not specified or is blank or null, "
+ + "it must be specified as a valid file location\n", e.getMessage());
}
}
@Test
public void goodParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -146,44 +183,46 @@ public class ParameterTests {
assertTrue(parameters.getEventOutputParameters().containsKey("FirstProducer"));
assertTrue(parameters.getEventOutputParameters().containsKey("MyOtherProducer"));
assertEquals("FILE", parameters.getEventOutputParameters().get("FirstProducer")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("FILE", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals(ApexFileEventProducer.class.getCanonicalName(), parameters.getEventOutputParameters()
- .get("MyOtherProducer").getCarrierTechnologyParameters().getEventProducerPluginClass());
+ .get("MyOtherProducer").getCarrierTechnologyParameters().getEventProducerPluginClass());
assertEquals(ApexFileEventConsumer.class.getCanonicalName(), parameters.getEventOutputParameters()
- .get("MyOtherProducer").getCarrierTechnologyParameters().getEventConsumerPluginClass());
- assertEquals("JSON",
- parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters().getLabel());
+ .get("MyOtherProducer").getCarrierTechnologyParameters().getEventConsumerPluginClass());
+ assertEquals("JSON", parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters()
+ .getLabel());
assertEquals("JSON", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertTrue(parameters.getEventInputParameters().containsKey("TheFileConsumer1"));
assertTrue(parameters.getEventInputParameters().containsKey("MySuperDooperConsumer1"));
assertEquals("FILE", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("SUPER_DOOPER", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("JSON", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals("SUPER_TOK_DEL", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals(ApexFileEventProducer.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventProducerPluginClass());
+ .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventProducerPluginClass());
assertEquals(ApexFileEventConsumer.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventConsumerPluginClass());
- assertEquals(SuperDooperEventProducer.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("MySuperDooperConsumer1").getCarrierTechnologyParameters().getEventProducerPluginClass());
- assertEquals(SuperDooperEventSubscriber.class.getCanonicalName(), parameters.getEventInputParameters()
- .get("MySuperDooperConsumer1").getCarrierTechnologyParameters().getEventConsumerPluginClass());
- } catch (final ApexParameterException e) {
+ .get("TheFileConsumer1").getCarrierTechnologyParameters().getEventConsumerPluginClass());
+ assertEquals(SuperDooperEventProducer.class.getCanonicalName(),
+ parameters.getEventInputParameters().get("MySuperDooperConsumer1")
+ .getCarrierTechnologyParameters().getEventProducerPluginClass());
+ assertEquals(SuperDooperEventSubscriber.class.getCanonicalName(),
+ parameters.getEventInputParameters().get("MySuperDooperConsumer1")
+ .getCarrierTechnologyParameters().getEventConsumerPluginClass());
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
@Test
public void superDooperParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/superDooperParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/superDooperParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -195,14 +234,14 @@ public class ParameterTests {
assertEquals(345, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- final CarrierTechnologyParameters prodCT =
- parameters.getEventOutputParameters().get("FirstProducer").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEP =
- parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters();
- final CarrierTechnologyParameters consCT =
- parameters.getEventInputParameters().get("MySuperDooperConsumer1").getCarrierTechnologyParameters();
- final EventProtocolParameters consEP =
- parameters.getEventInputParameters().get("MySuperDooperConsumer1").getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCT = parameters.getEventOutputParameters().get("FirstProducer")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEP = parameters.getEventOutputParameters().get("FirstProducer")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters consCT = parameters.getEventInputParameters()
+ .get("MySuperDooperConsumer1").getCarrierTechnologyParameters();
+ final EventProtocolParameters consEP = parameters.getEventInputParameters().get("MySuperDooperConsumer1")
+ .getEventProtocolParameters();
assertEquals("SUPER_DOOPER", prodCT.getLabel());
assertEquals("SUPER_TOK_DEL", prodEP.getLabel());
@@ -211,8 +250,7 @@ public class ParameterTests {
assertTrue(prodCT instanceof SuperDooperCarrierTechnologyParameters);
- final SuperDooperCarrierTechnologyParameters superDooperParameters =
- (SuperDooperCarrierTechnologyParameters) prodCT;
+ final SuperDooperCarrierTechnologyParameters superDooperParameters = (SuperDooperCarrierTechnologyParameters) prodCT;
assertEquals("somehost:12345", superDooperParameters.getBootstrapServers());
assertEquals("0", superDooperParameters.getAcks());
assertEquals(25, superDooperParameters.getRetries());
@@ -230,9 +268,9 @@ public class ParameterTests {
assertEquals("some.key.deserailizer", superDooperParameters.getKeyDeserializer());
assertEquals("some.value.deserailizer", superDooperParameters.getValueDeserializer());
- final String[] consumerTopics = {"consumer-out-0", "consumer-out-1", "consumer-out-2"};
+ final String[] consumerTopics = { "consumer-out-0", "consumer-out-1", "consumer-out-2" };
assertEquals(Arrays.asList(consumerTopics), superDooperParameters.getConsumerTopicList());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
index a476b84ca..8bcc1bd37 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java
@@ -26,9 +26,9 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -38,7 +38,7 @@ import org.onap.policy.apex.service.parameters.ApexParameters;
public class ProducerConsumerTests {
@Test
public void goodParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -50,220 +50,241 @@ public class ProducerConsumerTests {
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
assertEquals("FILE", parameters.getEventOutputParameters().get("FirstProducer")
- .getCarrierTechnologyParameters().getLabel());
- assertEquals("JSON",
- parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
+ assertEquals("JSON", parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters()
+ .getLabel());
assertEquals("FILE", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("JSON", parameters.getEventOutputParameters().get("MyOtherProducer")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals("FILE", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("JSON", parameters.getEventInputParameters().get("TheFileConsumer1")
- .getEventProtocolParameters().getLabel());
+ .getEventProtocolParameters().getLabel());
assertEquals("SUPER_DOOPER", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getCarrierTechnologyParameters().getLabel());
+ .getCarrierTechnologyParameters().getLabel());
assertEquals("SUPER_TOK_DEL", parameters.getEventInputParameters().get("MySuperDooperConsumer1")
- .getEventProtocolParameters().getLabel());
- } catch (final ApexParameterException e) {
+ .getEventProtocolParameters().getLabel());
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
@Test
public void noCarrierTechnology() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoCT.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCT.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoCT.json\"\n"
- + "Apex parameters invalid\n" + " event input (aConsumer) parameters invalid\n"
- + " event handler carrierTechnologyParameters not specified or blank", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"aConsumer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
+ + "event handler carrierTechnologyParameters not specified or blank\n", e.getMessage());
}
}
@Test
public void noEventProcol() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoEP.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEP.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoEP.json\"\n"
- + "Apex parameters invalid\n" + " event input (aConsumer) parameters invalid\n"
- + " fileName not specified or is blank or null, it must be specified as a valid file location\n"
- + " event output (aProducer) parameters invalid\n"
- + " event handler eventProtocolParameters not specified or blank", e.getMessage());
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"aProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, "
+ + "event handler eventProtocolParameters not specified or blank\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"aConsumer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, "
+ + "fileName not specified or is blank or null, "
+ + "it must be specified as a valid file location\n", e.getMessage());
}
}
@Test
public void noCarrierTechnologyParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoCTParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCTParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsNoCTParClass.json\"\n"
- + "(ApexParameterRuntimeException):carrier technology \"SUPER_DOOPER\" "
- + "does not match plugin \"FILE\" in "
- + "\"com.ericsson.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters"
- + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "(ParameterRuntimeException):carrier technology \"SUPER_DOOPER\" "
+ + "parameter \"parameterClassName\" value \"null\" invalid in JSON file", e.getMessage());
}
}
@Test
public void mismatchCarrierTechnologyParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
- + "\"src/test/resources/parameters/prodConsMismatchCTParClass.json\"\n"
- + "(ApexParameterRuntimeException):carrier technology \"SUPER_LOOPER\" "
- + "does not match plugin \"SUPER_DOOPER\" in \""
- + "com.ericsson.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters"
- + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "\"src/test/resources/parameters/prodConsMismatchCTParClass.json\"\n"
+ + "(ParameterRuntimeException):carrier technology \"SUPER_LOOPER\" "
+ + "does not match plugin \"SUPER_DOOPER\" in \"" + "org.onap.policy.apex.service.engine."
+ + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters"
+ + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"",
+ e.getMessage());
}
}
@Test
public void wrongTypeCarrierTechnologyParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
- + "\"src/test/resources/parameters/prodConsWrongTypeCTParClass.json\"\n"
- + "(ApexParameterRuntimeException):could not create default parameters for carrier technology "
- + "\"SUPER_DOOPER\"\ncom.ericsson.apex.service.engine.parameters.dummyclasses."
- + "SuperTokenDelimitedEventProtocolParameters cannot be cast to "
- + "com.ericsson.apex.service.parameters.carriertechnology.CarrierTechnologyParameters",
- e.getMessage());
+ + "\"src/test/resources/parameters/prodConsWrongTypeCTParClass.json\"\n"
+ + "(ParameterRuntimeException):could not create default parameters for carrier technology "
+ + "\"SUPER_DOOPER\"\n" + "org.onap.policy.apex.service.engine.parameters.dummyclasses."
+ + "SuperTokenDelimitedEventProtocolParameters cannot be cast to "
+ + "org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters",
+ e.getMessage());
}
}
@Test
public void okFileNameCarrierTechnology() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsOKFileName.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsOKFileName.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
final FILECarrierTechnologyParameters fileParams = (FILECarrierTechnologyParameters) parameters
- .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters();
+ .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters();
assertEquals("/tmp/aaa.json", fileParams.getFileName());
assertEquals(false, fileParams.isStandardError());
assertEquals(false, fileParams.isStandardIO());
assertEquals(false, fileParams.isStreamingMode());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
@Test
public void badFileNameCarrierTechnology() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsBadFileName.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsBadFileName.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
- assertEquals(
- "validation error(s) on parameters from \"src/test/resources/parameters/prodConsBadFileName.json\""
- + "\nApex parameters invalid\n" + " event output (aProducer) parameters invalid"
- + "\n fileName not specified or is blank or null, it must be specified as a valid file location",
- e.getMessage());
+ } catch (final ParameterException e) {
+ assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsBadFileName.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, parameter group has status INVALID\n"
+ + " parameter group \"aProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"FILE\" type "
+ + "\"org.onap.policy.apex.service.engine.event.impl."
+ + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " field \"fileName\" type "
+ + "\"java.lang.String\" value \"null\" INVALID, fileName not specified or is blank or null, "
+ + "it must be specified as a valid file location\n", e.getMessage());
}
}
-
@Test
public void badEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsBadEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsBadEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsBadEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" "
- + "in \"com.ericsson.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters"
- + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "(ParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" in "
+ + "\"org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters"
+ + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
+ e.getMessage());
}
}
@Test
public void noEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsNoEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsNoEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" "
- + "in \"com.ericsson.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters"
- + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ + "(ParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" parameter "
+ + "\"parameterClassName\" value \"null\" invalid in JSON file", e.getMessage());
}
}
@Test
public void mismatchEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
- assertEquals(
- "error reading parameters from \"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):event protocol \"SUPER_TOK_BEL\" "
+ } catch (final ParameterException e) {
+ assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n"
+ + "(ParameterRuntimeException):event protocol \"SUPER_TOK_BEL\" "
+ "does not match plugin \"SUPER_TOK_DEL\" in "
- + "\"com.ericsson.apex.service.engine.parameters.dummyclasses."
+ + "\"org.onap.policy.apex.service.engine.parameters.dummyclasses."
+ "SuperTokenDelimitedEventProtocolParameters\", "
+ "specify correct event protocol parameter plugin in parameter \"parameterClassName\"",
- e.getMessage());
+ e.getMessage());
}
}
@Test
public void wrongTypeEventProtocolParClass() {
- final String[] args = {"-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("error reading parameters from "
- + "\"src/test/resources/parameters/prodConsWrongTypeEPParClass.json\"\n"
- + "(ApexParameterRuntimeException):could not create default parameters for event protocol "
- + "\"SUPER_TOK_DEL\"\n"
- + "com.ericsson.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters "
- + "cannot be cast to com.ericsson.apex.service.parameters.eventprotocol.EventProtocolParameters",
- e.getMessage());
+ + "\"src/test/resources/parameters/prodConsWrongTypeEPParClass.json\"\n"
+ + "(ParameterRuntimeException):could not create default parameters for event protocol "
+ + "\"SUPER_TOK_DEL\"\n" + "org.onap.policy.apex.service.engine."
+ + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters "
+ + "cannot be cast to org.onap.policy.apex.service."
+ + "parameters.eventprotocol.EventProtocolParameters", e.getMessage());
}
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
index cc1d6d3dc..1c291786f 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java
@@ -30,12 +30,12 @@ import org.junit.Test;
import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters;
import org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperTokenDelimitedEventProtocolParameters;
-import org.onap.policy.apex.service.parameters.ApexParameterException;
import org.onap.policy.apex.service.parameters.ApexParameterHandler;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
+import org.onap.policy.common.parameters.ParameterException;
/**
* Test for an empty parameter file.
@@ -44,257 +44,362 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
*/
public class SyncParameterTests {
@Test
- public void syncBadNoSyncWithPeer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json"};
+ public void syncBadNoSyncWithPeer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json\"\n"
- + "Apex parameters invalid\n"
- + " parameter \\\"synchronousPeer\\\" is illegal on non synchronous event output "
- + "\"SyncProducer0\"", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsNoSyncWithPeer.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", specified peered mode \"SYNCHRONOUS\" "
+ + "peer is illegal on eventOutputParameters \"SyncProducer0\" \n", e.getMessage());
}
}
@Test
- public void syncBadNotSyncWithPeer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json"};
+ public void syncBadNotSyncWithPeer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json\"\n"
- + "Apex parameters invalid\n"
- + " parameter \\\"synchronousPeer\\\" is illegal on non synchronous event output \"SyncProducer0\"",
- e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsNotSyncWithPeer.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", specified peered mode \"SYNCHRONOUS\" peer is illegal "
+ + "on eventOutputParameters \"SyncProducer0\" \n", e.getMessage());
}
}
@Test
- public void syncBadSyncBadPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsBadPeers.json"};
+ public void syncBadSyncBadPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsBadPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsBadPeers.json\"" + "\nApex parameters invalid\n"
- + " specified \"synchronousPeer\" parameter value \"SyncConsumer1\" on event input "
- + "\"SyncConsumer0\" does not exist or is an invalid peer for this event handler\n"
- + " specified \"synchronousPeer\" parameter value \"SyncConsumer0\" on event input "
- + "\"SyncConsumer1\" does not exist or is an invalid peer for this event handler\n"
- + " specified \"synchronousPeer\" parameter value \"SyncProducer1\" on event output "
- + "\"SyncProducer0\" does not exist or is an invalid peer for this event handler\n"
- + " specified \"synchronousPeer\" parameter value \"SyncProducer0\" on event output "
- + "\"SyncProducer1\" does not exist or is an invalid peer for this event handler", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsBadPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS does not exist "
+ + "or is not defined with the same peered mode\n", e.getMessage());
}
}
@Test
- public void syncBadSyncInvalidTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json"};
+ public void syncBadSyncInvalidTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsInvalidTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsInvalidTimeout.json\"\n"
- + "Apex parameters invalid\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-1\" is illegal on synchronous event input "
- + "\"SyncConsumer0\", specify a non-negative timeout value in milliseconds\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-99999999\" is illegal on synchronous event input "
- + "\"SyncConsumer1\", specify a non-negative timeout value in milliseconds\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-10\" is illegal on synchronous event output "
- + "\"SyncProducer0\", specify a non-negative timeout value in milliseconds\n"
- + " parameter \\\"synchronousTimeout\\\" value \"-3\" is illegal on synchronous event output "
- + "\"SyncProducer1\", specify a non-negative timeout value in milliseconds\n"
- + " synchronous timeout of event input \"SyncConsumer0\" and event output \"SyncProducer0\" "
- + "[-1/-10] do not match\n"
- + " synchronous timeout of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1\" [-99999999/-3] do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsInvalidTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " specified peered mode \"SYNCHRONOUS\" timeout value \"-10\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, specified peered mode \"SYNCHRONOUS\" timeout value \"-3\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n"
+ + " parameter group map \"eventInputParameters\" INVALID, parameter group has status INVALID\n"
+ + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID, "
+ + "specified peered mode \"SYNCHRONOUS\" timeout value \"-1\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " specified peered mode \"SYNCHRONOUS\" timeout value \"-99999999\" is illegal, "
+ + "specify a non-negative timeout value in milliseconds\n", e.getMessage());
}
}
@Test
- public void syncBadSyncBadTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json"};
+ public void syncBadSyncBadTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsBadTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsBadTimeout.json\"\n" + "Apex parameters invalid\n"
- + " parameter \\\"synchronousTimeout\\\" is illegal on non synchronous event output "
- + "\"MyOtherProducer\"", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsBadTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"MyOtherProducer\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, specified peered mode \"SYNCHRONOUS\" "
+ + "timeout is illegal on eventOutputParameters \"MyOtherProducer\"\n", e.getMessage());
}
}
@Test
- public void syncBadSyncUnpairedTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json"};
+ public void syncBadSyncUnpairedTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncBadParamsUnpairedTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncBadParamsUnpairedTimeout.json\"\n"
- + "Apex parameters invalid\n"
- + " synchronous timeout of event input \"SyncConsumer0\" and event output "
- + "\"SyncProducer0\" [1/10] do not match\n"
- + " synchronous timeout of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1\" [99999999/3] do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncBadParamsUnpairedTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS timeout 10 on event handler "
+ + "\"SyncProducer0\" does not equal timeout 1 on event handler \"SyncConsumer0\"\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS timeout 3 on event handler "
+ + "\"SyncProducer1\" does not equal timeout 99999999 on event handler \"SyncConsumer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS timeout 1 on event handler "
+ + "\"SyncConsumer0\" does not equal timeout 10 on event handler \"SyncProducer0\"\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS timeout 99999999 on event handler "
+ + "\"SyncConsumer1\" does not equal timeout 3 on event handler \"SyncProducer1\"\n" + "",
+ e.getMessage());
}
}
@Test
- public void syncGoodSyncGoodTimeoutProducer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json"};
+ public void syncGoodSyncGoodTimeoutProducer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParamsProducerTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(12345, parameters.getEventInputParameters().get("SyncConsumer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventInputParameters().get("SyncConsumer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(12345, parameters.getEventOutputParameters().get("SyncProducer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventOutputParameters().get("SyncProducer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
} catch (final Exception e) {
fail("This test should not throw an exception");
}
}
@Test
- public void syncGoodSyncGoodTimeoutConsumer() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json"};
+ public void syncGoodSyncGoodTimeoutConsumer() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParamsConsumerTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(12345, parameters.getEventInputParameters().get("SyncConsumer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventInputParameters().get("SyncConsumer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(12345, parameters.getEventOutputParameters().get("SyncProducer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventOutputParameters().get("SyncProducer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
} catch (final Exception e) {
fail("This test should not throw an exception");
}
}
@Test
- public void syncGoodSyncGoodTimeoutBoth() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncGoodParamsBothTimeout.json"};
+ public void syncGoodSyncGoodTimeoutBoth() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParamsBothTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
assertEquals(12345, parameters.getEventInputParameters().get("SyncConsumer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventInputParameters().get("SyncConsumer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(12345, parameters.getEventOutputParameters().get("SyncProducer0")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
assertEquals(1, parameters.getEventOutputParameters().get("SyncProducer1")
- .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ .getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
} catch (final Exception e) {
fail("This test should not throw an exception");
}
}
@Test
- public void syncUnusedConsumerPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json"};
+ public void syncUnusedConsumerPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncUnusedConsumerPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedConsumerPeers.json\"\n" + "Apex parameters invalid\n"
- + " value of parameter \"synchronousPeer\" on event output \"SyncProducer1\" must be unique, "
- + "it s used on another event output\n"
- + " synchronous peers of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1/SyncConsumer0\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncUnusedConsumerPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, peer \"SyncConsumer0 for peered mode SYNCHRONOUS, "
+ + "value \"SyncProducer0\" on peer \"SyncConsumer0\" "
+ + "does not equal event handler \"SyncProducer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" "
+ + "INVALID, peer \"SyncProducer1 for peered mode SYNCHRONOUS, "
+ + "value \"SyncConsumer0\" on peer \"SyncProducer1\" "
+ + "does not equal event handler \"SyncConsumer1\"\n", e.getMessage());
}
}
@Test
- public void syncMismatchedPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncMismatchedPeers.json"};
+ public void syncMismatchedPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncMismatchedPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncMismatchedPeers.json\"\nApex parameters invalid\n"
- + " synchronous peers of event input \"SyncConsumer0\" and event output "
- + "\"SyncProducer0/SyncConsumer1\" do not match\n"
- + " synchronous peers of event input \"SyncConsumer1\" and event output "
- + "\"SyncProducer1/SyncConsumer0\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncMismatchedPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer1 for peered mode SYNCHRONOUS, value \"SyncProducer1\" "
+ + "on peer \"SyncConsumer1\" does not equal event handler \"SyncProducer0\"\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer0\" "
+ + "on peer \"SyncConsumer0\" does not equal event handler \"SyncProducer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer0 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" "
+ + "on peer \"SyncProducer0\" does not equal event handler \"SyncConsumer0\"\n"
+ + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer0\" "
+ + "on peer \"SyncProducer1\" does not equal event handler \"SyncConsumer1\"\n",
+ e.getMessage());
}
}
@Test
- public void syncUnusedProducerPeers() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedProducerPeers.json"};
+ public void syncUnusedProducerPeers() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncUnusedProducerPeers.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\nApex parameters invalid\n"
- + " value of parameter \"synchronousPeer\" on event input \"SyncConsumer1\" must be unique, "
- + "it is used on another event input\nsynchronous peers of event input \"SyncConsumer0\" and event"
- + " output \"SyncProducer1/SyncConsumer1\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncProducer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer1\" on peer "
+ + "\"SyncConsumer0\" does not equal event handler \"SyncProducer0\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, parameter group has status INVALID\n"
+ + " parameter group \"SyncConsumer0\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID"
+ + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" on peer "
+ + "\"SyncProducer1\" does not equal event handler \"SyncConsumer0\"\n", e.getMessage());
}
}
@Test
- public void syncMismatchedTimeout() throws ApexParameterException {
- final String[] args = {"-c", "src/test/resources/parameters/syncUnusedProducerPeers.json"};
+ public void syncMismatchedTimeout() throws ParameterException {
+ final String[] args = { "-c", "src/test/resources/parameters/syncMismatchedTimeout.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
new ApexParameterHandler().getParameters(arguments);
fail("This test should throw an exception");
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
assertEquals("validation error(s) on parameters from "
- + "\"src/test/resources/parameters/syncUnusedProducerPeers.json\"\n" + "Apex parameters invalid\n"
- + " value of parameter \"synchronousPeer\" on event input \"SyncConsumer1\" "
- + "must be unique, it s used on another event input\n"
- + " synchronous peers of event input \"SyncConsumer0\" and event output "
- + "\"SyncProducer1/SyncConsumer1\" do not match", e.getMessage());
+ + "\"src/test/resources/parameters/syncMismatchedTimeout.json\"\n"
+ + "parameter group \"APEX_PARAMETERS\" type "
+ + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, "
+ + "parameter group has status INVALID\n"
+ + " parameter group map \"eventOutputParameters\" "
+ + "INVALID, parameter group has status INVALID\n"
+ + " parameter group \"SyncProducer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " peer \"SyncConsumer1 for peered mode SYNCHRONOUS timeout 456 "
+ + "on event handler \"SyncProducer1\" does not equal timeout 123 "
+ + "on event handler \"SyncConsumer1\"\n"
+ + " parameter group map \"eventInputParameters\" INVALID, "
+ + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer1\" type "
+ + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID,"
+ + " peer \"SyncProducer1 for peered mode SYNCHRONOUS timeout 123 "
+ + "on event handler \"SyncConsumer1\" does not equal timeout 456 "
+ + "on event handler \"SyncProducer1\"\n", e.getMessage());
}
}
@Test
public void syncGoodParametersTest() {
- final String[] args = {"-c", "src/test/resources/parameters/SyncGoodParams.json"};
+ final String[] args = { "-c", "src/test/resources/parameters/syncGoodParams.json" };
final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args);
try {
@@ -306,22 +411,22 @@ public class SyncParameterTests {
assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount());
assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort());
- final CarrierTechnologyParameters prodCT0 =
- parameters.getEventOutputParameters().get("SyncProducer0").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEP0 =
- parameters.getEventOutputParameters().get("SyncProducer0").getEventProtocolParameters();
- final CarrierTechnologyParameters consCT0 =
- parameters.getEventInputParameters().get("SyncConsumer0").getCarrierTechnologyParameters();
- final EventProtocolParameters consEP0 =
- parameters.getEventInputParameters().get("SyncConsumer0").getEventProtocolParameters();
- final CarrierTechnologyParameters prodCT1 =
- parameters.getEventOutputParameters().get("SyncProducer1").getCarrierTechnologyParameters();
- final EventProtocolParameters prodEP1 =
- parameters.getEventOutputParameters().get("SyncProducer1").getEventProtocolParameters();
- final CarrierTechnologyParameters consCT1 =
- parameters.getEventInputParameters().get("SyncConsumer1").getCarrierTechnologyParameters();
- final EventProtocolParameters consEP1 =
- parameters.getEventInputParameters().get("SyncConsumer1").getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCT0 = parameters.getEventOutputParameters().get("SyncProducer0")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEP0 = parameters.getEventOutputParameters().get("SyncProducer0")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters consCT0 = parameters.getEventInputParameters().get("SyncConsumer0")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters consEP0 = parameters.getEventInputParameters().get("SyncConsumer0")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters prodCT1 = parameters.getEventOutputParameters().get("SyncProducer1")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters prodEP1 = parameters.getEventOutputParameters().get("SyncProducer1")
+ .getEventProtocolParameters();
+ final CarrierTechnologyParameters consCT1 = parameters.getEventInputParameters().get("SyncConsumer1")
+ .getCarrierTechnologyParameters();
+ final EventProtocolParameters consEP1 = parameters.getEventInputParameters().get("SyncConsumer1")
+ .getEventProtocolParameters();
assertEquals("FILE", prodCT0.getLabel());
assertEquals("JSON", prodEP0.getLabel());
@@ -335,8 +440,7 @@ public class SyncParameterTests {
assertTrue(consCT1 instanceof SuperDooperCarrierTechnologyParameters);
assertTrue(consEP1 instanceof SuperTokenDelimitedEventProtocolParameters);
- final SuperDooperCarrierTechnologyParameters superDooperParameters =
- (SuperDooperCarrierTechnologyParameters) consCT1;
+ final SuperDooperCarrierTechnologyParameters superDooperParameters = (SuperDooperCarrierTechnologyParameters) consCT1;
assertEquals("localhost:9092", superDooperParameters.getBootstrapServers());
assertEquals("all", superDooperParameters.getAcks());
assertEquals(0, superDooperParameters.getRetries());
@@ -350,17 +454,17 @@ public class SyncParameterTests {
assertEquals("apex-out", superDooperParameters.getProducerTopic());
assertEquals(100, superDooperParameters.getConsumerPollTime());
assertEquals("org.apache.superDooper.common.serialization.StringSerializer",
- superDooperParameters.getKeySerializer());
+ superDooperParameters.getKeySerializer());
assertEquals("org.apache.superDooper.common.serialization.StringSerializer",
- superDooperParameters.getValueSerializer());
+ superDooperParameters.getValueSerializer());
assertEquals("org.apache.superDooper.common.serialization.StringDeserializer",
- superDooperParameters.getKeyDeserializer());
+ superDooperParameters.getKeyDeserializer());
assertEquals("org.apache.superDooper.common.serialization.StringDeserializer",
- superDooperParameters.getValueDeserializer());
+ superDooperParameters.getValueDeserializer());
- final String[] consumerTopics = {"apex-in"};
+ final String[] consumerTopics = { "apex-in" };
assertEquals(Arrays.asList(consumerTopics), superDooperParameters.getConsumerTopicList());
- } catch (final ApexParameterException e) {
+ } catch (final ParameterException e) {
fail("This test should not throw an exception");
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
index 604849f31..3ec84b150 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java
@@ -24,8 +24,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for SuperDooper as an event carrier technology.
@@ -46,14 +47,11 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
private static final int DEFAULT_SESSION_TIMEOUT = 30000;
private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
private static final int DEFAULT_CONSUMER_POLL_TIME = 100;
- private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = {"apex-in"};
+ private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = { "apex-in" };
private static final String DEFAULT_KEY_SERIALIZER = "org.apache.superDooper.common.serialization.StringSerializer";
- private static final String DEFAULT_VALUE_SERIALIZER =
- "org.apache.superDooper.common.serialization.StringSerializer";
- private static final String DEFAULT_KEY_DESERIALIZER =
- "org.apache.superDooper.common.serialization.StringDeserializer";
- private static final String DEFAULT_VALUE_DESERIALIZER =
- "org.apache.superDooper.common.serialization.StringDeserializer";
+ private static final String DEFAULT_VALUE_SERIALIZER = "org.apache.superDooper.common.serialization.StringSerializer";
+ private static final String DEFAULT_KEY_DESERIALIZER = "org.apache.superDooper.common.serialization.StringDeserializer";
+ private static final String DEFAULT_VALUE_DESERIALIZER = "org.apache.superDooper.common.serialization.StringDeserializer";
// Parameter property map tokens
private static final String PROPERTY_BOOTSTRAP_SERVERS = "bootstrap.servers";
@@ -91,19 +89,18 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
private String valueDeserializer = DEFAULT_VALUE_DESERIALIZER;
/**
- * Constructor to create a file carrier technology parameters instance and register the instance
- * with the parameter service.
+ * Constructor to create a file carrier technology parameters instance and register the instance with the parameter
+ * service.
*/
public SuperDooperCarrierTechnologyParameters() {
- super(SuperDooperCarrierTechnologyParameters.class.getCanonicalName());
- ParameterService.registerParameters(SuperDooperCarrierTechnologyParameters.class, this);
+ super();
// Set the carrier technology properties for the FILE carrier technology
this.setLabel("SUPER_DOOPER");
this.setEventProducerPluginClass(
- "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventProducer");
+ "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventProducer");
this.setEventConsumerPluginClass(
- "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventSubscriber");
+ "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperEventSubscriber");
}
/**
@@ -454,92 +451,103 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
+ * @see org.onap.policy.common.parameters.ParameterGroup#getName()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public String getName() {
+ return this.getLabel();
+ }
- errorMessageBuilder.append(super.validate());
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (bootstrapServers == null || bootstrapServers.trim().length() == 0) {
- errorMessageBuilder
- .append(" bootstrapServers not specified, must be specified as a string of form host:port\n");
+ result.setResult("bootstrapServers", ValidationStatus.INVALID,
+ "bootstrapServers not specified, must be specified as a string of form host:port");
}
if (acks == null || acks.trim().length() == 0) {
- errorMessageBuilder.append(" acks not specified, must be specified as a string with values [0|1|all]\n");
+ result.setResult("acks", ValidationStatus.INVALID,
+ "acks not specified, must be specified as a string with values [0|1|all]");
}
if (retries < 0) {
- errorMessageBuilder.append(" retries [" + retries + "] invalid, must be specified as retries >= 0\n");
+ result.setResult("retries", ValidationStatus.INVALID, "[" + retries + "] invalid, must be specified as retries >= 0");
}
if (batchSize < 0) {
- errorMessageBuilder
- .append(" batchSize [" + batchSize + "] invalid, must be specified as batchSize >= 0\n");
+ result.setResult("batchSize", ValidationStatus.INVALID, "[" + batchSize + "] invalid, must be specified as batchSize >= 0");
}
if (lingerTime < 0) {
- errorMessageBuilder
- .append(" lingerTime [" + lingerTime + "] invalid, must be specified as lingerTime >= 0\n");
+ result.setResult("lingerTime", ValidationStatus.INVALID, "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0");
}
if (bufferMemory < 0) {
- errorMessageBuilder
- .append(" bufferMemory [" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0\n");
+ result.setResult("bufferMemory", ValidationStatus.INVALID, "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0");
}
if (groupId == null || groupId.trim().length() == 0) {
- errorMessageBuilder.append(" groupId not specified, must be specified as a string\n");
+ result.setResult("groupId", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (autoCommitTime < 0) {
- errorMessageBuilder.append(
- " autoCommitTime [" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0\n");
+ result.setResult("autoCommitTime", ValidationStatus.INVALID, "[" + autoCommitTime
+ + "] invalid, must be specified as autoCommitTime >= 0");
}
if (sessionTimeout < 0) {
- errorMessageBuilder.append(
- " sessionTimeout [" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0\n");
+ result.setResult("sessionTimeout", ValidationStatus.INVALID, "sessionTimeout [" + sessionTimeout
+ + "] invalid, must be specified as sessionTimeout >= 0");
}
if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" producerTopic not specified, must be specified as a string\n");
+ result.setResult("producerTopic", ValidationStatus.INVALID, "producerTopic not specified, must be specified as a string");
}
if (consumerPollTime < 0) {
- errorMessageBuilder.append(" consumerPollTime [" + consumerPollTime
- + "] invalid, must be specified as consumerPollTime >= 0\n");
+ result.setResult("consumerPollTime", ValidationStatus.INVALID, "[" + consumerPollTime
+ + "] invalid, must be specified as consumerPollTime >= 0");
}
if (consumerTopicList == null || consumerTopicList.length == 0) {
- errorMessageBuilder.append(" consumerTopicList not specified, must be specified as a list of strings\n");
+ result.setResult("consumerTopicList", ValidationStatus.INVALID, "not specified, must be specified as a list of strings");
}
+ StringBuilder consumerTopicMessageBuilder = new StringBuilder();
for (final String consumerTopic : consumerTopicList) {
if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
- + "\" specified on consumerTopicList, consumer topics must be specified as strings\n");
+ consumerTopicMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
+ + "\" specified on consumerTopicList, consumer topics must be specified as strings");
}
}
+
+ if (consumerTopicMessageBuilder.length() > 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID, consumerTopicMessageBuilder.toString());
+ }
if (keySerializer == null || keySerializer.trim().length() == 0) {
- errorMessageBuilder.append(" keySerializer not specified, must be specified as a string\n");
+ result.setResult("keySerializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (valueSerializer == null || valueSerializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueSerializer not specified, must be specified as a string\n");
+ result.setResult("valueSerializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (keyDeserializer == null || keyDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" keyDeserializer not specified, must be specified as a string\n");
+ result.setResult("keyDeserializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
if (valueDeserializer == null || valueDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueDeserializer not specified, must be specified as a string\n");
+ result.setResult("valueDeserializer", ValidationStatus.INVALID, "not specified, must be specified as a string");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java
index 8d7d65977..72dbc57a6 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.service.engine.parameters.dummyclasses;
import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Distributor parameters for the Super Dooper Distributor.
@@ -44,9 +43,7 @@ public class SuperDooperDistributorParameters extends DistributorParameters {
private String jGroupsBindAddress = DEFAULT_INFINSPAN_JGROUPS_BIND_ADDRESS;
public SuperDooperDistributorParameters() {
- super(SuperDooperDistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(SuperDooperDistributorParameters.class, this);
- ParameterService.registerParameters(DistributorParameters.class, this);
+ super();
}
public String getConfigFile() {
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
index bac271319..02d986186 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java
@@ -20,7 +20,6 @@
package org.onap.policy.apex.service.engine.parameters.dummyclasses;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters;
import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters;
@@ -40,7 +39,6 @@ public class SuperTokenDelimitedEventProtocolParameters extends EventProtocolTex
*/
public SuperTokenDelimitedEventProtocolParameters() {
super(JSONEventProtocolParameters.class.getCanonicalName());
- ParameterService.registerParameters(SuperTokenDelimitedEventProtocolParameters.class, this);
// Set the event protocol properties for the JSON carrier technology
this.setLabel(SUPER_TOKEN_EVENT_PROTOCOL_LABEL);
diff --git a/services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json b/services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json
new file mode 100644
index 000000000..378106825
--- /dev/null
+++ b/services/services-engine/src/test/resources/parameters/syncMismatchedTimeout.json
@@ -0,0 +1,74 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 19,
+ "deploymentPort": 65522,
+ "policyModelFileName": "src/test/resources/policymodels/SamplePolicyModelMVEL.json",
+ "engineParameters": {
+ "executorParameters": {
+ "MVEL": {
+ "parameterClassName": "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "SyncProducer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "/tmp/aaa.json"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "synchronousMode": true,
+ "synchronousPeer": "SyncConsumer0"
+ },
+ "SyncProducer1": {
+ "synchronousMode": true,
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "/tmp/aaa.json"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "synchronousPeer": "SyncConsumer1",
+ "synchronousTimeout" : 456
+ }
+ },
+ "eventInputParameters": {
+ "SyncConsumer0": {
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "synchronousMode": true,
+ "synchronousPeer": "SyncProducer0",
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "/tmp/bbb.json"
+ }
+ }
+ },
+ "SyncConsumer1": {
+ "synchronousPeer": "SyncProducer1",
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "SUPER_DOOPER",
+ "parameterClassName": "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "SUPER_TOK_DEL",
+ "parameterClassName": "org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperTokenDelimitedEventProtocolParameters"
+ },
+ "synchronousMode": true,
+ "synchronousTimeout" : 123
+ }
+ }
+} \ No newline at end of file
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
index 87968e64d..e5dab9706 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
@@ -40,7 +40,6 @@ import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistribut
import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.context.parameters.LockManagerParameters;
import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.lock.modifier.LockType;
import org.onap.policy.apex.context.test.locking.ConcurrentContext;
@@ -52,13 +51,13 @@ import org.onap.policy.apex.context.test.utils.ZooKeeperServerServiceProvider;
import org.onap.policy.apex.core.infrastructure.messaging.util.MessagingUtils;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
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.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -226,7 +225,7 @@ public class TestConcurrentContext {
curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
contextParameters.setLockManagerParameters(curatorParameters);
- ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
+ ParameterService.register(curatorParameters);
final ConfigrationProvider configrationProvider = getConfigrationProvider("CuratorLock",
TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS);
@@ -308,7 +307,7 @@ public class TestConcurrentContext {
curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
contextParameters.setLockManagerParameters(curatorParameters);
- ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
+ ParameterService.register(curatorParameters);
final ConfigrationProvider configrationProvider = getConfigrationProvider("InfinispanMultiCuratorLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
@@ -342,7 +341,7 @@ public class TestConcurrentContext {
curatorParameters.setPluginClass(CuratorLockManager.class.getCanonicalName());
curatorParameters.setZookeeperAddress(ZOOKEEPER_ADDRESS + ":" + zookeeperPort);
contextParameters.setLockManagerParameters(curatorParameters);
- ParameterService.registerParameters(LockManagerParameters.class, curatorParameters);
+ ParameterService.register(curatorParameters);
final ConfigrationProvider configrationProvider = getConfigrationProvider("HazelcastMultiCuratorLock",
TEST_JVM_COUNT_MULTI_JVM, TEST_THREAD_COUNT_MULTI_JVM, TEST_THREAD_LOOPS);
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java
index 8b1cc0b04..3c0e9f984 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java
@@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine;
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.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
public class TestApexEngineJRuby {
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("JRUBY", new JrubyExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test apex engine.
@@ -38,10 +86,7 @@ public class TestApexEngineJRuby {
*/
@Test
public void testApexEngineJRuby() throws ApexException, InterruptedException, IOException {
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("JRUBY", new JrubyExecutorParameters());
-
- new TestApexEngine("JRUBY", parameters);
- new TestApexEngine("JRUBY", parameters);
+ new TestApexEngine("JRUBY", engineParameters);
+ new TestApexEngine("JRUBY", engineParameters);
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java
index 44593a0a2..c1d68760d 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java
@@ -22,10 +22,17 @@ package org.onap.policy.apex.plugins.executor.test.script.engine;
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.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestApexEngine_Java.
@@ -33,6 +40,47 @@ import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestApexEngineJava {
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test apex engine.
@@ -43,10 +91,7 @@ public class TestApexEngineJava {
*/
@Test
public void testApexEngineJava() throws InterruptedException, IOException, ApexException {
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
-
- new TestApexEngine("JAVA", parameters);
- new TestApexEngine("JAVA", parameters);
+ new TestApexEngine("JAVA", engineParameters);
+ new TestApexEngine("JAVA", engineParameters);
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java
index 1f55f8458..1f5c1d4b8 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java
@@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine;
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.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
public class TestApexEngineJavascript {
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test apex engine.
@@ -38,10 +86,8 @@ public class TestApexEngineJavascript {
*/
@Test
public void testApexEngineJavascript() throws ApexException, InterruptedException, IOException {
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
- new TestApexEngine("JAVASCRIPT", parameters);
- new TestApexEngine("JAVASCRIPT", parameters);
+ new TestApexEngine("JAVASCRIPT", engineParameters);
+ new TestApexEngine("JAVASCRIPT", engineParameters);
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java
index eabe63dfb..b5b0f9a78 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java
@@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine;
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.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
public class TestApexEngineJython {
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("JYTHON", new JythonExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test apex engine.
@@ -38,10 +86,7 @@ public class TestApexEngineJython {
*/
@Test
public void testApexEngineJython() throws ApexException, InterruptedException, IOException {
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("JYTHON", new JythonExecutorParameters());
-
- new TestApexEngine("JYTHON", parameters);
- new TestApexEngine("JYTHON", parameters);
+ new TestApexEngine("JYTHON", engineParameters);
+ new TestApexEngine("JYTHON", engineParameters);
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java
index aea7cecc6..e500c9d3b 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java
@@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine;
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.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.common.parameters.ParameterService;
public class TestApexEngineMVEL {
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test apex engine.
@@ -38,10 +86,7 @@ public class TestApexEngineMVEL {
*/
@Test
public void testApexEngineMVEL() throws ApexException, InterruptedException, IOException {
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
-
- new TestApexEngine("MVEL", parameters);
- new TestApexEngine("MVEL", parameters);
+ new TestApexEngine("MVEL", engineParameters);
+ new TestApexEngine("MVEL", engineParameters);
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java
index 0ed78a13f..07a374926 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java
@@ -30,7 +30,13 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
@@ -41,6 +47,7 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -53,6 +60,48 @@ public class TestEventInstantiation {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestEventInstantiation.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
+
/**
* Test event instantiation.
*
@@ -69,9 +118,6 @@ public class TestEventInstantiation {
final AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
assertNotNull(apexPolicyModel);
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
-
final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(apexPolicyModel.getKey());
apexEngine.updateModel(apexPolicyModel);
apexEngine.start();
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java
index 5ca71cf33..83e69c98f 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java
@@ -27,8 +27,14 @@ import static org.junit.Assert.fail;
import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.ContextAlbum;
+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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl;
@@ -38,6 +44,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener;
import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -50,6 +57,48 @@ public class TestContextUpdateDifferentModels {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateDifferentModels.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
+
@Test
public void testContextUpdateDifferentModels() throws ApexException, InterruptedException, IOException {
logger.debug("Running test testContextUpdateDifferentModels . . .");
@@ -57,9 +106,6 @@ public class TestContextUpdateDifferentModels {
final AxPolicyModel apexModelSample = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
assertNotNull(apexModelSample);
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
-
final ApexEngineImpl apexEngine =
(ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1"));
final TestApexActionListener listener = new TestApexActionListener("Test");
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java
index e78d4c5bb..7aaa1e585 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java
@@ -30,8 +30,13 @@ import java.util.HashMap;
import java.util.Map;
import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.ContextException;
+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.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
@@ -42,6 +47,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener;
import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -54,14 +60,52 @@ public class TestContextUpdateModel {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateModel.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineParameters engineParameters;
+
+ @Before
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
@Test
public void testContextUpdateModel() throws ApexException, InterruptedException, IOException {
final AxArtifactKey key = new AxArtifactKey("TestApexEngine", "0.0.1");
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
-
final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(key);
final TestApexActionListener listener = new TestApexActionListener("Test");
apexEngine.addEventListener("listener", listener);
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/KafkaEventProducer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/KafkaEventProducer.java
index 639b450df..c243b8b07 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/KafkaEventProducer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/KafkaEventProducer.java
@@ -40,14 +40,12 @@ public class KafkaEventProducer implements Runnable {
private final long eventInterval;
private long eventsSentCount = 0;
- private Producer<String, String> producer;
-
private final Thread producerThread;
private boolean sendEventsFlag = false;
private boolean stopFlag = false;
public KafkaEventProducer(final String topic, final String kafkaServerAddress, final int eventCount,
- final boolean xmlEvents, final long eventInterval) {
+ final boolean xmlEvents, final long eventInterval) {
this.topic = topic;
this.kafkaServerAddress = kafkaServerAddress;
this.eventCount = eventCount;
@@ -70,13 +68,13 @@ public class KafkaEventProducer implements Runnable {
kafkaProducerProperties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
kafkaProducerProperties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
- producer = new KafkaProducer<String, String>(kafkaProducerProperties);
+ final Producer<String, String> producer = new KafkaProducer<String, String>(kafkaProducerProperties);
while (producerThread.isAlive() && !stopFlag) {
ThreadUtilities.sleep(50);
if (sendEventsFlag) {
- sendEventsToTopic();
+ sendEventsToTopic(producer);
sendEventsFlag = false;
}
}
@@ -88,13 +86,13 @@ public class KafkaEventProducer implements Runnable {
sendEventsFlag = true;
}
- private void sendEventsToTopic() {
+ private void sendEventsToTopic(final Producer<String, String> producer) {
System.out.println(KafkaEventProducer.class.getCanonicalName() + ": sending events to Kafka server at "
- + kafkaServerAddress + ", event count " + eventCount + ", xmlEvents " + xmlEvents);
+ + kafkaServerAddress + ", event count " + eventCount + ", xmlEvents " + xmlEvents);
for (int i = 0; i < eventCount; i++) {
System.out.println(KafkaEventProducer.class.getCanonicalName() + ": waiting " + eventInterval
- + " milliseconds before sending next event");
+ + " milliseconds before sending next event");
ThreadUtilities.sleep(eventInterval);
String eventString = null;
@@ -159,8 +157,8 @@ public class KafkaEventProducer implements Runnable {
return;
}
- final KafkaEventProducer producer =
- new KafkaEventProducer(args[0], args[1], eventCount, xmlEvents, eventInterval);
+ final KafkaEventProducer producer = new KafkaEventProducer(args[0], args[1], eventCount, xmlEvents,
+ eventInterval);
producer.sendEvents();
producer.shutdown();
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java
index d624d66bf..9aa9ac931 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java
@@ -26,6 +26,16 @@ import java.io.IOException;
import java.nio.file.Files;
import java.util.Properties;
+import kafka.admin.AdminUtils;
+import kafka.admin.RackAwareMode;
+import kafka.server.BrokerState;
+import kafka.server.KafkaConfig;
+import kafka.server.KafkaServer;
+import kafka.utils.TestUtils;
+import kafka.utils.ZKStringSerializer$;
+import kafka.utils.ZkUtils;
+import kafka.zk.EmbeddedZookeeper;
+
import org.I0Itec.zkclient.ZkClient;
import org.apache.kafka.common.utils.MockTime;
import org.apache.kafka.common.utils.Time;
@@ -37,14 +47,6 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
-import kafka.admin.AdminUtils;
-import kafka.admin.RackAwareMode;
-import kafka.server.KafkaConfig;
-import kafka.server.KafkaServer;
-import kafka.utils.TestUtils;
-import kafka.utils.ZKStringSerializer$;
-import kafka.utils.ZkUtils;
-import kafka.zk.EmbeddedZookeeper;
public class TestKafka2Kafka {
// The method of starting an embedded Kafka server used in this example is based on the method
@@ -84,11 +86,13 @@ public class TestKafka2Kafka {
final KafkaConfig config = new KafkaConfig(brokerProps);
final Time mock = new MockTime();
kafkaServer = TestUtils.createServer(config, mock);
-
+ kafkaServer.startup();
+
// create topics
AdminUtils.createTopic(zkUtils, "apex-in-0", 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
AdminUtils.createTopic(zkUtils, "apex-in-1", 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
AdminUtils.createTopic(zkUtils, "apex-out", 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
+
}
@AfterClass
@@ -120,12 +124,13 @@ public class TestKafka2Kafka {
throws MessagingException, ApexException {
final KafkaEventSubscriber subscriber =
new KafkaEventSubscriber("apex-out-" + topicSuffix, "localhost:" + BROKERPORT);
- final KafkaEventProducer producer = new KafkaEventProducer("apex-in-" + topicSuffix, "localhost:" + BROKERPORT,
- EVENT_COUNT, xmlEvents, EVENT_INTERVAL);
final ApexMain apexMain = new ApexMain(args);
ThreadUtilities.sleep(3000);
+ final KafkaEventProducer producer = new KafkaEventProducer("apex-in-" + topicSuffix, "localhost:" + BROKERPORT,
+ EVENT_COUNT, xmlEvents, EVENT_INTERVAL);
+
producer.sendEvents();
final long testStartTime = System.currentTimeMillis();
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestFile2REST.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestFile2REST.java
index d304eb9d0..dd3f15ab6 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestFile2REST.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestFile2REST.java
@@ -140,7 +140,7 @@ public class TestFile2REST {
System.setOut(stdout);
System.setErr(stderr);
- assertTrue(outString.contains(" no URL has been set for event sending on REST client"));
+ assertTrue(outString.contains(" no URL has been set for event sending on REST client"));
}
@Test
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestREST2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestREST2File.java
index f8898a7c5..922e03217 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestREST2File.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restclient/TestREST2File.java
@@ -123,7 +123,7 @@ public class TestREST2File {
System.setOut(stdout);
System.setErr(stderr);
- assertTrue(outString.contains(" no URL has been set for event sending on REST client"));
+ assertTrue(outString.contains(" no URL has been set for event sending on REST client"));
}
@Test
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restserver/TestRESTServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restserver/TestRESTServer.java
index b0bcac439..15928b3c7 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restserver/TestRESTServer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restserver/TestRESTServer.java
@@ -201,7 +201,7 @@ public class TestRESTServer {
System.setOut(stdout);
System.setErr(stderr);
- assertTrue(outString.contains(" host and port are specified only in standalone mode"));
+ assertTrue(outString.contains(" host is specified only in standalone mode"));
}
@Test
@@ -220,7 +220,7 @@ public class TestRESTServer {
System.setOut(stdout);
System.setErr(stderr);
- assertTrue(outString.contains(" host and port are specified only in standalone mode"));
+ assertTrue(outString.contains(" port is specified only in standalone mode"));
}
@Test
@@ -300,7 +300,7 @@ public class TestRESTServer {
System.setErr(stderr);
assertTrue(outString.contains(
- "event output for peered mode \"SYNCHRONOUS\": peer \"FirstConsumer\" for event handler \"FirstProducer\" does not exist or is not defined as being synchronous"));
+ "peer \"FirstConsumer for peered mode SYNCHRONOUS does not exist or is not defined with the same peered mode"));
}
@Test
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java
index bcdcd571f..d68576d16 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java
@@ -33,9 +33,9 @@ import org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.service.engine.main.ApexMain;
+import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.ResourceUtils;
public class EventAlbumContextTest {
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java
index adc416dca..451b4c76a 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java
@@ -33,6 +33,10 @@ import java.util.Map;
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.core.deployment.BatchDeployer;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
@@ -42,6 +46,7 @@ import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -58,13 +63,55 @@ public class EngDepMessagingTest {
private static final long MAX_START_WAIT = 10000; // 10 sec
- /**
- * Sets the up.
- *
- * @throws Exception the exception
- */
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ private EngineServiceParameters engineServiceParameters;
+
@Before
- public void setUp() throws Exception {}
+ public void beforeTest() {
+ schemaParameters = new SchemaParameters();
+
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+
+ 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);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ engineServiceParameters = new EngineServiceParameters();
+ engineServiceParameters.setName("EngDepMessagingTest");
+ engineServiceParameters.setVersion("0.0.1");
+ engineServiceParameters.setDeploymentPort(58820);
+ engineServiceParameters.setInstanceCount(3);
+ engineServiceParameters.setId(100);
+ engineServiceParameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+
+ ParameterService.register(engineServiceParameters);
+ ParameterService.register(engineServiceParameters.getEngineParameters());
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(engineServiceParameters);
+ ParameterService.deregister(engineServiceParameters.getEngineParameters());
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+
+ ParameterService.deregister(schemaParameters);
+ }
/**
* Test EngDep messaging.
@@ -79,15 +126,7 @@ public class EngDepMessagingTest {
ModelService.clear();
- final EngineServiceParameters parameters = new EngineServiceParameters();
- parameters.setName("EngDepMessagingTest");
- parameters.setVersion("0.0.1");
- parameters.setDeploymentPort(58820);
- parameters.setInstanceCount(3);
- parameters.setId(100);
- parameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
-
- final EngineTestServer server = new EngineTestServer(parameters);
+ final EngineTestServer server = new EngineTestServer(engineServiceParameters);
assertNotNull(server);
final Thread serverThread = new Thread(server);
@@ -135,7 +174,7 @@ public class EngDepMessagingTest {
}
ThreadUtilities.sleep(500);
- assertEquals(server.getTotalActionEventsReceived(), 2);
+ assertEquals(2, server.getTotalActionEventsReceived());
deployer1.init();
deployer1.stopEngines();
@@ -160,7 +199,7 @@ public class EngDepMessagingTest {
}
ThreadUtilities.sleep(500);
- assertEquals(server.getTotalActionEventsReceived(), 4);
+ assertEquals(4, server.getTotalActionEventsReceived());
deployer2.init();
deployer2.stopEngines();
diff --git a/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml b/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml
index 46722477a..5b416f50d 100644
--- a/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml
+++ b/testsuites/performance/performance-context-metrics/src/test/resources/infinispan/infinispan.xml
@@ -19,24 +19,23 @@
============LICENSE_END=========================================================
-->
-<?xml version="1.0" encoding="UTF-8"?>
-
-<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="external-file" path="infinispan/default-jgroups-tcp.xml" />
- </jgroups>
+<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="external-file" path="infinispan/default-jgroups-tcp.xml" />
+ </jgroups>
- <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
- <transport cluster="apexCluster" stack="external-file" />
- <jmx />
- <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- <replicated-cache name="TestContext_0.0.1" mode="SYNC">
- <state-transfer enabled="true" />
- </replicated-cache>
- </cache-container>
+ <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
+ <transport cluster="apexCluster" stack="external-file" />
+ <jmx />
+ <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ <replicated-cache name="TestContext_0.0.1" mode="SYNC">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ </cache-container>
</infinispan>