From 0415057132ae04f1d75cb60f7a62d9fa65d6e04d Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Thu, 18 Feb 2021 15:15:26 -0600 Subject: Fix sonars and target dir Fix a couple of sonars introduced by the PdpType review. Also creation of a target directory below the xacml-pdp directory. Issue-ID: POLICY-3071 Change-Id: I9fe325d0a75970fbe3d42be36906013c1fc2ecb9 Signed-off-by: Pamela Dragosh --- .../pdpx/main/parameters/XacmlPdpParameterGroup.java | 8 +++++--- .../main/parameters/TestXacmlPdpParameterHandler.java | 15 +++------------ 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java index 9c8eae0b..cb8425b1 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java @@ -41,6 +41,8 @@ public class XacmlPdpParameterGroup implements ParameterGroup { private static final String PARAM_TOPIC_PARAMETER_GROUP = "topicParameterGroup"; private static final String PARAM_APPLICATION_PATH = "applicationPath"; + private static final String ERROR_MSG = "must be a non-blank string"; + @Setter private String name; @@ -78,13 +80,13 @@ public class XacmlPdpParameterGroup implements ParameterGroup { public GroupValidationResult validate() { final GroupValidationResult validationResult = new GroupValidationResult(this); if (!ParameterValidationUtils.validateStringParameter(name)) { - validationResult.setResult("name", ValidationStatus.INVALID, "must be a non-blank string"); + validationResult.setResult("name", ValidationStatus.INVALID, ERROR_MSG); } if (!ParameterValidationUtils.validateStringParameter(pdpGroup)) { - validationResult.setResult("pdpGroup", ValidationStatus.INVALID, "must be a non-blank string"); + validationResult.setResult("pdpGroup", ValidationStatus.INVALID, ERROR_MSG); } if (!ParameterValidationUtils.validateStringParameter(pdpType)) { - validationResult.setResult("pdpType", ValidationStatus.INVALID, "must be a non-blank string"); + validationResult.setResult("pdpType", ValidationStatus.INVALID, ERROR_MSG); } if (restServerParameters == null) { validationResult.setResult(PARAM_REST_SERVER, ValidationStatus.INVALID, diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java index 9a997194..1b62965d 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java @@ -135,7 +135,7 @@ public class TestXacmlPdpParameterHandler { } @Test - public void testXacmlPdpParameterGroup_InvalidName() throws PolicyXacmlPdpException { + public void testXacmlPdpParameterGroup_Invalid() throws PolicyXacmlPdpException { final String[] xacmlPdpConfigParameters = {"-c", "parameters/XacmlPdpConfigParameters_InvalidName.json"}; final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments(); @@ -143,24 +143,15 @@ public class TestXacmlPdpParameterHandler { assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining( "field \"name\" type \"java.lang.String\" value \" \" INVALID, must be a non-blank string"); - } - - @Test - public void testXacmlPdpParameterGroup_InvalidPdpGroup() throws PolicyXacmlPdpException { - final String[] xacmlPdpConfigParameters = {"-c", "parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json"}; + xacmlPdpConfigParameters[1] = "parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json"; - final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments(); arguments.parse(xacmlPdpConfigParameters); assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining( "field \"pdpGroup\" type \"java.lang.String\" value \" \" INVALID, must be a non-blank string"); - } - @Test - public void testXacmlPdpParameterGroup_InvalidPdpType() throws PolicyXacmlPdpException { - final String[] xacmlPdpConfigParameters = {"-c", "parameters/XacmlPdpConfigParameters_InvalidPdpType.json"}; + xacmlPdpConfigParameters[1] = "parameters/XacmlPdpConfigParameters_InvalidPdpType.json"; - final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments(); arguments.parse(xacmlPdpConfigParameters); assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining( -- cgit 1.2.3-korg