summaryrefslogtreecommitdiffstats
path: root/cps-service/src
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2022-12-13 11:08:25 +0000
committerGerrit Code Review <gerrit@onap.org>2022-12-13 11:08:25 +0000
commit3ded83809e65eec2ac673f157b03212472a29833 (patch)
tree1d74795500d26ba877ec2678210d61282dda4193 /cps-service/src
parent55469288c62a762b16b53e665d1fd496d6126dec (diff)
parenta4f4215c435414360f281b625705595be9367ace (diff)
Merge "Fixing SonarQube violations"
Diffstat (limited to 'cps-service/src')
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java3
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java14
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy2
4 files changed, 12 insertions, 9 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java
index 8d4df20b81..28b18b3b5c 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java
@@ -22,6 +22,7 @@
package org.onap.cps.spi;
+import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -97,7 +98,7 @@ public interface CpsDataPersistenceService {
* @param xpath xpath
* @param leaves the leaves as a map where key is a leaf name and a value is a leaf value
*/
- void updateDataLeaves(String dataspaceName, String anchorName, String xpath, Map<String, Object> leaves);
+ void updateDataLeaves(String dataspaceName, String anchorName, String xpath, Map<String, Serializable> leaves);
/**
* Replaces an existing data node's content including descendants.
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
index 8170db3dad..76f33bbc14 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
@@ -46,7 +46,7 @@ public class DataNode implements Serializable {
private ModuleReference moduleReference;
private String xpath;
private String moduleNamePrefix;
- private Map<String, Object> leaves = Collections.emptyMap();
+ private Map<String, Serializable> leaves = Collections.emptyMap();
private Collection<String> xpathsChildren;
private Collection<DataNode> childDataNodes = Collections.emptySet();
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
index af820def0c..1d8bac0dde 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
@@ -23,6 +23,7 @@ package org.onap.cps.spi.model;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -49,7 +50,7 @@ public class DataNodeBuilder {
private String xpath;
private String moduleNamePrefix;
private String parentNodeXpath = "";
- private Map<String, Object> leaves = Collections.emptyMap();
+ private Map<String, Serializable> leaves = Collections.emptyMap();
private Collection<DataNode> childDataNodes = Collections.emptySet();
/**
@@ -103,7 +104,7 @@ public class DataNodeBuilder {
* @param leaves for the data node
* @return DataNodeBuilder
*/
- public DataNodeBuilder withLeaves(final Map<String, Object> leaves) {
+ public DataNodeBuilder withLeaves(final Map<String, Serializable> leaves) {
this.leaves = leaves;
return this;
}
@@ -183,7 +184,7 @@ public class DataNodeBuilder {
} else if (normalizedNode instanceof ValueNode) {
final ValueNode<NormalizedNode> valuesNode = (ValueNode) normalizedNode;
addYangLeaf(currentDataNode, valuesNode.getIdentifier().getNodeType().getLocalName(),
- valuesNode.body());
+ (Serializable) valuesNode.body());
} else if (normalizedNode instanceof LeafSetNode) {
addYangLeafList(currentDataNode, (LeafSetNode<?>) normalizedNode);
} else {
@@ -202,8 +203,9 @@ public class DataNodeBuilder {
}
}
- private static void addYangLeaf(final DataNode currentDataNode, final String leafName, final Object leafValue) {
- final Map<String, Object> leaves = new ImmutableMap.Builder<String, Object>()
+ private static void addYangLeaf(final DataNode currentDataNode, final String leafName,
+ final Serializable leafValue) {
+ final Map<String, Serializable> leaves = new ImmutableMap.Builder<String, Serializable>()
.putAll(currentDataNode.getLeaves())
.put(leafName, leafValue)
.build();
@@ -216,7 +218,7 @@ public class DataNodeBuilder {
.stream()
.map(normalizedNode -> (normalizedNode).body())
.collect(Collectors.toUnmodifiableList());
- addYangLeaf(currentDataNode, leafListName, leafListValues);
+ addYangLeaf(currentDataNode, leafListName, (Serializable) leafListValues);
}
private static void addDataNodeForEachListElement(final DataNode currentDataNode, final MapNode mapNode) {
diff --git a/cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy
index a58504ff40..e46147c04d 100644
--- a/cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy
@@ -32,7 +32,7 @@ import spock.lang.Specification
class DataNodeBuilderSpec extends Specification {
- Map<String, Map<String, Object>> expectedLeavesByXpathMap = [
+ Map<String, Map<String, Serializable>> expectedLeavesByXpathMap = [
'/test-tree' : [],
'/test-tree/branch[@name=\'Left\']' : [name: 'Left'],
'/test-tree/branch[@name=\'Left\']/nest' : [name: 'Small', birds: ['Sparrow', 'Robin', 'Finch']],