summaryrefslogtreecommitdiffstats
path: root/cps-service/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-04-19 12:40:01 +0300
committerRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-04-20 12:58:55 +0300
commit24bf350947acb7fcb62878932d520387bc922a96 (patch)
tree447c8ad367db6769c5e6bd66f85fcf059524999b /cps-service/src/test/groovy/org/onap
parent3da52076907385c8a42b817f7aceb65e0dcb7cdd (diff)
Create child data node (part 1): CPS service + REST
Issue-ID: CPS-337 Change-Id: I9c5c62d144b5301ac80e2b82a5cc66a980dad011 Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-service/src/test/groovy/org/onap')
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy20
1 files changed, 20 insertions, 0 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
index d561475273..29a2314a33 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
+ * Modifications Copyright (C) 2021 Pantheon.tech
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,6 +70,25 @@ class CpsDataServiceImplSpec extends Specification {
{ dataNode -> dataNode.xpath == '/test-tree' })
}
+ def 'Saving child data fragment under existing node.'() {
+ given: 'that the admin service will return an anchor'
+ def anchor = Anchor.builder().name(anchorName).schemaSetName(schemaSetName).build()
+ mockCpsAdminService.getAnchor(dataspaceName, anchorName) >> anchor
+ and: 'the schema source set cache returns a schema source set'
+ def mockYangTextSchemaSourceSet = Mock(YangTextSchemaSourceSet)
+ mockYangTextSchemaSourceSetCache.get(dataspaceName, schemaSetName) >> mockYangTextSchemaSourceSet
+ and: 'the schema source sets returns the test-tree schema context'
+ def yangResourceNameToContent = TestUtils.getYangResourcesAsMap('test-tree.yang')
+ def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getSchemaContext()
+ mockYangTextSchemaSourceSet.getSchemaContext() >> schemaContext
+ when: 'save data method is invoked with test-tree json data'
+ def jsonData = '{"branch": [{"name": "New"}]}'
+ objectUnderTest.saveData(dataspaceName, anchorName, '/test-tree',jsonData)
+ then: 'the persistence service method is invoked with correct parameters'
+ 1 * mockCpsDataPersistenceService.addChildDataNode(dataspaceName, anchorName,'/test-tree',
+ { dataNode -> dataNode.xpath == '/test-tree/branch[@name=\'New\']' })
+ }
+
@Unroll
def 'Get data node with option #fetchDescendantsOption.'() {
def xpath = '/xpath'