From 38bd1bffbed6faa272bf435c9936e3a99287372e Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 19 Sep 2017 07:34:04 -0400 Subject: Adding JUnits for Configuration Classes Also fixed some Sonar Major issues to help clean that up. Issue-ID: POLICY-109 Change-Id: Ic8a0b8d97f2be1cc1f8e8e4e8b319c6117b231a4 Signed-off-by: Pamela Dragosh --- .../configuration/ControllerConfiguration.java | 3 ++- .../protocol/configuration/DroolsConfiguration.java | 17 +++++++++-------- .../protocol/configuration/PdpdConfiguration.java | 21 +++++++++++---------- 3 files changed, 22 insertions(+), 19 deletions(-) (limited to 'policy-management/src/main/java') diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java index ded7a52c..b0b8b504 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java @@ -67,7 +67,7 @@ public class ControllerConfiguration { @JsonProperty("drools") private DroolsConfiguration drools; @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); protected final static Object NOT_FOUND_VALUE = new Object(); /** @@ -75,6 +75,7 @@ public class ControllerConfiguration { * */ public ControllerConfiguration() { + // Empty } /** diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java index 5f32d7a4..4c672e7b 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java @@ -63,7 +63,7 @@ public class DroolsConfiguration { @JsonProperty("version") private String version; @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); protected final static Object NOT_FOUND_VALUE = new Object(); /** @@ -71,6 +71,7 @@ public class DroolsConfiguration { * */ public DroolsConfiguration() { + // Empty } /** @@ -196,21 +197,21 @@ public class DroolsConfiguration { switch (name) { case "artifactId": if (value instanceof String) { - setArtifactId(((String) value)); + setArtifactId((String) value); } else { throw new IllegalArgumentException(("property \"artifactId\" is of type \"java.lang.String\", but got "+ value.getClass().toString())); } return true; case "groupId": if (value instanceof String) { - setGroupId(((String) value)); + setGroupId((String) value); } else { throw new IllegalArgumentException(("property \"groupId\" is of type \"java.lang.String\", but got "+ value.getClass().toString())); } return true; case "version": if (value instanceof String) { - setVersion(((String) value)); + setVersion((String) value); } else { throw new IllegalArgumentException(("property \"version\" is of type \"java.lang.String\", but got "+ value.getClass().toString())); } @@ -239,21 +240,21 @@ public class DroolsConfiguration { publicT get(String name) { Object value = declaredPropertyOrNotFound(name, DroolsConfiguration.NOT_FOUND_VALUE); if (DroolsConfiguration.NOT_FOUND_VALUE!= value) { - return ((T) value); + return (T) value; } else { - return ((T) getAdditionalProperties().get(name)); + return (T) getAdditionalProperties().get(name); } } public void set(String name, Object value) { if (!declaredProperty(name, value)) { - getAdditionalProperties().put(name, ((Object) value)); + getAdditionalProperties().put(name, value); } } public DroolsConfiguration with(String name, Object value) { if (!declaredProperty(name, value)) { - getAdditionalProperties().put(name, ((Object) value)); + getAdditionalProperties().put(name, value); } return this; } diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java index d7295fd4..8d6f9bfd 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java @@ -67,9 +67,9 @@ public class PdpdConfiguration { * */ @JsonProperty("controllers") - private List controllers = new ArrayList(); + private List controllers = new ArrayList<>(); @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); protected final static Object NOT_FOUND_VALUE = new Object(); /** @@ -77,6 +77,7 @@ public class PdpdConfiguration { * */ public PdpdConfiguration() { + // Empty } /** @@ -201,21 +202,21 @@ public class PdpdConfiguration { switch (name) { case "requestID": if (value instanceof String) { - setRequestID(((String) value)); + setRequestID((String) value); } else { throw new IllegalArgumentException(("property \"requestID\" is of type \"java.lang.String\", but got "+ value.getClass().toString())); } return true; case "entity": if (value instanceof String) { - setEntity(((String) value)); + setEntity((String) value); } else { throw new IllegalArgumentException(("property \"entity\" is of type \"java.lang.String\", but got "+ value.getClass().toString())); } return true; case "controllers": if (value instanceof List) { - setControllers(((List ) value)); + setControllers((List ) value); } else { throw new IllegalArgumentException(("property \"controllers\" is of type \"java.util.List\", but got "+ value.getClass().toString())); } @@ -244,21 +245,21 @@ public class PdpdConfiguration { publicT get(String name) { Object value = declaredPropertyOrNotFound(name, PdpdConfiguration.NOT_FOUND_VALUE); if (PdpdConfiguration.NOT_FOUND_VALUE!= value) { - return ((T) value); + return (T) value; } else { - return ((T) getAdditionalProperties().get(name)); + return (T) getAdditionalProperties().get(name); } } public void set(String name, Object value) { if (!declaredProperty(name, value)) { - getAdditionalProperties().put(name, ((Object) value)); + getAdditionalProperties().put(name, value); } } public PdpdConfiguration with(String name, Object value) { if (!declaredProperty(name, value)) { - getAdditionalProperties().put(name, ((Object) value)); + getAdditionalProperties().put(name, value); } return this; } @@ -276,7 +277,7 @@ public class PdpdConfiguration { if ((other instanceof PdpdConfiguration) == false) { return false; } - PdpdConfiguration rhs = ((PdpdConfiguration) other); + PdpdConfiguration rhs = (PdpdConfiguration) other; return new EqualsBuilder().append(requestID, rhs.requestID).append(entity, rhs.entity).append(controllers, rhs.controllers).append(additionalProperties, rhs.additionalProperties).isEquals(); } -- cgit 1.2.3-korg