From f32508381ce0b555fc14978cbaa458aa4e2d91c5 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 30 Aug 2018 09:37:29 +0100 Subject: Use parameter service in apex Switch parameter handling in apex to use the ONAP PF common parameter service Change-Id: Id318d19c726b18b1a69c630fa81ca7d695355e9c Issue-ID: POLICY-954 Signed-off-by: liamfallon --- .../hazelcast/HazelcastContextDistributorTest.java | 47 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src') 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"); } - } -- cgit 1.2.3-korg