diff options
Diffstat (limited to 'policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java')
-rw-r--r-- | policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java | 104 |
1 files changed, 50 insertions, 54 deletions
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); + } } |