aboutsummaryrefslogtreecommitdiffstats
path: root/examples/examples-adaptive/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-adaptive/src')
-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
2 files changed, 100 insertions, 6 deletions
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);