summaryrefslogtreecommitdiffstats
path: root/policy-management/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management/src/test/java/org')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java34
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java6
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java7
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java103
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java6
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java12
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java39
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java8
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java102
9 files changed, 163 insertions, 154 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
index 47baa07e..67026c0a 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public class DroolsControllerFactoryTest {
@Test
public void buildNullController() {
Properties droolsProps = new Properties();
- DroolsController droolsController = DroolsController.factory.build(droolsProps, null, null);
+ DroolsController droolsController = DroolsControllerConstants.getFactory().build(droolsProps, null, null);
if (!isNullController(droolsController)) {
fail("drools controller is not a null controller");
@@ -44,20 +44,20 @@ public class DroolsControllerFactoryTest {
@Test
public void getNullController() {
DroolsController controller =
- DroolsController.factory.get(DroolsController.NO_GROUP_ID,
- DroolsController.NO_ARTIFACT_ID, DroolsController.NO_VERSION);
+ DroolsControllerConstants.getFactory().get(DroolsControllerConstants.NO_GROUP_ID,
+ DroolsControllerConstants.NO_ARTIFACT_ID, DroolsControllerConstants.NO_VERSION);
assertNotNull(controller);
- assertEquals(DroolsController.NO_GROUP_ID, controller.getGroupId());
- assertEquals(DroolsController.NO_ARTIFACT_ID, controller.getArtifactId());
- assertEquals(DroolsController.NO_VERSION, controller.getVersion());
+ assertEquals(DroolsControllerConstants.NO_GROUP_ID, controller.getGroupId());
+ assertEquals(DroolsControllerConstants.NO_ARTIFACT_ID, controller.getArtifactId());
+ assertEquals(DroolsControllerConstants.NO_VERSION, controller.getVersion());
}
@Test
public void inventory() {
- List<DroolsController> controllers = DroolsController.factory.inventory();
+ List<DroolsController> controllers = DroolsControllerConstants.getFactory().inventory();
assertNotNull(controllers);
-
+
for (int i = 0; i < controllers.size(); i++) {
if (!isNullController(controllers.get(i)) && !isActualController(controllers.get(i))) {
fail("drools controller is not a null controller");
@@ -83,31 +83,31 @@ public class DroolsControllerFactoryTest {
if (droolsController == null) {
return false;
}
-
- if (!DroolsController.NO_GROUP_ID.equals(droolsController.getGroupId())) {
+
+ if (!DroolsControllerConstants.NO_GROUP_ID.equals(droolsController.getGroupId())) {
return false;
}
-
- if (!DroolsController.NO_ARTIFACT_ID.equals(droolsController.getArtifactId())) {
+
+ if (!DroolsControllerConstants.NO_ARTIFACT_ID.equals(droolsController.getArtifactId())) {
return false;
}
- return DroolsController.NO_VERSION.equals(droolsController.getVersion());
+ return DroolsControllerConstants.NO_VERSION.equals(droolsController.getVersion());
}
private boolean isActualController(DroolsController droolsController) {
if (droolsController == null) {
return false;
}
-
+
if (!"org.onap.policy.drools.test".equals(droolsController.getGroupId())) {
return false;
}
-
+
if (!"protocolcoder".equals(droolsController.getArtifactId())) {
return false;
}
-
+
return droolsController.getVersion() != null && droolsController.getVersion().substring(0, 1).matches("[0-9]");
}
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
index 20b79bde..7187ad1b 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
@@ -58,7 +58,9 @@ import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.drools.core.PolicyContainer;
import org.onap.policy.drools.core.PolicySession;
import org.onap.policy.drools.features.DroolsControllerFeatureApi;
+import org.onap.policy.drools.features.DroolsControllerFeatureApiConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
+import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolParams;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
@@ -887,8 +889,8 @@ public class MavenDroolsController2Test {
}
};
- assertSame(EventProtocolCoder.manager, drools.getCoderManager());
- assertSame(DroolsControllerFeatureApi.providers, drools.getDroolsProviders());
+ assertSame(EventProtocolCoderConstants.getManager(), drools.getCoderManager());
+ assertSame(DroolsControllerFeatureApiConstants.getProviders(), drools.getDroolsProviders());
}
@Test
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
index 4b0c438f..8515582d 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
@@ -24,6 +24,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.drools.controller.DroolsController;
+import org.onap.policy.drools.controller.DroolsControllerConstants;
public class NullDroolsControllerTest {
@@ -56,17 +57,17 @@ public class NullDroolsControllerTest {
@Test
public void getGroupId() {
- Assert.assertEquals(new NullDroolsController().getGroupId(), DroolsController.NO_GROUP_ID);
+ Assert.assertEquals(new NullDroolsController().getGroupId(), DroolsControllerConstants.NO_GROUP_ID);
}
@Test
public void getArtifactId() {
- Assert.assertEquals(new NullDroolsController().getArtifactId(), DroolsController.NO_ARTIFACT_ID);
+ Assert.assertEquals(new NullDroolsController().getArtifactId(), DroolsControllerConstants.NO_ARTIFACT_ID);
}
@Test
public void getVersion() {
- Assert.assertEquals(new NullDroolsController().getVersion(), DroolsController.NO_VERSION);
+ Assert.assertEquals(new NullDroolsController().getVersion(), DroolsControllerConstants.NO_VERSION);
}
@Test
diff --git a/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java b/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
index b2771944..8cd4ee6e 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
@@ -37,7 +37,7 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import org.onap.policy.drools.properties.DroolsProperties;
+import org.onap.policy.drools.properties.DroolsPropertyConstants;
/**
* (File) System Persistence Tests.
@@ -103,24 +103,24 @@ public class SystemPersistenceTest {
@Test
public void test1NonDefaultConfigDir() {
- SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
- assertEquals(OTHER_CONFIG_DIR, SystemPersistence.manager.getConfigurationPath().toString());
+ SystemPersistenceConstants.getManager().setConfigurationDir(OTHER_CONFIG_DIR);
+ assertEquals(OTHER_CONFIG_DIR, SystemPersistenceConstants.getManager().getConfigurationPath().toString());
- SystemPersistence.manager.setConfigurationDir(null);
- assertEquals(SystemPersistence.DEFAULT_CONFIGURATION_DIR,
- SystemPersistence.manager.getConfigurationPath().toString());
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
+ assertEquals(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR,
+ SystemPersistenceConstants.getManager().getConfigurationPath().toString());
- SystemPersistence.manager.setConfigurationDir();
- assertEquals(SystemPersistence.DEFAULT_CONFIGURATION_DIR,
- SystemPersistence.manager.getConfigurationPath().toString());
+ SystemPersistenceConstants.getManager().setConfigurationDir();
+ assertEquals(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR,
+ SystemPersistenceConstants.getManager().getConfigurationPath().toString());
}
@Test
public void test2Engine_Environment_System() throws IOException {
- SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
+ SystemPersistenceConstants.getManager().setConfigurationDir(OTHER_CONFIG_DIR);
final Path policyEnginePropsPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(),
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
FileSystemPersistence.PROPERTIES_FILE_ENGINE);
final Properties engineProps = new Properties();
@@ -132,113 +132,114 @@ public class SystemPersistenceTest {
}
}
- assertEquals(engineProps, SystemPersistence.manager.getEngineProperties());
+ assertEquals(engineProps, SystemPersistenceConstants.getManager().getEngineProperties());
final Path environmentPropertiesPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), ENV_PROPS_FILE);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), ENV_PROPS_FILE);
if (Files.notExists(environmentPropertiesPath)) {
Files.createFile(environmentPropertiesPath);
}
- assertNotNull(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS));
- assertTrue(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS).isEmpty());
- assertEquals(1, SystemPersistence.manager.getEnvironmentProperties().size());
- assertEquals(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS),
- SystemPersistence.manager.getEnvironmentProperties().get(0));
+ assertNotNull(SystemPersistenceConstants.getManager().getEnvironmentProperties(ENV_PROPS));
+ assertTrue(SystemPersistenceConstants.getManager().getEnvironmentProperties(ENV_PROPS).isEmpty());
+ assertEquals(1, SystemPersistenceConstants.getManager().getEnvironmentProperties().size());
+ assertEquals(SystemPersistenceConstants.getManager().getEnvironmentProperties(ENV_PROPS),
+ SystemPersistenceConstants.getManager().getEnvironmentProperties().get(0));
Path systemPropertiesPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), SYSTEM_PROPS_FILE);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), SYSTEM_PROPS_FILE);
if (Files.notExists(systemPropertiesPath)) {
Files.createFile(systemPropertiesPath);
}
- assertNotNull(SystemPersistence.manager.getSystemProperties(SYSTEM_PROPS));
- assertTrue(SystemPersistence.manager.getSystemProperties(SYSTEM_PROPS).isEmpty());
- assertEquals(1, SystemPersistence.manager.getSystemProperties().size());
- assertEquals(SystemPersistence.manager.getSystemProperties(SYSTEM_PROPS),
- SystemPersistence.manager.getSystemProperties().get(0));
+ assertNotNull(SystemPersistenceConstants.getManager().getSystemProperties(SYSTEM_PROPS));
+ assertTrue(SystemPersistenceConstants.getManager().getSystemProperties(SYSTEM_PROPS).isEmpty());
+ assertEquals(1, SystemPersistenceConstants.getManager().getSystemProperties().size());
+ assertEquals(SystemPersistenceConstants.getManager().getSystemProperties(SYSTEM_PROPS),
+ SystemPersistenceConstants.getManager().getSystemProperties().get(0));
}
@Test
public void test3Topic() {
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
Path topicPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_TOPIC_FILE);
+ .get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), TEST_TOPIC_FILE);
Path topicBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_TOPIC_FILE_BAK);
+ .get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), TEST_TOPIC_FILE_BAK);
assertTrue(Files.notExists(topicPath));
assertTrue(Files.notExists(topicBakPath));
- SystemPersistence.manager.storeTopic(TEST_TOPIC_NAME, new Properties());
+ SystemPersistenceConstants.getManager().storeTopic(TEST_TOPIC_NAME, new Properties());
assertTrue(Files.exists(topicPath));
- Properties properties = SystemPersistence.manager.getTopicProperties(TEST_TOPIC_NAME);
+ Properties properties = SystemPersistenceConstants.getManager().getTopicProperties(TEST_TOPIC_NAME);
assertNotNull(properties);
- List<Properties> topicPropsList = SystemPersistence.manager.getTopicProperties();
+ List<Properties> topicPropsList = SystemPersistenceConstants.getManager().getTopicProperties();
assertEquals(1, topicPropsList.size());
- SystemPersistence.manager.backupTopic(TEST_TOPIC_NAME);
+ SystemPersistenceConstants.getManager().backupTopic(TEST_TOPIC_NAME);
assertTrue(Files.exists(topicBakPath));
- SystemPersistence.manager.deleteTopic(TEST_TOPIC_NAME);
+ SystemPersistenceConstants.getManager().deleteTopic(TEST_TOPIC_NAME);
assertTrue(Files.notExists(topicPath));
}
@Test
public void test4Controller() {
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
Path controllerPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+ .get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
- Path controllerBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ Path controllerBakPath = Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
+ TEST_CONTROLLER_FILE_BAK);
assertTrue(Files.notExists(controllerPath));
assertTrue(Files.notExists(controllerBakPath));
- SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, new Properties());
+ SystemPersistenceConstants.getManager().storeController(TEST_CONTROLLER_NAME, new Properties());
assertTrue(Files.exists(controllerPath));
- Properties properties = SystemPersistence.manager.getControllerProperties(TEST_CONTROLLER_NAME);
+ Properties properties = SystemPersistenceConstants.getManager().getControllerProperties(TEST_CONTROLLER_NAME);
assertNotNull(properties);
- List<Properties> controllerPropsList = SystemPersistence.manager.getControllerProperties();
+ List<Properties> controllerPropsList = SystemPersistenceConstants.getManager().getControllerProperties();
assertEquals(1, controllerPropsList.size());
assertEquals(TEST_CONTROLLER_NAME, controllerPropsList
- .get(0).getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME));
+ .get(0).getProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME));
- SystemPersistence.manager.backupController(TEST_CONTROLLER_NAME);
+ SystemPersistenceConstants.getManager().backupController(TEST_CONTROLLER_NAME);
assertTrue(Files.exists(controllerBakPath));
- SystemPersistence.manager.deleteController(TEST_CONTROLLER_NAME);
+ SystemPersistenceConstants.getManager().deleteController(TEST_CONTROLLER_NAME);
assertTrue(Files.notExists(controllerPath));
}
/**
* Clean up the working directories.
- *
+ *
* @throws IOException throws IO exception
*/
private static void cleanUpWorkingDirs() throws IOException {
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
- for (Properties properties : SystemPersistence.manager.getControllerProperties()) {
- SystemPersistence.manager.deleteController(properties
- .getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME));
+ for (Properties properties : SystemPersistenceConstants.getManager().getControllerProperties()) {
+ SystemPersistenceConstants.getManager().deleteController(properties
+ .getProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME));
}
- SystemPersistence.manager.deleteTopic(TEST_TOPIC_NAME);
+ SystemPersistenceConstants.getManager().deleteTopic(TEST_TOPIC_NAME);
- final Path testControllerBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ final Path testControllerBakPath =
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
+ TEST_CONTROLLER_FILE_BAK);
final Path testTopicBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_TOPIC_FILE_BAK);
+ .get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), TEST_TOPIC_FILE_BAK);
final Path policyEnginePath = Paths.get(OTHER_CONFIG_DIR, FileSystemPersistence.PROPERTIES_FILE_ENGINE);
final Path environmentPath = Paths.get(OTHER_CONFIG_DIR, ENV_PROPS_FILE);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
index db90bea7..6f34c2c1 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
@@ -83,18 +83,18 @@ public class EventProtocolCoderTest {
TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
- EventProtocolCoder.manager.addEncoder(
+ EventProtocolCoderConstants.getManager().addEncoder(
EventProtocolParams.builder().groupId(ENCODER_GROUP).artifactId(ENCODER_ARTIFACT)
.topic(NOOP_TOPIC).eventClass(DroolsConfiguration.class.getName())
.protocolFilter(new JsonProtocolFilter()).customGsonCoder(null)
.modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()));
- final String json = EventProtocolCoder.manager.encode(NOOP_TOPIC,
+ final String json = EventProtocolCoderConstants.getManager().encode(NOOP_TOPIC,
new DroolsConfiguration(ENCODER_GROUP, ENCODER_ARTIFACT, ENCODER_VERSION));
assertTrue(json.contains(ENCODER_GROUP));
assertTrue(json.contains(ENCODER_ARTIFACT));
- EventProtocolCoder.manager.removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
+ EventProtocolCoderConstants.getManager().removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
}
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
index 64661845..bd595725 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
@@ -34,9 +34,9 @@ import org.kie.api.builder.ReleaseId;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
-import org.onap.policy.drools.controller.DroolsController;
+import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.controller.internal.MavenDroolsControllerTest;
-import org.onap.policy.drools.properties.DroolsProperties;
+import org.onap.policy.drools.properties.DroolsPropertyConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomGsonCoder;
import org.onap.policy.drools.util.KieUtils;
@@ -234,13 +234,13 @@ public class ProtocolCoderToolsetTest {
final List<? extends TopicSink> noopTopics = TopicEndpointManager.getManager().addTopicSinks(sinkConfig);
Properties droolsControllerConfig = new Properties();
- droolsControllerConfig.put(DroolsProperties.RULES_GROUPID, releaseId.getGroupId());
- droolsControllerConfig.put(DroolsProperties.RULES_ARTIFACTID, releaseId.getArtifactId());
- droolsControllerConfig.put(DroolsProperties.RULES_VERSION, releaseId.getVersion());
+ droolsControllerConfig.put(DroolsPropertyConstants.RULES_GROUPID, releaseId.getGroupId());
+ droolsControllerConfig.put(DroolsPropertyConstants.RULES_ARTIFACTID, releaseId.getArtifactId());
+ droolsControllerConfig.put(DroolsPropertyConstants.RULES_VERSION, releaseId.getVersion());
droolsControllerConfig.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS + "." + JUNIT_PROTOCOL_CODER_TOPIC
+ PolicyEndPointProperties.PROPERTY_TOPIC_EVENTS_SUFFIX, Triple.class.getName());
- DroolsController.factory.build(droolsControllerConfig, null, noopTopics);
+ DroolsControllerConstants.getFactory().build(droolsControllerConfig, null, noopTopics);
}
private JsonProtocolFilter createFilterSet() {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
index 88712a3b..173c1738 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
@@ -48,9 +48,9 @@ import org.junit.runners.MethodSorters;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+import org.onap.policy.drools.system.PolicyControllerConstants;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -107,23 +107,23 @@ public class RestManagerTest {
public static void setUp() throws IOException, InterruptedException {
cleanUpWorkingDirs();
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
/* override default port */
- final Properties engineProps = PolicyEngine.manager.defaultTelemetryConfig();
+ final Properties engineProps = PolicyEngineConstants.getManager().defaultTelemetryConfig();
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "" + DEFAULT_TELEMETRY_PORT);
+ + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "" + DEFAULT_TELEMETRY_PORT);
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
+ PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX,
TestAafTelemetryAuthFilter.class.getName());
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
+ PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
TELEMETRY_USER);
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
+ PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX,
TELEMETRY_PASSWORD);
@@ -141,11 +141,11 @@ public class RestManagerTest {
engineProps.put(DMAAP_SINK_MECHID_KEY, DMAAP_MECHID);
engineProps.put(DMAAP_SINK_PASSWD_KEY, DMAAP_PASSWD);
- PolicyEngine.manager.configure(engineProps);
- PolicyEngine.manager.start();
+ PolicyEngineConstants.getManager().configure(engineProps);
+ PolicyEngineConstants.getManager().start();
Properties controllerProps = new Properties();
- PolicyEngine.manager.createPolicyController(FOO_CONTROLLER, controllerProps);
+ PolicyEngineConstants.getManager().createPolicyController(FOO_CONTROLLER, controllerProps);
// client = HttpClients.createDefault();
CredentialsProvider provider = new BasicCredentialsProvider();
@@ -173,9 +173,9 @@ public class RestManagerTest {
@AfterClass
public static void tearDown() throws IOException, InterruptedException {
/* Shutdown managed resources */
- PolicyController.factory.shutdown();
+ PolicyControllerConstants.getFactory().shutdown();
TopicEndpointManager.getManager().shutdown();
- PolicyEngine.manager.stop();
+ PolicyEngineConstants.getManager().stop();
Thread.sleep(10000L);
client.close();
cleanUpWorkingDirs();
@@ -441,7 +441,7 @@ public class RestManagerTest {
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- PolicyEngine.manager.setEnvironmentProperty("foo", "bar");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("foo", "bar");
httpGet = new HttpGet(HOST_URL + "/engine/environment/foo");
response = client.execute(httpGet);
String responseBody = this.getResponseBody(response);
@@ -962,10 +962,11 @@ public class RestManagerTest {
}
private static void cleanUpWorkingDirs() throws IOException {
- final Path testControllerPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), FOO_CONTROLLER_FILE);
+ final Path testControllerPath = Paths.get(
+ SystemPersistenceConstants.getManager().getConfigurationPath().toString(), FOO_CONTROLLER_FILE);
final Path testControllerBakPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), FOO_CONTROLLER_FILE_BAK);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
+ FOO_CONTROLLER_FILE_BAK);
Files.deleteIfExists(testControllerPath);
Files.deleteIfExists(testControllerBakPath);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
index c5fa3980..e9f0b48a 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
@@ -56,7 +56,7 @@ import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.features.PolicyControllerFeatureApi;
import org.onap.policy.drools.features.PolicyEngineFeatureApi;
import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.DroolsProperties;
+import org.onap.policy.drools.properties.DroolsPropertyConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
@@ -492,19 +492,19 @@ public class PolicyEngineManagerTest {
// empty name in properties - same result
setUp();
- properties.setProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME, "");
+ properties.setProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, "");
assertEquals(controller, mgr.createPolicyController(MY_NAME, properties));
verify(contProv1).beforeCreate(MY_NAME, properties);
// matching name in properties - same result
setUp();
- properties.setProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME, MY_NAME);
+ properties.setProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, MY_NAME);
assertEquals(controller, mgr.createPolicyController(MY_NAME, properties));
verify(contProv1).beforeCreate(MY_NAME, properties);
// mismatching name in properties - nothing should happen besides exception
setUp();
- properties.setProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME, "mistmatched-name");
+ properties.setProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, "mistmatched-name");
assertThatIllegalStateException().isThrownBy(() -> mgr.createPolicyController(MY_NAME, properties));
verify(contProv1, never()).beforeCreate(MY_NAME, properties);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
index d47c2183..df1f6cca 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
@@ -39,9 +39,9 @@ import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.gson.GsonTestUtils;
-import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.DroolsProperties;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+import org.onap.policy.drools.properties.DroolsPropertyConstants;
+import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolParams;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
@@ -106,7 +106,8 @@ public class PolicyEngineTest {
*/
protected static void cleanUpWorkingDir() {
final Path testControllerPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
+ TEST_CONTROLLER_FILE);
try {
Files.deleteIfExists(testControllerPath);
} catch (final Exception e) {
@@ -114,7 +115,8 @@ public class PolicyEngineTest {
}
final Path testControllerBakPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
+ TEST_CONTROLLER_FILE_BAK);
try {
Files.deleteIfExists(testControllerBakPath);
} catch (final Exception e) {
@@ -136,7 +138,7 @@ public class PolicyEngineTest {
cleanUpWorkingDir();
/* ensure presence of config directory */
- final Path configDir = Paths.get(SystemPersistence.DEFAULT_CONFIGURATION_DIR);
+ final Path configDir = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
if (Files.notExists(configDir)) {
Files.createDirectories(configDir);
}
@@ -152,56 +154,57 @@ public class PolicyEngineTest {
public void test100Configure() {
logger.info("enter");
- final Properties engineProps = PolicyEngine.manager.defaultTelemetryConfig();
+ final Properties engineProps = PolicyEngineConstants.getManager().defaultTelemetryConfig();
/* override default port */
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
+ PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "" + DEFAULT_TELEMETRY_PORT);
- assertFalse(PolicyEngine.manager.isAlive());
- PolicyEngine.manager.configure(engineProps);
- assertFalse(PolicyEngine.manager.isAlive());
+ assertFalse(PolicyEngineConstants.getManager().isAlive());
+ PolicyEngineConstants.getManager().configure(engineProps);
+ assertFalse(PolicyEngineConstants.getManager().isAlive());
- logger.info("engine {} has configuration {}", PolicyEngine.manager, engineProps);
+ logger.info("engine {} has configuration {}", PolicyEngineConstants.getManager(), engineProps);
- gson.compareGson(PolicyEngine.manager, new File(PolicyEngineTest.class.getSimpleName() + "Config.json"));
+ gson.compareGson(PolicyEngineConstants.getManager(),
+ new File(PolicyEngineTest.class.getSimpleName() + "Config.json"));
}
@Test
public void test200Start() {
logger.info("enter");
- PolicyEngine.manager.start();
+ PolicyEngineConstants.getManager().start();
- assertTrue(PolicyEngine.manager.isAlive());
- assertFalse(PolicyEngine.manager.isLocked());
- assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
- assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
+ assertTrue(PolicyEngineConstants.getManager().isAlive());
+ assertFalse(PolicyEngineConstants.getManager().isLocked());
+ assertFalse(PolicyEngineConstants.getManager().getHttpServers().isEmpty());
+ assertTrue(PolicyEngineConstants.getManager().getHttpServers().get(0).isAlive());
}
@Test
public void test300Lock() {
logger.info("enter");
- PolicyEngine.manager.lock();
+ PolicyEngineConstants.getManager().lock();
- assertTrue(PolicyEngine.manager.isAlive());
- assertTrue(PolicyEngine.manager.isLocked());
- assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
- assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
+ assertTrue(PolicyEngineConstants.getManager().isAlive());
+ assertTrue(PolicyEngineConstants.getManager().isLocked());
+ assertFalse(PolicyEngineConstants.getManager().getHttpServers().isEmpty());
+ assertTrue(PolicyEngineConstants.getManager().getHttpServers().get(0).isAlive());
}
@Test
public void test301Unlock() {
logger.info("enter");
- PolicyEngine.manager.unlock();
+ PolicyEngineConstants.getManager().unlock();
- assertTrue(PolicyEngine.manager.isAlive());
- assertFalse(PolicyEngine.manager.isLocked());
- assertFalse(PolicyEngine.manager.getHttpServers().isEmpty());
- assertTrue(PolicyEngine.manager.getHttpServers().get(0).isAlive());
+ assertTrue(PolicyEngineConstants.getManager().isAlive());
+ assertFalse(PolicyEngineConstants.getManager().isLocked());
+ assertFalse(PolicyEngineConstants.getManager().getHttpServers().isEmpty());
+ assertTrue(PolicyEngineConstants.getManager().getHttpServers().get(0).isAlive());
}
@Test
@@ -211,20 +214,20 @@ public class PolicyEngineTest {
TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties).get(0).start();
- EventProtocolCoder.manager.addEncoder(
+ EventProtocolCoderConstants.getManager().addEncoder(
EventProtocolParams.builder().groupId(ENCODER_GROUP).artifactId(ENCODER_ARTIFACT)
.topic(NOOP_TOPIC).eventClass(DroolsConfiguration.class.getName())
.protocolFilter(new JsonProtocolFilter()).customGsonCoder(null)
.modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()));
- assertTrue(PolicyEngine.manager.deliver(NOOP_TOPIC,
+ assertTrue(PolicyEngineConstants.getManager().deliver(NOOP_TOPIC,
new DroolsConfiguration(ENCODER_GROUP, ENCODER_ARTIFACT, ENCODER_VERSION)));
final TopicSink sink = NoopTopicFactories.getSinkFactory().get(NOOP_TOPIC);
assertTrue(sink.getRecentEvents()[0].contains(ENCODER_GROUP));
assertTrue(sink.getRecentEvents()[0].contains(ENCODER_ARTIFACT));
- EventProtocolCoder.manager.removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
+ EventProtocolCoderConstants.getManager().removeEncoders(ENCODER_GROUP, ENCODER_ARTIFACT, NOOP_TOPIC);
}
@Test
@@ -232,19 +235,20 @@ public class PolicyEngineTest {
logger.info("enter");
final Properties controllerProperties = new Properties();
- controllerProperties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
- PolicyEngine.manager.createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
+ controllerProperties.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
+ PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
- assertTrue(PolicyController.factory.inventory().size() == 1);
+ assertTrue(PolicyControllerConstants.getFactory().inventory().size() == 1);
- gson.compareGson(PolicyEngine.manager, new File(PolicyEngineTest.class.getSimpleName() + "Add.json"));
+ gson.compareGson(PolicyEngineConstants.getManager(),
+ new File(PolicyEngineTest.class.getSimpleName() + "Add.json"));
}
@Test
public void test401ControllerVerify() {
logger.info("enter");
- final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
+ final PolicyController testController = PolicyControllerConstants.getFactory().get(TEST_CONTROLLER_NAME);
assertFalse(testController.isAlive());
assertFalse(testController.isLocked());
@@ -259,34 +263,34 @@ public class PolicyEngineTest {
public void test500Deactivate() throws Exception {
logger.info("enter");
- PolicyEngine.manager.deactivate();
+ PolicyEngineConstants.getManager().deactivate();
- final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
+ final PolicyController testController = PolicyControllerConstants.getFactory().get(TEST_CONTROLLER_NAME);
assertFalse(testController.isAlive());
assertTrue(testController.isLocked());
- assertTrue(PolicyEngine.manager.isLocked());
- assertTrue(PolicyEngine.manager.isAlive());
+ assertTrue(PolicyEngineConstants.getManager().isLocked());
+ assertTrue(PolicyEngineConstants.getManager().isAlive());
}
@Test
public void test501Activate() throws Exception {
logger.info("enter");
- PolicyEngine.manager.activate();
+ PolicyEngineConstants.getManager().activate();
- final PolicyController testController = PolicyController.factory.get(TEST_CONTROLLER_NAME);
+ final PolicyController testController = PolicyControllerConstants.getFactory().get(TEST_CONTROLLER_NAME);
assertTrue(testController.isAlive());
assertFalse(testController.isLocked());
- assertFalse(PolicyEngine.manager.isLocked());
- assertTrue(PolicyEngine.manager.isAlive());
+ assertFalse(PolicyEngineConstants.getManager().isLocked());
+ assertTrue(PolicyEngineConstants.getManager().isAlive());
}
@Test
public void test900ControllerRemove() throws Exception {
logger.info("enter");
- PolicyEngine.manager.removePolicyController(TEST_CONTROLLER_NAME);
- assertTrue(PolicyController.factory.inventory().isEmpty());
+ PolicyEngineConstants.getManager().removePolicyController(TEST_CONTROLLER_NAME);
+ assertTrue(PolicyControllerConstants.getFactory().inventory().isEmpty());
}
@Test
@@ -294,11 +298,11 @@ public class PolicyEngineTest {
logger.info("enter");
/* Shutdown managed resources */
- PolicyController.factory.shutdown();
+ PolicyControllerConstants.getFactory().shutdown();
TopicEndpointManager.getManager().shutdown();
- PolicyEngine.manager.stop();
+ PolicyEngineConstants.getManager().stop();
Thread.sleep(10000L);
- assertFalse(PolicyEngine.manager.isAlive());
+ assertFalse(PolicyEngineConstants.getManager().isAlive());
}
}