summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaty.rotman <katy.rotman@amdocs.com>2018-05-24 14:09:26 +0300
committerOren Kleks <orenkle@amdocs.com>2018-05-28 08:15:19 +0000
commit6c72be9effaeff9f2b6dbc843b2d4d1ec1b60b1b (patch)
treec12f52038556398175f7a4ee64a821aa44659644
parentd981ef67e956f1e5a28ca77f2841f49e468c5b1b (diff)
fixing sonar violations
Issue-ID: SDC-1363 Change-Id: I29b8df69d49d6ca0ba953b362f7574213e931183 Signed-off-by: katy.rotman <katy.rotman@amdocs.com>
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java26
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java2
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityFilter.java11
3 files changed, 20 insertions, 19 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
index 5a8aa7e1d5..8c9c63af03 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
@@ -47,12 +47,15 @@ public class InterfacesOperationsToscaUtil {
private static final String OPERATIONS_KEY = "operations";
private static final String DEFAULT = "default";
- private static final String _DEFAULT = "_default";
+ private static final String DEFAULT_HAS_UNDERSCORE = "_default";
private static final String DOT = ".";
private static final String DEFAULT_INPUT_TYPE = "string";
private static final String SELF = "SELF";
private static final String GET_PROPERTY = "get_property";
- public static final String DEFAULTP = "defaultp";
+ private static final String DEFAULTP = "defaultp";
+
+ private InterfacesOperationsToscaUtil() {
+ }
/**
* Creates the interface_types element
@@ -67,7 +70,7 @@ public class InterfacesOperationsToscaUtil {
}
final Map<String, InterfaceDefinition> interfaces = ((Resource) component).getInterfaces();
- if ( MapUtils.isEmpty(interfaces)) {
+ if (MapUtils.isEmpty(interfaces)) {
return null;
}
@@ -78,8 +81,8 @@ public class InterfacesOperationsToscaUtil {
final Map<String, OperationDataDefinition> operations = interfaceDefinition.getOperations();
Map<String, Object> toscaOperations = new HashMap<>();
- for (String operationId : operations.keySet()) {
- toscaOperations.put(operations.get(operationId).getName(),
+ for (Map.Entry<String, OperationDataDefinition> operationEntry : operations.entrySet()) {
+ toscaOperations.put(operationEntry.getValue().getName(),
null); //currently not initializing any of the operations' fields as it is not needed
}
@@ -108,7 +111,7 @@ public class InterfacesOperationsToscaUtil {
}
final Map<String, InterfaceDefinition> interfaces = ((Resource) component).getInterfaces();
- if ( MapUtils.isEmpty(interfaces)) {
+ if (MapUtils.isEmpty(interfaces)) {
return;
}
for (InterfaceDefinition interfaceDefinition : interfaces.values()) {
@@ -150,23 +153,21 @@ public class InterfacesOperationsToscaUtil {
* @param operationsMap the map to update
*/
private static void handleDefaults(Map<String, Object> operationsMap) {
- for (String key : operationsMap.keySet()) {
- Object value = operationsMap.get(key);
+ for (Map.Entry<String, Object> operationEntry : operationsMap.entrySet()) {
+ final Object value = operationEntry.getValue();
if (value instanceof Map) {
handleDefaults((Map<String, Object>) value);
}
+ final String key = operationEntry.getKey();
if (key.equals(DEFAULTP)) {
Object removed = operationsMap.remove(key);
operationsMap.put(DEFAULT, removed);
}
}
-
-
}
private static String getLastPartOfName(String toscaResourceName) {
return toscaResourceName.substring(toscaResourceName.lastIndexOf(DOT) + 1);
-
}
private static boolean isArtifactPresent(Map.Entry<String, OperationDataDefinition> operationEntry) {
@@ -215,9 +216,8 @@ public class InterfacesOperationsToscaUtil {
if (objectAsMap.containsKey(DEFAULT)) {
Object defaultValue = objectAsMap.get(DEFAULT);
objectAsMap.remove(DEFAULT);
- objectAsMap.put(_DEFAULT, defaultValue);
+ objectAsMap.put(DEFAULT_HAS_UNDERSCORE, defaultValue);
}
return objectAsMap;
}
-
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java
index 57fe098972..67b27f678f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java
@@ -43,7 +43,7 @@ import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
public class InterfacesOperationsToscaUtilTest {
@BeforeClass
- public static void setUp() throws Exception {
+ public static void setUp() {
new DummyConfigurationManager();
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityFilter.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityFilter.java
index 0453325aa2..ce0391d62d 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityFilter.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityFilter.java
@@ -26,7 +26,7 @@ import java.util.Map;
public class CapabilityFilter {
- List<Map<String, List<Constraint>>> properties;
+ private List<Map<String, List<Constraint>>> properties;
public List<Map<String, List<Constraint>>> getProperties() {
return properties;
@@ -38,9 +38,10 @@ public class CapabilityFilter {
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("CapabilityFilter{");
- sb.append("properties=").append(properties);
- sb.append('}');
- return sb.toString();
+ return "CapabilityFilter{" + "properties=" + properties + '}';
+ }
+
+ public CapabilityFilter() {
+ //default constructor
}
}