aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/test/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-09-13 19:35:18 -0400
committerPamela Dragosh <pdragosh@research.att.com>2018-09-13 20:00:37 -0400
commitc733c08b7201ffdee81c7dab2ed50a1ce8fd5bbb (patch)
treef2a55827d08f47d86ba1a838a1cd5e129731935e /policy-management/src/test/java
parent69c83ef510fe7e1efda5dd75e7beaa862250ef05 (diff)
Fix checkstyle in policy-management
The submodule policy-management checkstyle fixes. There may be one or two sonar fixes in there. Issue-ID: POLICY-882 Change-Id: I9cb43c573c6811dd058943650ba1ea5f6dc880aa Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'policy-management/src/test/java')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java16
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java8
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java240
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java12
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java16
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java19
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java15
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java104
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java434
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java28
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java29
11 files changed, 486 insertions, 435 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 4fb4d92d..47baa07e 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
@@ -37,7 +37,7 @@ public class DroolsControllerFactoryTest {
DroolsController droolsController = DroolsController.factory.build(droolsProps, null, null);
if (!isNullController(droolsController)) {
- fail("drools controller is not a null controller");
+ fail("drools controller is not a null controller");
}
}
@@ -60,7 +60,7 @@ public class DroolsControllerFactoryTest {
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");
+ fail("drools controller is not a null controller");
}
}
}
@@ -81,15 +81,15 @@ public class DroolsControllerFactoryTest {
private boolean isNullController(DroolsController droolsController) {
if (droolsController == null) {
- return false;
+ return false;
}
if (!DroolsController.NO_GROUP_ID.equals(droolsController.getGroupId())) {
- return false;
+ return false;
}
if (!DroolsController.NO_ARTIFACT_ID.equals(droolsController.getArtifactId())) {
- return false;
+ return false;
}
return DroolsController.NO_VERSION.equals(droolsController.getVersion());
@@ -97,15 +97,15 @@ public class DroolsControllerFactoryTest {
private boolean isActualController(DroolsController droolsController) {
if (droolsController == null) {
- return false;
+ return false;
}
if (!"org.onap.policy.drools.test".equals(droolsController.getGroupId())) {
- return false;
+ return false;
}
if (!"protocolcoder".equals(droolsController.getArtifactId())) {
- return false;
+ 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/MavenDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
index a41c3c1a..5df6eb8d 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
@@ -40,6 +40,11 @@ public class MavenDroolsControllerTest {
private static volatile ReleaseId releaseId;
+ /**
+ * Set up.
+ *
+ * @throws IOException throws an IO exception
+ */
@BeforeClass
public static void setUp() throws IOException {
releaseId =
@@ -74,8 +79,9 @@ public class MavenDroolsControllerTest {
}
private DroolsController createDroolsController(long courtesyStartTimeMs) throws InterruptedException {
- if (releaseId == null)
+ if (releaseId == null) {
throw new IllegalStateException("no prereq artifact installed in maven repository");
+ }
DroolsController controller = new MavenDroolsController(releaseId.getGroupId(),
releaseId.getArtifactId(), releaseId.getVersion(), null, null);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java b/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java
index 9b2e6161..1e51cfec 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.persistence.test;
import static org.junit.Assert.assertEquals;
@@ -43,145 +44,150 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * (File) System Persistence Tests
+ * (File) System Persistence Tests.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SystemPersistenceTest {
- /**
- * logger
- */
- private static final Logger logger = LoggerFactory.getLogger(SystemPersistenceTest.class);
-
- /**
- * sample configuration dir
- */
- public static final String OTHER_CONFIG_DIR = "tmp";
-
- /**
- * Test JUnit Controller Name
- */
- public static final String TEST_CONTROLLER_NAME = "foo";
-
- /**
- * Test JUnit Controller Name
- */
- public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
-
- /**
- * Test JUnit Controller Name Backup
- */
- public static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
-
- /**
- * Test JUnit Environment/Engine properties
- */
- private static final String ENV_PROPS = "envProps";
- private static final String ENV_PROPS_FILE = ENV_PROPS + ".environment";
- private static final String POLICY_ENGINE_PROPERTIES_FILE = "policy-engine.properties";
-
- @BeforeClass
- public static void setUp() throws IOException {
- cleanUpWorkingDirs();
- }
-
- @AfterClass
- public static void tearDown() throws IOException {
- cleanUpWorkingDirs();
- }
-
- @Test
- public void test1NonDefaultConfigDir() throws IOException {
- logger.info("enter");
-
- SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
- assertTrue(
- SystemPersistence.manager.getConfigurationPath().toString().equals(OTHER_CONFIG_DIR));
-
- SystemPersistence.manager.setConfigurationDir(null);
- assertTrue(SystemPersistence.manager.getConfigurationPath().toString()
- .equals(SystemPersistence.DEFAULT_CONFIGURATION_DIR));
- }
-
- @Test
- public void test2Engine() throws IOException {
- logger.info("enter");
-
- SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
-
- final Path policyEnginePropsPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(),
- FileSystemPersistence.PROPERTIES_FILE_ENGINE);
-
- final Properties engineProps = new Properties();
- engineProps.setProperty("foo", "bar");
- engineProps.setProperty("fiz", "buz");
- if (Files.notExists(policyEnginePropsPath)) {
- try (final OutputStream fout = new FileOutputStream(policyEnginePropsPath.toFile())) {
- engineProps.store(fout, "");
- }
+ /**
+ * logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(SystemPersistenceTest.class);
+
+ /**
+ * sample configuration dir.
+ */
+ public static final String OTHER_CONFIG_DIR = "tmp";
+
+ /**
+ * Test JUnit Controller Name.
+ */
+ public static final String TEST_CONTROLLER_NAME = "foo";
+
+ /**
+ * Test JUnit Controller Name.
+ */
+ public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
+
+ /**
+ * Test JUnit Controller Name Backup.
+ */
+ public static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
+
+ /**
+ * Test JUnit Environment/Engine properties.
+ */
+ private static final String ENV_PROPS = "envProps";
+ private static final String ENV_PROPS_FILE = ENV_PROPS + ".environment";
+ private static final String POLICY_ENGINE_PROPERTIES_FILE = "policy-engine.properties";
+
+ @BeforeClass
+ public static void setUp() throws IOException {
+ cleanUpWorkingDirs();
+ }
+
+ @AfterClass
+ public static void tearDown() throws IOException {
+ cleanUpWorkingDirs();
}
- assertEquals(SystemPersistence.manager.getEngineProperties(), engineProps);
+ @Test
+ public void test1NonDefaultConfigDir() throws IOException {
+ logger.info("enter");
+
+ SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
+ assertTrue(
+ SystemPersistence.manager.getConfigurationPath().toString().equals(OTHER_CONFIG_DIR));
- final Path environmentPropertiesPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), ENV_PROPS_FILE);
- if (Files.notExists(environmentPropertiesPath)) {
- Files.createFile(environmentPropertiesPath);
+ SystemPersistence.manager.setConfigurationDir(null);
+ assertTrue(SystemPersistence.manager.getConfigurationPath().toString()
+ .equals(SystemPersistence.DEFAULT_CONFIGURATION_DIR));
}
- assertTrue(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS).isEmpty());
- assertTrue(SystemPersistence.manager.getEnvironmentProperties().size() == 1);
- }
- @Test
- public void test3PersistConfiguration() {
- logger.info("enter");
+ @Test
+ public void test2Engine() throws IOException {
+ logger.info("enter");
+
+ SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
+
+ final Path policyEnginePropsPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(),
+ FileSystemPersistence.PROPERTIES_FILE_ENGINE);
+
+ final Properties engineProps = new Properties();
+ engineProps.setProperty("foo", "bar");
+ engineProps.setProperty("fiz", "buz");
+ if (Files.notExists(policyEnginePropsPath)) {
+ try (final OutputStream fout = new FileOutputStream(policyEnginePropsPath.toFile())) {
+ engineProps.store(fout, "");
+ }
+ }
+
+ assertEquals(SystemPersistence.manager.getEngineProperties(), engineProps);
+
+ final Path environmentPropertiesPath =
+ Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), ENV_PROPS_FILE);
+ if (Files.notExists(environmentPropertiesPath)) {
+ Files.createFile(environmentPropertiesPath);
+ }
+ assertTrue(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS).isEmpty());
+ assertTrue(SystemPersistence.manager.getEnvironmentProperties().size() == 1);
+ }
+
+ @Test
+ public void test3PersistConfiguration() {
+ logger.info("enter");
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistence.manager.setConfigurationDir(null);
- final Path controllerPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+ final Path controllerPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
- final Path controllerBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ final Path controllerBakPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
- assertTrue(Files.notExists(controllerPath));
- assertTrue(Files.notExists(controllerBakPath));
+ assertTrue(Files.notExists(controllerPath));
+ assertTrue(Files.notExists(controllerBakPath));
- Properties properties = new Properties();
- properties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
- SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, properties);
+ Properties properties = new Properties();
+ properties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
+ SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, properties);
- assertTrue(Files.exists(controllerPath));
+ assertTrue(Files.exists(controllerPath));
- properties = SystemPersistence.manager.getControllerProperties(TEST_CONTROLLER_NAME);
- assertTrue(properties != null);
+ properties = SystemPersistence.manager.getControllerProperties(TEST_CONTROLLER_NAME);
+ assertTrue(properties != null);
- SystemPersistence.manager.backupController(TEST_CONTROLLER_NAME);
- assertTrue(Files.exists(controllerBakPath));
+ SystemPersistence.manager.backupController(TEST_CONTROLLER_NAME);
+ assertTrue(Files.exists(controllerBakPath));
- assertFalse(SystemPersistence.manager.getControllerProperties().isEmpty());
+ assertFalse(SystemPersistence.manager.getControllerProperties().isEmpty());
- SystemPersistence.manager.deleteController(TEST_CONTROLLER_NAME);
- assertTrue(Files.notExists(controllerPath));
- }
+ SystemPersistence.manager.deleteController(TEST_CONTROLLER_NAME);
+ assertTrue(Files.notExists(controllerPath));
+ }
- public static void cleanUpWorkingDirs() throws IOException {
+ /**
+ * Clean up the working directories.
+ *
+ * @throws IOException throws IO exception
+ */
+ public static void cleanUpWorkingDirs() throws IOException {
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistence.manager.setConfigurationDir(null);
- final Path testControllerPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
- final Path testControllerBakPath = Paths
- .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ final Path testControllerPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+ final Path testControllerBakPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
- final Path policyEnginePath = Paths.get(OTHER_CONFIG_DIR, POLICY_ENGINE_PROPERTIES_FILE);
- final Path environmentPath = Paths.get(OTHER_CONFIG_DIR, ENV_PROPS_FILE);
+ final Path policyEnginePath = Paths.get(OTHER_CONFIG_DIR, POLICY_ENGINE_PROPERTIES_FILE);
+ final Path environmentPath = Paths.get(OTHER_CONFIG_DIR, ENV_PROPS_FILE);
- Files.deleteIfExists(testControllerPath);
- Files.deleteIfExists(testControllerBakPath);
- Files.deleteIfExists(policyEnginePath);
- Files.deleteIfExists(environmentPath);
- }
+ Files.deleteIfExists(testControllerPath);
+ Files.deleteIfExists(testControllerBakPath);
+ Files.deleteIfExists(policyEnginePath);
+ Files.deleteIfExists(environmentPath);
+ }
}
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 b42c64b1..d6330cd5 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
@@ -31,32 +31,32 @@ import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
/**
- * Tests Coders
+ * Tests Coders.
*/
public class EventProtocolCoderTest {
/**
- * Coder Group
+ * Coder Group.
*/
private static final String ENCODER_GROUP = "foo";
/**
- * Coder Artifact
+ * Coder Artifact.
*/
private static final String ENCODER_ARTIFACT = "bar";
/**
- * Coder Version
+ * Coder Version.
*/
private static final String ENCODER_VERSION = null;
/**
- * noop topic
+ * noop topic.
*/
private static final String NOOP_TOPIC = "JUNIT";
/**
- * Event Test Class
+ * Event Test Class.
*/
public static class EventTest {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
index 624bc2cf..e83e5880 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
@@ -160,14 +160,14 @@ public class JsonProtocolFilterTest {
assertTrue(protocolFilterB.getRules(NAME4).get(1).getName().equals(NAME4));
assertTrue(protocolFilterB.getRules(NAME4).get(1).getRegex().equals(REGEX4b));
- String jsonA = "{ \"name1\":\"regex1\",\"name2\":\"regex2\"," +
- "\"name3\":\"regex3\",\"name4\":\"regex4a\",\"name4\":\"regex4b\"}";
- String jsonB = "{ \"name1\":\"regex1\",\"name2\":\"regex2\"," +
- "\"name3\":\"regex3\",\"name4\":\"regex4a-regex4b\"}";
- String jsonC = "{ \"name1\":\"regex1\",\"name2\":\"regex2\"," +
- "\"name3\":\"regex3\",\"name4\":\"regex4a\"}";
- String jsonD = "{ \"name1\":\"regex1\",\"name2\":\"regex2\"," +
- "\"name3\":\"regex3\",\"name4\":\"regex4b\"}";
+ final String jsonA = "{ \"name1\":\"regex1\",\"name2\":\"regex2\","
+ + "\"name3\":\"regex3\",\"name4\":\"regex4a\",\"name4\":\"regex4b\"}";
+ final String jsonB = "{ \"name1\":\"regex1\",\"name2\":\"regex2\","
+ + "\"name3\":\"regex3\",\"name4\":\"regex4a-regex4b\"}";
+ final String jsonC = "{ \"name1\":\"regex1\",\"name2\":\"regex2\","
+ + "\"name3\":\"regex3\",\"name4\":\"regex4a\"}";
+ final String jsonD = "{ \"name1\":\"regex1\",\"name2\":\"regex2\","
+ + "\"name3\":\"regex3\",\"name4\":\"regex4b\"}";
assertFalse(protocolFilterB.accept(jsonA));
assertTrue(protocolFilterB.accept(jsonB));
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 aa04f407..28168178 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
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * ProtocolCoder Toolset JUNITs
+ * ProtocolCoder Toolset JUNITs.
*/
public class ProtocolCoderToolsetTest {
public static final String JUNIT_PROTOCOL_CODER_ARTIFACT_ID = "protocolcoder";
@@ -66,6 +66,11 @@ public class ProtocolCoderToolsetTest {
public static final Gson customCoder = new GsonBuilder().create();
+ /**
+ * Setup.
+ *
+ * @throws IOException throws IO Exception
+ */
@Before
public void setUp() throws IOException {
if (releaseId != null) {
@@ -94,6 +99,11 @@ public class ProtocolCoderToolsetTest {
testJacksonToolset(createFilterSet());
}
+ /**
+ * Test the Gson toolset.
+ *
+ * @param protocolFilter protocol filter
+ */
public void testGsonToolset(JsonProtocolFilter protocolFilter) {
GsonProtocolCoderToolset gsonToolset = new GsonProtocolCoderToolset(JUNIT_PROTOCOL_CODER_TOPIC, CONTROLLER_ID,
this.releaseId.getGroupId(), this.releaseId.getArtifactId(), Triple.class.getCanonicalName(),
@@ -114,6 +124,11 @@ public class ProtocolCoderToolsetTest {
return new Triple<>("v1", "v2", "v3");
}
+ /**
+ * Test Jackson toolset.
+ *
+ * @param protocolFilter protocol filter
+ */
public void testJacksonToolset(JsonProtocolFilter protocolFilter) {
JacksonProtocolCoderToolset jacksonToolset = new JacksonProtocolCoderToolset(JUNIT_PROTOCOL_CODER_TOPIC,
CONTROLLER_ID, this.releaseId.getGroupId(), this.releaseId.getArtifactId(),
@@ -242,7 +257,7 @@ public class ProtocolCoderToolsetTest {
Properties sinkConfig = new Properties();
sinkConfig.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, JUNIT_PROTOCOL_CODER_TOPIC);
- List<? extends TopicSink> noopTopics = TopicEndpoint.manager.addTopicSinks(sinkConfig);
+ final List<? extends TopicSink> noopTopics = TopicEndpoint.manager.addTopicSinks(sinkConfig);
Properties droolsControllerConfig = new Properties();
droolsControllerConfig.put(DroolsProperties.RULES_GROUPID, releaseId.getGroupId());
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
index bfebeacf..f3817d5c 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Configuration Test
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.protocol.configuration;
import static org.junit.Assert.assertEquals;
@@ -50,6 +51,10 @@ public class ControllerConfigurationTest {
private static final DroolsConfiguration DROOLS_CONFIG2 = new DroolsConfiguration(ARTIFACT2, GROUPID2, VERSION2);
private static final String DROOLS_STRING = "drools";
+
+ /**
+ * Test.
+ */
@Test
public void test() {
@@ -77,7 +82,8 @@ public class ControllerConfigurationTest {
controllerConfig2.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
assertEquals(controllerConfig2.getAdditionalProperties(), additionalProperties);
- assertEquals(controllerConfig2, controllerConfig2.withAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE));
+ assertEquals(controllerConfig2, controllerConfig2.withAdditionalProperty(ADDITIONAL_PROPERTY_KEY,
+ ADDITIONAL_PROPERTY_VALUE));
assertTrue(controllerConfig2.declaredProperty(NAME, NAME2));
assertTrue(controllerConfig2.declaredProperty(OPERATION, OPERATION2));
@@ -90,10 +96,9 @@ public class ControllerConfigurationTest {
assertEquals(controllerConfig2.declaredPropertyOrNotFound(DROOLS_STRING, DROOLS_CONFIG2), DROOLS_CONFIG2);
assertEquals(controllerConfig2.declaredPropertyOrNotFound("dummy", NAME), NAME);
- int hashCode = new HashCodeBuilder().append(NAME2).append(OPERATION2).append(DROOLS_CONFIG2).append(additionalProperties).toHashCode();
+ int hashCode = new HashCodeBuilder().append(NAME2).append(OPERATION2).append(DROOLS_CONFIG2)
+ .append(additionalProperties).toHashCode();
assertEquals(controllerConfig2.hashCode(), hashCode);
}
-
-
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
index f4c2410c..7d9b6551 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Configuration Test
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.protocol.configuration;
import static org.junit.Assert.assertEquals;
@@ -29,73 +30,68 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.junit.Test;
public class DroolsConfigurationTest {
- private static final String ARTIFACT_ID_STRING = "artifactId";
- private static final String GROUP_ID_STRING = "groupId";
- private static final String VERSION_STRING = "version";
-
-
- private static final String NAME = "name";
- private static final String ARTIFACT = "org.onap.artifact";
- private static final String GROUPID = "group";
- private static final String VERSION = "1.0.0";
-
- private static final String ARTIFACT2 = "org.onap.artifact2";
- private static final String GROUPID2 = "group2";
- private static final String VERSION2 = "1.0.1";
-
- private static final String ADDITIONAL_PROPERTY_KEY = "foo";
- private static final String ADDITIONAL_PROPERTY_VALUE = "bar";
-
- @Test
- public void test() {
- final Properties additionalProperties = new Properties();
- additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
+ private static final String ARTIFACT_ID_STRING = "artifactId";
+ private static final String GROUP_ID_STRING = "groupId";
+ private static final String VERSION_STRING = "version";
- final DroolsConfiguration droolsConfig = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
- assertTrue(droolsConfig.equals(droolsConfig));
- droolsConfig.set(ARTIFACT_ID_STRING, "foobar");
- assertEquals(droolsConfig.get(ARTIFACT_ID_STRING), "foobar");
+ private static final String NAME = "name";
+ private static final String ARTIFACT = "org.onap.artifact";
+ private static final String GROUPID = "group";
+ private static final String VERSION = "1.0.0";
- assertEquals(droolsConfig.with(ARTIFACT_ID_STRING, "foobar2"), droolsConfig);
+ private static final String ARTIFACT2 = "org.onap.artifact2";
+ private static final String GROUPID2 = "group2";
+ private static final String VERSION2 = "1.0.1";
- final DroolsConfiguration droolsConfig2 = new DroolsConfiguration();
- droolsConfig2.setArtifactId(ARTIFACT2);
- droolsConfig2.setGroupId(GROUPID2);
- droolsConfig2.setVersion(VERSION2);
+ private static final String ADDITIONAL_PROPERTY_KEY = "foo";
+ private static final String ADDITIONAL_PROPERTY_VALUE = "bar";
- assertEquals(droolsConfig2.getArtifactId(), ARTIFACT2);
- assertEquals(droolsConfig2.getGroupId(), GROUPID2);
- assertEquals(droolsConfig2.getVersion(), VERSION2);
+ @Test
+ public void test() {
+ final Properties additionalProperties = new Properties();
+ additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
- assertEquals(droolsConfig2.withArtifactId(ARTIFACT2), droolsConfig2);
- assertEquals(droolsConfig2.withGroupId(GROUPID2), droolsConfig2);
- assertEquals(droolsConfig2.withVersion(VERSION2), droolsConfig2);
+ final DroolsConfiguration droolsConfig = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
+ assertTrue(droolsConfig.equals(droolsConfig));
- droolsConfig2.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
- assertEquals(droolsConfig2.getAdditionalProperties(), additionalProperties);
+ droolsConfig.set(ARTIFACT_ID_STRING, "foobar");
+ assertEquals(droolsConfig.get(ARTIFACT_ID_STRING), "foobar");
- assertEquals(droolsConfig2,
- droolsConfig2.withAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE));
+ assertEquals(droolsConfig.with(ARTIFACT_ID_STRING, "foobar2"), droolsConfig);
- assertTrue(droolsConfig2.declaredProperty(ARTIFACT_ID_STRING, ARTIFACT2));
- assertTrue(droolsConfig2.declaredProperty(GROUP_ID_STRING, GROUPID2));
- assertTrue(droolsConfig2.declaredProperty(VERSION_STRING, VERSION2));
- assertFalse(droolsConfig2.declaredProperty("dummy", NAME));
+ final DroolsConfiguration droolsConfig2 = new DroolsConfiguration();
+ droolsConfig2.setArtifactId(ARTIFACT2);
+ droolsConfig2.setGroupId(GROUPID2);
+ droolsConfig2.setVersion(VERSION2);
- assertEquals(droolsConfig2.declaredPropertyOrNotFound(ARTIFACT_ID_STRING, ARTIFACT2),
- ARTIFACT2);
- assertEquals(droolsConfig2.declaredPropertyOrNotFound(GROUP_ID_STRING, GROUPID2), GROUPID2);
- assertEquals(droolsConfig2.declaredPropertyOrNotFound(VERSION_STRING, VERSION2), VERSION2);
- assertEquals(droolsConfig2.declaredPropertyOrNotFound("dummy", ARTIFACT2), ARTIFACT2);
+ assertEquals(droolsConfig2.getArtifactId(), ARTIFACT2);
+ assertEquals(droolsConfig2.getGroupId(), GROUPID2);
+ assertEquals(droolsConfig2.getVersion(), VERSION2);
- final int hashCode = new HashCodeBuilder().append(ARTIFACT2).append(GROUPID2).append(VERSION2)
- .append(additionalProperties).toHashCode();
- assertEquals(droolsConfig2.hashCode(), hashCode);
+ assertEquals(droolsConfig2.withArtifactId(ARTIFACT2), droolsConfig2);
+ assertEquals(droolsConfig2.withGroupId(GROUPID2), droolsConfig2);
+ assertEquals(droolsConfig2.withVersion(VERSION2), droolsConfig2);
+ droolsConfig2.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
+ assertEquals(droolsConfig2.getAdditionalProperties(), additionalProperties);
+ assertEquals(droolsConfig2,
+ droolsConfig2.withAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE));
- }
+ assertTrue(droolsConfig2.declaredProperty(ARTIFACT_ID_STRING, ARTIFACT2));
+ assertTrue(droolsConfig2.declaredProperty(GROUP_ID_STRING, GROUPID2));
+ assertTrue(droolsConfig2.declaredProperty(VERSION_STRING, VERSION2));
+ assertFalse(droolsConfig2.declaredProperty("dummy", NAME));
+ assertEquals(droolsConfig2.declaredPropertyOrNotFound(ARTIFACT_ID_STRING, ARTIFACT2),
+ ARTIFACT2);
+ assertEquals(droolsConfig2.declaredPropertyOrNotFound(GROUP_ID_STRING, GROUPID2), GROUPID2);
+ assertEquals(droolsConfig2.declaredPropertyOrNotFound(VERSION_STRING, VERSION2), VERSION2);
+ assertEquals(droolsConfig2.declaredPropertyOrNotFound("dummy", ARTIFACT2), ARTIFACT2);
+ final int hashCode = new HashCodeBuilder().append(ARTIFACT2).append(GROUPID2).append(VERSION2)
+ .append(additionalProperties).toHashCode();
+ assertEquals(droolsConfig2.hashCode(), hashCode);
+ }
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
index 84c85b8a..b5f3c535 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Configuration Test
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.protocol.configuration;
import static org.junit.Assert.assertEquals;
@@ -32,219 +33,222 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PdpdConfigurationTest {
-
- private static final Logger logger = LoggerFactory.getLogger(PdpdConfigurationTest.class);
-
- private static final String REQUEST_ID = UUID.randomUUID().toString();
- private static final String REQUEST_ID2 = UUID.randomUUID().toString();
-
- private static final String ENTITY = "entity1";
- private static final String ENTITY2 = "entity2";
-
- private static final String PROPERTY1 = "property1";
- private static final String PROPERTY2 = "property2";
-
- private static final String VALUE1 = "value1";
- private static final String VALUE2 = "value2";
-
- private static final String ARTIFACT = "org.onap.artifact";
- private static final String GROUPID = "group";
- private static final String VERSION = "1.0.0";
-
- private static final String ARTIFACT2 = "org.onap.artifact2";
- private static final String GROUPID2 = "group2";
- private static final String VERSION2 = "1.0.1";
-
- private static final String NAME = "name";
- private static final String OPERATION = "operation";
-
- private static final String NAME2 = "name2";
- private static final String OPERATION2 = "operation2";
-
- @Test
- public void test() {
- //
- // Empty constructor test
- //
- DroolsConfiguration drools = new DroolsConfiguration();
- drools.set("artifactId", ARTIFACT);
- drools.set("groupId", GROUPID);
- drools.set("version", VERSION);
- drools.set(PROPERTY1, VALUE1);
-
- assertTrue(drools.equals(drools));
- assertFalse(drools.equals(new Object()));
-
- logger.info("Drools HashCode {}", drools.hashCode());
-
- //
- // Constructor with values test get calls
- //
- DroolsConfiguration drools2 = new DroolsConfiguration(
- drools.get("artifactId"),
- drools.get("groupId"),
- drools.get("version"));
-
- //
- // get Property
- //
-
- drools2.set(PROPERTY1, drools.get(PROPERTY1));
-
- assertTrue(drools.equals(drools2));
-
- //
- // with methods
- //
- drools2.withArtifactId(ARTIFACT2).withGroupId(GROUPID2).withVersion(VERSION2).withAdditionalProperty(PROPERTY2, VALUE2);
-
- assertFalse(drools.equals(drools2));
-
- //
- // Test get additional properties
- //
- assertEquals(drools.getAdditionalProperties().size(), 1);
-
- //
- // Test Not found
- //
- assertEquals(drools.declaredPropertyOrNotFound(PROPERTY2, DroolsConfiguration.NOT_FOUND_VALUE), DroolsConfiguration.NOT_FOUND_VALUE);
-
- logger.info("drools {}", drools);
- logger.info("drools2 {}", drools2);
-
- //
- // Test Controller Default Constructor
- //
- ControllerConfiguration controller = new ControllerConfiguration();
-
- //
- // Test set
- //
-
- controller.set("name", NAME);
- controller.set("operation", OPERATION);
- controller.set("drools", drools);
- controller.set(PROPERTY1, VALUE1);
-
- assertTrue(controller.equals(controller));
- assertFalse(controller.equals(new Object()));
-
- logger.info("Controller HashCode {}", controller.hashCode());
-
- //
- // Controller Constructor gets
- //
- ControllerConfiguration controller2 = new ControllerConfiguration(
- controller.get("name"),
- controller.get("operation"),
- controller.get("drools"));
-
- //
- // Test get property
- //
-
- controller2.set(PROPERTY1, controller.get(PROPERTY1));
-
- assertTrue(controller.equals(controller2));
-
- //
- // test with methods
- //
-
- controller2.withDrools(drools2).withName(NAME2).withOperation(OPERATION2).withAdditionalProperty(PROPERTY2, VALUE2);
-
- assertFalse(controller.equals(controller2));
-
- //
- // Test additional properties
- //
- assertEquals(controller.getAdditionalProperties().size(), 1);
-
- //
- // Not found
- //
- assertEquals(controller.declaredPropertyOrNotFound(PROPERTY2, ControllerConfiguration.NOT_FOUND_VALUE), ControllerConfiguration.NOT_FOUND_VALUE);
-
- //
- // toString
- //
- logger.info("Controller {}", controller);
- logger.info("Controller2 {}", controller2);
-
- //
- // PDP Configuration empty constructor
- //
- PdpdConfiguration config = new PdpdConfiguration();
-
- //
- // Test set
- //
-
- config.set("requestID", REQUEST_ID);
- config.set("entity", ENTITY);
- List<ControllerConfiguration> controllers = new ArrayList<>();
- controllers.add(controller);
- config.set("controllers", controllers);
- config.set(PROPERTY1, VALUE1);
-
- assertTrue(config.equals(config));
- assertFalse(config.equals(new Object()));
-
- logger.info("Config HashCode {}", config.hashCode());
-
- //
- // Test constructor with values
- //
-
- PdpdConfiguration config2 = new PdpdConfiguration(
- config.get("requestID"),
- config.get("entity"),
- config.get("controllers"));
-
- //
- // Test set
- //
-
- config2.set(PROPERTY1, config.get(PROPERTY1));
-
- assertTrue(config.equals(config2));
-
- //
- // Test with methods
- //
- List<ControllerConfiguration> controllers2 = new ArrayList<>();
- controllers2.add(controller2);
- config2.withRequestID(REQUEST_ID2).withEntity(ENTITY2).withController(controllers2);
-
- assertFalse(config.equals(config2));
-
- //
- // Test additional properties
- //
-
- assertEquals(config.getAdditionalProperties().size(), 1);
-
- //
- // Test NOT FOUND
- //
- assertEquals(config.declaredPropertyOrNotFound(PROPERTY2, ControllerConfiguration.NOT_FOUND_VALUE), ControllerConfiguration.NOT_FOUND_VALUE);
-
- //
- // toString
- //
- logger.info("Config {}", config);
- logger.info("Config2 {}", config2);
-
- }
-
- @Test
- public void testConstructor() {
-
- PdpdConfiguration config = new PdpdConfiguration(REQUEST_ID, ENTITY, null);
- assertEquals(config.getRequestID(), REQUEST_ID);
- assertEquals(config.getEntity(), ENTITY);
-
- }
+
+ private static final Logger logger = LoggerFactory.getLogger(PdpdConfigurationTest.class);
+
+ private static final String REQUEST_ID = UUID.randomUUID().toString();
+ private static final String REQUEST_ID2 = UUID.randomUUID().toString();
+
+ private static final String ENTITY = "entity1";
+ private static final String ENTITY2 = "entity2";
+
+ private static final String PROPERTY1 = "property1";
+ private static final String PROPERTY2 = "property2";
+
+ private static final String VALUE1 = "value1";
+ private static final String VALUE2 = "value2";
+
+ private static final String ARTIFACT = "org.onap.artifact";
+ private static final String GROUPID = "group";
+ private static final String VERSION = "1.0.0";
+
+ private static final String ARTIFACT2 = "org.onap.artifact2";
+ private static final String GROUPID2 = "group2";
+ private static final String VERSION2 = "1.0.1";
+
+ private static final String NAME = "name";
+ private static final String OPERATION = "operation";
+
+ private static final String NAME2 = "name2";
+ private static final String OPERATION2 = "operation2";
+
+ @Test
+ public void test() {
+ //
+ // Empty constructor test
+ //
+ DroolsConfiguration drools = new DroolsConfiguration();
+ drools.set("artifactId", ARTIFACT);
+ drools.set("groupId", GROUPID);
+ drools.set("version", VERSION);
+ drools.set(PROPERTY1, VALUE1);
+
+ assertTrue(drools.equals(drools));
+ assertFalse(drools.equals(new Object()));
+
+ logger.info("Drools HashCode {}", drools.hashCode());
+
+ //
+ // Constructor with values test get calls
+ //
+ DroolsConfiguration drools2 = new DroolsConfiguration(
+ drools.get("artifactId"),
+ drools.get("groupId"),
+ drools.get("version"));
+
+ //
+ // get Property
+ //
+
+ drools2.set(PROPERTY1, drools.get(PROPERTY1));
+
+ assertTrue(drools.equals(drools2));
+
+ //
+ // with methods
+ //
+ drools2.withArtifactId(ARTIFACT2).withGroupId(GROUPID2).withVersion(VERSION2)
+ .withAdditionalProperty(PROPERTY2, VALUE2);
+
+ assertFalse(drools.equals(drools2));
+
+ //
+ // Test get additional properties
+ //
+ assertEquals(drools.getAdditionalProperties().size(), 1);
+
+ //
+ // Test Not found
+ //
+ assertEquals(DroolsConfiguration.NOT_FOUND_VALUE,
+ drools.declaredPropertyOrNotFound(PROPERTY2, DroolsConfiguration.NOT_FOUND_VALUE));
+
+ logger.info("drools {}", drools);
+ logger.info("drools2 {}", drools2);
+
+ //
+ // Test Controller Default Constructor
+ //
+ ControllerConfiguration controller = new ControllerConfiguration();
+
+ //
+ // Test set
+ //
+
+ controller.set("name", NAME);
+ controller.set("operation", OPERATION);
+ controller.set("drools", drools);
+ controller.set(PROPERTY1, VALUE1);
+
+ assertTrue(controller.equals(controller));
+ assertFalse(controller.equals(new Object()));
+
+ logger.info("Controller HashCode {}", controller.hashCode());
+
+ //
+ // Controller Constructor gets
+ //
+ ControllerConfiguration controller2 = new ControllerConfiguration(
+ controller.get("name"),
+ controller.get("operation"),
+ controller.get("drools"));
+
+ //
+ // Test get property
+ //
+
+ controller2.set(PROPERTY1, controller.get(PROPERTY1));
+
+ assertTrue(controller.equals(controller2));
+
+ //
+ // test with methods
+ //
+
+ controller2.withDrools(drools2).withName(NAME2)
+ .withOperation(OPERATION2).withAdditionalProperty(PROPERTY2, VALUE2);
+
+ assertFalse(controller.equals(controller2));
+
+ //
+ // Test additional properties
+ //
+ assertEquals(controller.getAdditionalProperties().size(), 1);
+
+ //
+ // Not found
+ //
+ assertEquals(ControllerConfiguration.NOT_FOUND_VALUE,
+ controller.declaredPropertyOrNotFound(PROPERTY2, ControllerConfiguration.NOT_FOUND_VALUE));
+
+ //
+ // toString
+ //
+ logger.info("Controller {}", controller);
+ logger.info("Controller2 {}", controller2);
+
+ //
+ // PDP Configuration empty constructor
+ //
+ PdpdConfiguration config = new PdpdConfiguration();
+
+ //
+ // Test set
+ //
+
+ config.set("requestID", REQUEST_ID);
+ config.set("entity", ENTITY);
+ List<ControllerConfiguration> controllers = new ArrayList<>();
+ controllers.add(controller);
+ config.set("controllers", controllers);
+ config.set(PROPERTY1, VALUE1);
+
+ assertTrue(config.equals(config));
+ assertFalse(config.equals(new Object()));
+
+ logger.info("Config HashCode {}", config.hashCode());
+
+ //
+ // Test constructor with values
+ //
+
+ PdpdConfiguration config2 = new PdpdConfiguration(
+ config.get("requestID"),
+ config.get("entity"),
+ config.get("controllers"));
+
+ //
+ // Test set
+ //
+
+ config2.set(PROPERTY1, config.get(PROPERTY1));
+
+ assertTrue(config.equals(config2));
+
+ //
+ // Test with methods
+ //
+ List<ControllerConfiguration> controllers2 = new ArrayList<>();
+ controllers2.add(controller2);
+ config2.withRequestID(REQUEST_ID2).withEntity(ENTITY2).withController(controllers2);
+
+ assertFalse(config.equals(config2));
+
+ //
+ // Test additional properties
+ //
+
+ assertEquals(config.getAdditionalProperties().size(), 1);
+
+ //
+ // Test NOT FOUND
+ //
+ assertEquals(ControllerConfiguration.NOT_FOUND_VALUE,
+ config.declaredPropertyOrNotFound(PROPERTY2, ControllerConfiguration.NOT_FOUND_VALUE));
+
+ //
+ // toString
+ //
+ logger.info("Config {}", config);
+ logger.info("Config2 {}", config2);
+
+ }
+
+ @Test
+ public void testConstructor() {
+ PdpdConfiguration config = new PdpdConfiguration(REQUEST_ID, ENTITY, null);
+ assertEquals(config.getRequestID(), REQUEST_ID);
+ assertEquals(config.getEntity(), ENTITY);
+ }
}
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 e96a4b91..68a52ade 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -94,6 +94,11 @@ public class RestManagerTest {
private static final Logger logger = LoggerFactory.getLogger(RestManagerTest.class);
+ /**
+ * Set up.
+ *
+ * @throws IOException throws an IO exception
+ */
@BeforeClass
public static void setUp() throws IOException {
cleanUpWorkingDirs();
@@ -133,6 +138,12 @@ public class RestManagerTest {
}
+ /**
+ * Tear down.
+ *
+ * @throws IOException IO exception
+ * @throws InterruptedException Interrupted exception
+ */
@AfterClass
public static void tearDown() throws IOException, InterruptedException {
/* Shutdown managed resources */
@@ -147,7 +158,6 @@ public class RestManagerTest {
@Test
public void putDeleteTest() throws ClientProtocolException, IOException, InterruptedException {
- HttpPut httpPut;
HttpDelete httpDelete;
CloseableHttpResponse response;
@@ -172,7 +182,7 @@ public class RestManagerTest {
* PUT: /engine/switches/lock /engine/controllers/controllername/switches/lock DELETE:
* /engine/switches/lock /engine/controllers/controllername
*/
- httpPut = new HttpPut(HOST_URL + "/engine/switches/lock");
+ HttpPut httpPut = new HttpPut(HOST_URL + "/engine/switches/lock");
response = client.execute(httpPut);
logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(406, response.getStatusLine().getStatusCode());
@@ -351,7 +361,6 @@ public class RestManagerTest {
public void getTest() throws ClientProtocolException, IOException, InterruptedException {
HttpGet httpGet;
CloseableHttpResponse response;
- String responseBody;
/*
* GET: /engine /engine/features /engine/features/inventory /engine/features/featurename
@@ -403,7 +412,7 @@ public class RestManagerTest {
PolicyEngine.manager.setEnvironmentProperty("foo", "bar");
httpGet = new HttpGet(HOST_URL + "/engine/environment/foo");
response = client.execute(httpGet);
- responseBody = this.getResponseBody(response);
+ String responseBody = this.getResponseBody(response);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
logger.info(httpGet.getRequestLine() + " response body: {}", responseBody);
assertEquals(200, response.getStatusLine().getStatusCode());
@@ -839,7 +848,12 @@ public class RestManagerTest {
}
-
+ /**
+ * Get response body.
+ *
+ * @param response incoming response
+ * @return the body or null
+ */
public String getResponseBody(CloseableHttpResponse response) {
HttpEntity entity;
@@ -848,7 +862,7 @@ public class RestManagerTest {
return EntityUtils.toString(entity);
} catch (final IOException e) {
-
+ logger.info(e.toString());
}
return null;
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java
index c6a4ffb8..7b02d755 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/test/PolicyEngineTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -49,58 +49,58 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * PolicyEngine unit tests
+ * PolicyEngine unit tests.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PolicyEngineTest {
/**
- * Default Telemetry port for JUnits
+ * Default Telemetry port for JUnits.
*/
public static final int DEFAULT_TELEMETRY_PORT = 9698;
/**
- * Test JUnit Controller Name
+ * Test JUnit Controller Name.
*/
public static final String TEST_CONTROLLER_NAME = "foo";
/**
- * Controller Configuration File
+ * Controller Configuration File.
*/
public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
/**
- * Controller Configuration Backup File
+ * Controller Configuration Backup File.
*/
public static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
/**
- * Coder Group
+ * Coder Group.
*/
private static final String ENCODER_GROUP = "foo";
/**
- * Coder Artifact
+ * Coder Artifact.
*/
private static final String ENCODER_ARTIFACT = "bar";
/**
- * Coder Version
+ * Coder Version.
*/
private static final String ENCODER_VERSION = null;
/**
- * noop topic
+ * noop topic.
*/
private static final String NOOP_TOPIC = "JUNIT";
/**
- * logger
+ * logger.
*/
private static Logger logger = LoggerFactory.getLogger(PolicyEngineTest.class);
/**
- * clean up working directory
+ * clean up working directory.
*/
protected static void cleanUpWorkingDir() {
final Path testControllerPath =
@@ -120,6 +120,11 @@ public class PolicyEngineTest {
}
}
+ /**
+ * Start up.
+ *
+ * @throws IOException throws IO exception
+ */
@BeforeClass
public static void startUp() throws IOException {
logger.info("enter");