summaryrefslogtreecommitdiffstats
path: root/cps-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service/src')
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java27
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/YangUtils.java3
-rwxr-xr-xcps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy10
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy14
-rw-r--r--cps-service/src/test/resources/test-tree.json8
-rw-r--r--cps-service/src/test/resources/test-tree.yang12
6 files changed, 61 insertions, 13 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java b/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java
new file mode 100644
index 000000000..3a8a94b97
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (c) 2021 Bell Canada.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.spi.exceptions;
+
+public class ConcurrencyException extends CpsException {
+
+ public ConcurrencyException(final String message, final String details, final Throwable cause) {
+ super(message, details, cause);
+ }
+
+}
diff --git a/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java b/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
index e6c49ac8b..8c32010d7 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
@@ -44,6 +44,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@Slf4j
@@ -83,7 +84,7 @@ public class YangUtils {
private static NormalizedNode<?, ?> parseJsonData(final String jsonData, final SchemaContext schemaContext,
final Optional<DataSchemaNode> optionalParentSchemaNode) {
final var jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02
- .getShared(schemaContext);
+ .getShared((EffectiveModelContext) schemaContext);
final var normalizedNodeResult = new NormalizedNodeResult();
final var normalizedNodeStreamWriter = ImmutableNormalizedNodeStreamWriter
.from(normalizedNodeResult);
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
index 532f44203..be213c0fa 100755
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
@@ -35,16 +35,16 @@ class CpsAdminServiceImplSpec extends Specification {
}
def 'Create dataspace method invokes persistence service.'() {
- when: 'Create dataspace method is invoked'
+ when: 'create dataspace method is invoked'
objectUnderTest.createDataspace('someDataspace')
- then: 'The persistence service method is invoked with same parameters'
+ then: 'the persistence service method is invoked with same parameters'
1 * mockCpsAdminPersistenceService.createDataspace('someDataspace')
}
def 'Create anchor method invokes persistence service.'() {
- when: 'Create anchor method is invoked'
+ when: 'create anchor method is invoked'
objectUnderTest.createAnchor('someDataspace', 'someSchemaSet', 'someAnchorName')
- then: 'The persistence service method is invoked with same parameters'
+ then: 'the persistence service method is invoked with same parameters'
1 * mockCpsAdminPersistenceService.createAnchor('someDataspace', 'someSchemaSet', 'someAnchorName')
}
@@ -61,7 +61,7 @@ class CpsAdminServiceImplSpec extends Specification {
Anchor anchor = new Anchor()
mockCpsAdminPersistenceService.getAnchor('someDataspace','someAnchor') >> anchor
expect: 'the anchor provided by persistence service is returned as result'
- objectUnderTest.getAnchor('someDataspace','someAnchor') == anchor
+ assert objectUnderTest.getAnchor('someDataspace','someAnchor') == anchor
}
def 'Delete anchor.'() {
diff --git a/cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy
index 7f50f7f52..2751d5507 100644
--- a/cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,11 +29,12 @@ import spock.lang.Specification
class DataNodeBuilderSpec extends Specification {
Map<String, Map<String, Object>> expectedLeavesByXpathMap = [
- '/test-tree' : [],
- '/test-tree/branch[@name=\'Left\']' : [name: 'Left'],
- '/test-tree/branch[@name=\'Left\']/nest' : [name: 'Small', birds: ['Sparrow', 'Robin', 'Finch']],
- '/test-tree/branch[@name=\'Right\']' : [name: 'Right'],
- '/test-tree/branch[@name=\'Right\']/nest': [name: 'Big', birds: ['Owl', 'Raven', 'Crow']]
+ '/test-tree' : [],
+ '/test-tree/branch[@name=\'Left\']' : [name: 'Left'],
+ '/test-tree/branch[@name=\'Left\']/nest' : [name: 'Small', birds: ['Sparrow', 'Robin', 'Finch']],
+ '/test-tree/branch[@name=\'Right\']' : [name: 'Right'],
+ '/test-tree/branch[@name=\'Right\']/nest' : [name: 'Big', birds: ['Owl', 'Raven', 'Crow']],
+ '/test-tree/fruit[@color=\'Green\' and @name=\'Apple\']': [color: 'Green', name: 'Apple']
]
String[] networkTopologyModelRfc8345 = [
@@ -55,7 +57,7 @@ class DataNodeBuilderSpec extends Specification {
def result = new DataNodeBuilder().withNormalizedNodeTree(normalizedNode).build()
def mappedResult = TestUtils.getFlattenMapByXpath(result)
then: '5 DataNode objects with unique xpath were created in total'
- mappedResult.size() == 5
+ mappedResult.size() == 6
and: 'all expected xpaths were built'
mappedResult.keySet().containsAll(expectedLeavesByXpathMap.keySet())
and: 'each data node contains the expected attributes'
diff --git a/cps-service/src/test/resources/test-tree.json b/cps-service/src/test/resources/test-tree.json
index bc9cbd7ce..e1789abc1 100644
--- a/cps-service/src/test/resources/test-tree.json
+++ b/cps-service/src/test/resources/test-tree.json
@@ -23,6 +23,12 @@
]
}
}
+ ],
+ "fruit": [
+ {
+ "name": "Apple",
+ "color": "Green"
+ }
]
}
-} \ No newline at end of file
+}
diff --git a/cps-service/src/test/resources/test-tree.yang b/cps-service/src/test/resources/test-tree.yang
index faba8a11d..63100657e 100644
--- a/cps-service/src/test/resources/test-tree.yang
+++ b/cps-service/src/test/resources/test-tree.yang
@@ -20,5 +20,17 @@ module test-tree {
}
}
}
+ list fruit {
+ key "name color";
+
+ leaf name {
+ type string;
+ }
+
+ leaf color {
+ type string;
+ }
+
+ }
}
}