aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2017-09-21 13:11:55 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2017-09-21 13:12:08 -0500
commit727029e8ca0d596be20894f8565b54f66d299c2e (patch)
treeab9a8a04a47d0026715b0a5cfe7a0e48e2828513 /policy-management/src
parent42ddcb6dde34fd19523a33b72607dec4ecca31fc (diff)
Added junits to cover configuration classes
Added junits to cover DroolsConfiguration and ControllerConfiguration classes. Issue-Id: POLICY-262 Change-Id: Ie6cf4b15f8b08220a93b4469cc6fd4eda9299138 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'policy-management/src')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java99
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java108
2 files changed, 207 insertions, 0 deletions
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
new file mode 100644
index 00000000..bfebeacf
--- /dev/null
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Configuration Test
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.drools.protocol.configuration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.junit.Test;
+
+public class ControllerConfigurationTest {
+
+
+ private static final String NAME = "name";
+ private static final String OPERATION = "operation";
+ private static final String NAME2 = "name2";
+ private static final String OPERATION2 = "operation2";
+
+ 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";
+
+ private static final DroolsConfiguration DROOLS_CONFIG = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
+ private static final DroolsConfiguration DROOLS_CONFIG2 = new DroolsConfiguration(ARTIFACT2, GROUPID2, VERSION2);
+
+ private static final String DROOLS_STRING = "drools";
+ @Test
+ public void test() {
+
+ Properties additionalProperties = new Properties();
+ additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
+
+ ControllerConfiguration controllerConfig = new ControllerConfiguration(NAME, OPERATION, DROOLS_CONFIG);
+
+ assertTrue(controllerConfig.equals(controllerConfig));
+ assertFalse(controllerConfig.equals(new Object()));
+
+ ControllerConfiguration controllerConfig2 = new ControllerConfiguration();
+ controllerConfig2.setName(NAME2);
+ controllerConfig2.setOperation(OPERATION2);
+ controllerConfig2.setDrools(DROOLS_CONFIG2);
+
+ assertEquals(controllerConfig2.getName(), NAME2);
+ assertEquals(controllerConfig2.getOperation(), OPERATION2);
+ assertEquals(controllerConfig2.getDrools(), DROOLS_CONFIG2);
+
+ assertEquals(controllerConfig2, controllerConfig2.withName(NAME2));
+ assertEquals(controllerConfig2, controllerConfig2.withOperation(OPERATION2));
+ assertEquals(controllerConfig2, controllerConfig2.withDrools(DROOLS_CONFIG2));
+
+ controllerConfig2.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
+ assertEquals(controllerConfig2.getAdditionalProperties(), additionalProperties);
+
+ assertEquals(controllerConfig2, controllerConfig2.withAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE));
+
+ assertTrue(controllerConfig2.declaredProperty(NAME, NAME2));
+ assertTrue(controllerConfig2.declaredProperty(OPERATION, OPERATION2));
+ assertTrue(controllerConfig2.declaredProperty(DROOLS_STRING, DROOLS_CONFIG2));
+ assertFalse(controllerConfig2.declaredProperty("dummy", NAME));
+
+
+ assertEquals(controllerConfig2.declaredPropertyOrNotFound(NAME, NAME2), NAME2);
+ assertEquals(controllerConfig2.declaredPropertyOrNotFound(OPERATION, OPERATION2), OPERATION2);
+ 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();
+ 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
new file mode 100644
index 00000000..8ecda75d
--- /dev/null
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Configuration Test
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.drools.protocol.configuration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+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 OPERATION = "operation";
+ private static final String NAME2 = "name2";
+ private static final String OPERATION2 = "operation2";
+
+ 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";
+
+ private static final DroolsConfiguration DROOLS_CONFIG = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
+ private static final DroolsConfiguration DROOLS_CONFIG2 = new DroolsConfiguration(ARTIFACT2, GROUPID2, VERSION2);
+
+
+
+ @Test
+ public void test() {
+ Properties additionalProperties = new Properties();
+ additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
+
+ DroolsConfiguration droolsConfig = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
+ assertTrue(droolsConfig.equals(droolsConfig));
+
+ droolsConfig.set(ARTIFACT_ID_STRING, "foobar");
+ assertEquals(droolsConfig.get(ARTIFACT_ID_STRING),"foobar");
+
+ assertEquals(droolsConfig.with(ARTIFACT_ID_STRING, "foobar2"), droolsConfig);
+
+ DroolsConfiguration droolsConfig2 = new DroolsConfiguration();
+ droolsConfig2.setArtifactId(ARTIFACT2);
+ droolsConfig2.setGroupId(GROUPID2);
+ droolsConfig2.setVersion(VERSION2);
+
+ assertEquals(droolsConfig2.getArtifactId(), ARTIFACT2);
+ assertEquals(droolsConfig2.getGroupId(), GROUPID2);
+ assertEquals(droolsConfig2.getVersion(), VERSION2);
+
+ 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);
+
+ int hashCode = new HashCodeBuilder().append(ARTIFACT2).append(GROUPID2).append(VERSION2).append(additionalProperties).toHashCode();
+ assertEquals(droolsConfig2.hashCode(), hashCode);
+
+
+
+
+ }
+
+
+}