diff options
author | liboNet <libo.zhu@intel.com> | 2018-08-23 10:43:00 +0800 |
---|---|---|
committer | liboNet <libo.zhu@intel.com> | 2018-08-23 10:50:14 +0800 |
commit | 9a3dcafd4b22f2e11e2bcb256eb387745c606fa3 (patch) | |
tree | b9ed8520c60e9c07cf73a70b4d797c638d58fd92 /reception | |
parent | 742c4b2ed82860e2a74f3db3b2048173fbc530d8 (diff) |
Fix sonar code coverage issue
* Remove unused import
* Fix more than 1 statements on one line
* Divide validate into three parts to Fix >10 cyclomatic Complexity
Change-Id: I9c89c4854de31fa02a9052055662f4b74d12fe10
Issue-ID: POLICY-956
Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'reception')
-rw-r--r-- | reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java | 207 |
1 files changed, 138 insertions, 69 deletions
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java index 52e0988a..529cc9e4 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java @@ -17,11 +17,9 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.onap.policy.distribution.reception.parameters; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -76,38 +74,81 @@ public class PSSDConfigurationParametersGroup implements ParameterGroup { private boolean isFilterinEmptyResources; private Boolean isUseHttpsWithDmaap; - public PSSDConfigurationBuilder setAsdcAddress(String val) - { asdcAddress = val; return this; } - public PSSDConfigurationBuilder setMessageBusAddress(List<String> val) - { messageBusAddress = val; return this; } - public PSSDConfigurationBuilder setUser(String val) - { user = val; return this; } - public PSSDConfigurationBuilder setPassword(String val) - { password = val; return this; } - public PSSDConfigurationBuilder setPollingInterval(int val) - { pollingInterval = val; return this; } - public PSSDConfigurationBuilder setPollingTimeout(int val) - { pollingTimeout = val; return this; } - public PSSDConfigurationBuilder setConsumerId(String val) - { consumerId = val; return this; } - public PSSDConfigurationBuilder setArtifactTypes(List<String> val) - { artifactTypes = val; return this; } - public PSSDConfigurationBuilder setConsumerGroup(String val) - { consumerGroup = val; return this; } - public PSSDConfigurationBuilder setEnvironmentName(String val) - { environmentName = val; return this; } - public PSSDConfigurationBuilder setKeystorePath(String val) - { keystorePath = val; return this; } - public PSSDConfigurationBuilder setKeystorePassword(String val) - { keystorePassword = val; return this; } - public PSSDConfigurationBuilder setActiveserverTlsAuth(boolean val) - { activeserverTlsAuth = val; return this; } - public PSSDConfigurationBuilder setIsFilterinEmptyResources(boolean val) - { isFilterinEmptyResources = val; return this; } - public PSSDConfigurationBuilder setIsUseHttpsWithDmaap(Boolean val) - { isUseHttpsWithDmaap = val; return this; } + public PSSDConfigurationBuilder setAsdcAddress(String val) { + asdcAddress = val; + return this; + } + + public PSSDConfigurationBuilder setMessageBusAddress(List<String> val) { + messageBusAddress = val; + return this; + } + + public PSSDConfigurationBuilder setUser(String val) { + user = val; + return this; + } + + public PSSDConfigurationBuilder setPassword(String val) { + password = val; + return this; + } + + public PSSDConfigurationBuilder setPollingInterval(int val) { + pollingInterval = val; + return this; + } + + public PSSDConfigurationBuilder setPollingTimeout(int val) { + pollingTimeout = val; + return this; + } + + public PSSDConfigurationBuilder setConsumerId(String val) { + consumerId = val; + return this; + } + + public PSSDConfigurationBuilder setArtifactTypes(List<String> val) { + artifactTypes = val; + return this; + } + + public PSSDConfigurationBuilder setConsumerGroup(String val) { + consumerGroup = val; + return this; + } + + public PSSDConfigurationBuilder setEnvironmentName(String val) { + environmentName = val; + return this; + } + + public PSSDConfigurationBuilder setKeystorePath(String val) { + keystorePath = val; + return this; + } + + public PSSDConfigurationBuilder setKeystorePassword(String val) { + keystorePassword = val; + return this; + } + + public PSSDConfigurationBuilder setActiveserverTlsAuth(boolean val) { + activeserverTlsAuth = val; + return this; + } + + public PSSDConfigurationBuilder setIsFilterinEmptyResources(boolean val) { + isFilterinEmptyResources = val; + return this; + } + + public PSSDConfigurationBuilder setIsUseHttpsWithDmaap(Boolean val) { + isUseHttpsWithDmaap = val; + return this; + } - /** * it is to create a new PSSDConfigurationParametersGroup instance. */ @@ -200,50 +241,49 @@ public class PSSDConfigurationParametersGroup implements ParameterGroup { public Boolean isUseHttpsWithDmaap() { return isUseHttpsWithDmaap; } - + + /** + * Return a string representation of the object + * + * @return textually represents this object + */ @Override public String toString() { return "name =" + name + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = " + messageBusAddress + ", user = " + user + "]"; } + /** + * Return the name of this parameter group instance + * + * @return name the parameter group name + */ @Override public String getName() { return name ; } - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - - if (asdcAddress == null || asdcAddress.trim().length() == 0) { - validationResult.setResult("asdcAddress", ValidationStatus.INVALID, - "asdcAddress must be a non-blank string"); - } - - if (user == null || user.trim().length() == 0) { - validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string"); - } - - if (consumerId == null || consumerId.trim().length() == 0) { - validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string"); - } - - if (consumerGroup == null || consumerGroup.trim().length() == 0) { - validationResult.setResult("consumerGroup", ValidationStatus.INVALID, - "consumerGroup must be a non-blank string"); - } - - if (keystorePath == null || keystorePath.trim().length() == 0) { - validationResult.setResult("keystorePath", ValidationStatus.INVALID, - "keystorePath must be a non-blank string"); + /** + * Validate all the int Elements + * + */ + private void validateIntElement(final GroupValidationResult validationResult) { + if (pollingInterval <= 0) { + validationResult.setResult("pollingInterval", ValidationStatus.INVALID, + "pollingInterval must be a positive integer"); } - if (keystorePassword == null || keystorePassword.trim().length() == 0) { - validationResult.setResult("keystorePassword", ValidationStatus.INVALID, - "keystorePassword must be a non-blank string"); + if (pollingTimeout <= 0) { + validationResult.setResult("pollingTimeout", ValidationStatus.INVALID, + "pollingTimeout must be a positive integer"); } + } + /** + * Validate all the String List Elements + * + */ + private void validateStringListElement(final GroupValidationResult validationResult) { if (messageBusAddress == null) { validationResult.setResult("messageBusAddress", ValidationStatus.INVALID, "messageBusAddress must be a list of non-blank string"); @@ -267,17 +307,46 @@ public class PSSDConfigurationParametersGroup implements ParameterGroup { } } } + } - if (pollingInterval <= 0) { - validationResult.setResult("pollingInterval", ValidationStatus.INVALID, - "pollingInterval must be a positive integer"); + /** + * Validate the parameter group + * @return the result of the validation + */ + @Override + public GroupValidationResult validate() { + final GroupValidationResult validationResult = new GroupValidationResult(this); + + if (asdcAddress == null || asdcAddress.trim().length() == 0) { + validationResult.setResult("asdcAddress", ValidationStatus.INVALID, + "asdcAddress must be a non-blank string"); } - if (pollingTimeout <= 0) { - validationResult.setResult("pollingTimeout", ValidationStatus.INVALID, - "pollingTimeout must be a positive integer"); + if (user == null || user.trim().length() == 0) { + validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string"); + } + + if (consumerId == null || consumerId.trim().length() == 0) { + validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string"); + } + + if (consumerGroup == null || consumerGroup.trim().length() == 0) { + validationResult.setResult("consumerGroup", ValidationStatus.INVALID, + "consumerGroup must be a non-blank string"); + } + + if (keystorePath == null || keystorePath.trim().length() == 0) { + validationResult.setResult("keystorePath", ValidationStatus.INVALID, + "keystorePath must be a non-blank string"); + } + + if (keystorePassword == null || keystorePassword.trim().length() == 0) { + validationResult.setResult("keystorePassword", ValidationStatus.INVALID, + "keystorePassword must be a non-blank string"); } + validateIntElement(validationResult); + validateStringListElement(validationResult); return validationResult; } |