summaryrefslogtreecommitdiffstats
path: root/common/onap-sdc-artifact-generator-lib
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2018-05-22 08:36:40 +0200
committerTal Gitelman <tg851x@intl.att.com>2018-07-24 14:21:26 +0000
commitd0f8678bfa7f06f06c9f1dd3cad862b1b99c3a03 (patch)
tree277b0775e7a520242708e0866eb0f3bf67259661 /common/onap-sdc-artifact-generator-lib
parent4c9bc0204405fc840cac190fb9e0de946f3899ff (diff)
Fix sonar violations
Fix major sonar violations in ConfigurationUtils,ConfigurationImpl, PropertyType Issue-ID: SDC-1353 Change-Id: Ic3959ba174f0a9fcd3976c9d12c6425dc4353e72 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'common/onap-sdc-artifact-generator-lib')
-rw-r--r--common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java36
-rw-r--r--common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-test/src/main/java/org/onap/sdc/generator/SampleJUnitTest.java17
2 files changed, 25 insertions, 28 deletions
diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java
index ac8dffae02..83ded46bd1 100644
--- a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java
+++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java
@@ -26,7 +26,6 @@ import org.onap.sdc.generator.data.GeneratorConstants;
import org.onap.sdc.generator.error.IllegalAccessException;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -36,7 +35,6 @@ public abstract class Model {
protected Set<Widget> widgets = new HashSet<>();
private String modelId;
private String modelName;
- private ModelType modelType;
private String modelVersion;
private String modelNameVersionId;
private String modelDescription;
@@ -50,7 +48,7 @@ public abstract class Model {
public static Model getModelFor(String toscaType) {
Model modelToBeReturned = null;
- while (toscaType != null && toscaType.lastIndexOf(".") != -1 && modelToBeReturned == null) {
+ while (isModelNotSet(toscaType, modelToBeReturned)) {
switch (toscaType) {
@@ -91,6 +89,7 @@ public abstract class Model {
return modelToBeReturned;
}
+
public abstract boolean addResource(Resource resource);
public abstract boolean addWidget(Widget resource);
@@ -152,7 +151,6 @@ public abstract class Model {
* @return the model type
*/
public ModelType getModelType() {
- //checkSupported();
if (this instanceof Service) {
return ModelType.SERVICE;
} else if (this instanceof Resource) {
@@ -165,12 +163,10 @@ public abstract class Model {
}
public String getModelName() {
- //checkSupported();
return modelName;
}
public String getModelVersion() {
- //checkSupported();
return modelVersion;
}
@@ -180,7 +176,6 @@ public abstract class Model {
}
public String getModelDescription() {
- //checkSupported();
return modelDescription;
}
@@ -190,51 +185,49 @@ public abstract class Model {
* @param modelIdentInfo the model ident info
*/
public void populateModelIdentificationInformation(Map<String, String> modelIdentInfo) {
- Iterator<String> iter = modelIdentInfo.keySet().iterator();
- String property;
- while (iter.hasNext()) {
- switch (property = iter.next()) {
+ for (Map.Entry<String,String> entry : modelIdentInfo.entrySet()) {
+ String property=entry.getKey();
+ switch (property) {
case "vfModuleModelInvariantUUID":
case "serviceInvariantUUID":
case "resourceInvariantUUID":
case "invariantUUID":
case "providing_service_invariant_uuid":
- modelId = modelIdentInfo.get(property);
+ modelId = entry.getValue();
break;
case "vfModuleModelUUID":
case "resourceUUID":
case "serviceUUID":
case "UUID":
case "providing_service_uuid":
- modelNameVersionId = modelIdentInfo.get(property);
+ modelNameVersionId = entry.getValue();
break;
case "vfModuleModelVersion":
case "serviceVersion":
case "resourceversion":
case "version":
- modelVersion = modelIdentInfo.get(property);
+ modelVersion = entry.getValue();
break;
case "vfModuleModelName":
case "serviceName":
case "resourceName":
case "name":
- modelName = modelIdentInfo.get(property);
+ modelName = entry.getValue();
break;
case "serviceDescription":
case "resourceDescription":
case "vf_module_description":
case "description":
- modelDescription = modelIdentInfo.get(property);
+ modelDescription = entry.getValue();
break;
case "providing_service_name":
- modelName = modelIdentInfo.get(property);
- modelDescription = modelIdentInfo.get(property);
+ modelName = entry.getValue();
+ modelDescription = entry.getValue();
break;
default:
break;
}
- property = null;
}
@@ -249,11 +242,14 @@ public abstract class Model {
return widgets;
}
- private void checkSupported() throws IllegalAccessException {
+ private void checkSupported() {
if (this instanceof Widget) {
throw new IllegalAccessException(GeneratorConstants
.GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION);
}
}
+ private static boolean isModelNotSet(String toscaType, Model modelToBeReturned) {
+ return toscaType != null && toscaType.lastIndexOf(".") != -1 && modelToBeReturned == null;
+ }
}
diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-test/src/main/java/org/onap/sdc/generator/SampleJUnitTest.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-test/src/main/java/org/onap/sdc/generator/SampleJUnitTest.java
index 6b59e2ebfa..24946567b8 100644
--- a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-test/src/main/java/org/onap/sdc/generator/SampleJUnitTest.java
+++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-test/src/main/java/org/onap/sdc/generator/SampleJUnitTest.java
@@ -1555,14 +1555,15 @@ public class SampleJUnitTest extends TestCase {
public static void readPayload(List<Artifact> inputArtifacts,InputStream fis, String fileName) throws IOException {
byte[] payload = new byte[fis.available()];
- fis.read(payload);
- String checksum = GeneratorUtil.checkSum(payload);
- byte[] encodedPayload = GeneratorUtil.encode(payload);
- Artifact artifact = new Artifact(AAI_ARTIFACT_TYPE, AAI_ARTIFACT_GROUP_TYPE, checksum, encodedPayload);
- artifact.setName(fileName);
- artifact.setLabel(fileName);
- artifact.setDescription(fileName);
- inputArtifacts.add(artifact);
+ if (fis.read(payload) > 0) {
+ String checksum = GeneratorUtil.checkSum(payload);
+ byte[] encodedPayload = GeneratorUtil.encode(payload);
+ Artifact artifact = new Artifact(AAI_ARTIFACT_TYPE, AAI_ARTIFACT_GROUP_TYPE, checksum, encodedPayload);
+ artifact.setName(fileName);
+ artifact.setLabel(fileName);
+ artifact.setDescription(fileName);
+ inputArtifacts.add(artifact);
+ }
}