summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy4
-rw-r--r--cps-service/src/test/resources/bookstore.json9
-rw-r--r--cps-service/src/test/resources/bookstore.yang29
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy6
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstore.yang29
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstoreData.json9
6 files changed, 33 insertions, 53 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 ba438496fd..9d241f1bde 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
@@ -114,7 +114,7 @@ class CpsDataServiceImplSpec extends Specification {
given: 'schema set for given anchor and dataspace references bookstore model'
setupSchemaSetMocks('bookstore.yang')
when: 'save data method is invoked with list element json data'
- def jsonData = '{"multiple-data-tree:invoice": [{"ProductID": "2","ProductName": "Banana","price": "100","stock": True}]}'
+ def jsonData = '{"bookstore-address":[{"bookstore-name":"Easons","address":"Dublin,Ireland","postal-code":"D02HA21"}]}'
objectUnderTest.saveListElements(dataspaceName, anchorName, '/', jsonData, observedTimestamp)
then: 'the persistence service method is invoked with correct parameters'
1 * mockCpsDataPersistenceService.storeDataNodes(dataspaceName, anchorName,
@@ -122,7 +122,7 @@ class CpsDataServiceImplSpec extends Specification {
{
assert dataNodeCollection.size() == 1
assert dataNodeCollection.collect { it.getXpath() }
- .containsAll(['/invoice[@ProductID=\'2\']'])
+ .containsAll(['/bookstore-address[@bookstore-name=\'Easons\']'])
}
}
)
diff --git a/cps-service/src/test/resources/bookstore.json b/cps-service/src/test/resources/bookstore.json
index 4b8ed3dab1..c5fd0fffdc 100644
--- a/cps-service/src/test/resources/bookstore.json
+++ b/cps-service/src/test/resources/bookstore.json
@@ -1,10 +1,9 @@
{
- "multiple-data-tree:invoice": [
+ "bookstore-address": [
{
- "ProductID": "1",
- "ProductName": "Apple",
- "price": "100",
- "stock": false
+ "bookstore-name": "Easons",
+ "address": "Dublin,Ireland",
+ "postal-code": "D02HA21"
}
],
"test:bookstore":{
diff --git a/cps-service/src/test/resources/bookstore.yang b/cps-service/src/test/resources/bookstore.yang
index b7a52e2c8c..2033fc7031 100644
--- a/cps-service/src/test/resources/bookstore.yang
+++ b/cps-service/src/test/resources/bookstore.yang
@@ -15,31 +15,22 @@ module stores {
}
}
- list invoice {
- key "ProductID";
- leaf ProductID {
- type uint64;
- mandatory "true";
- description
- "Unique product ID. Example: 001";
- }
- leaf ProductName {
+ list bookstore-address {
+ key "bookstore-name";
+ leaf bookstore-name {
type string;
- mandatory "true";
description
- "Name of the Product";
+ "Name of bookstore. Example: My Bookstore";
}
- leaf price {
- type uint64;
- mandatory "true";
+ leaf address {
+ type string;
description
- "Price of book";
+ "Address of store";
}
- leaf stock {
- type boolean;
- default "false";
+ leaf postal-code {
+ type string;
description
- "Book in stock or not. Example value: true";
+ "Postal code of store";
}
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy
index a3f14397c2..7c257adda6 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy
@@ -183,15 +183,15 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
def 'Add and Delete top-level list (element) data nodes with root node.'() {
given: 'a new (multiple-data-tree:invoice) datanodes'
- def json = '{"multiple-data-tree:invoice": [{"ProductID": "2","ProductName": "Mango","price": "150","stock": true}]}'
+ def json = '{"bookstore-address":[{"bookstore-name":"Scholastic","address":"Bangalore,India","postal-code":"560043"}]}'
when: 'the new list elements are saved'
objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/', json, now)
then: 'they can be retrieved by their xpaths'
- objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/invoice[@ProductID ="2"]', INCLUDE_ALL_DESCENDANTS)
+ objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore-address[@bookstore-name="Easons"]', INCLUDE_ALL_DESCENDANTS)
and: 'there is one extra datanode'
assert originalCountBookstoreTopLevelListNodes + 1 == countTopLevelListDataNodesInBookstore()
when: 'the new elements are deleted'
- objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/invoice[@ProductID ="2"]', now)
+ objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore-address[@bookstore-name="Easons"]', now)
then: 'the original number of datanodes is restored'
assert originalCountBookstoreTopLevelListNodes == countTopLevelListDataNodesInBookstore()
}
diff --git a/integration-test/src/test/resources/data/bookstore/bookstore.yang b/integration-test/src/test/resources/data/bookstore/bookstore.yang
index ab384de1c4..6f60f1981c 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstore.yang
+++ b/integration-test/src/test/resources/data/bookstore/bookstore.yang
@@ -15,31 +15,22 @@ module stores {
}
}
- list invoice {
- key "ProductID";
- leaf ProductID {
- type uint64;
- mandatory "true";
- description
- "Unique product ID. Example: 001";
- }
- leaf ProductName {
+ list bookstore-address {
+ key "bookstore-name";
+ leaf bookstore-name {
type string;
- mandatory "true";
description
- "Name of the Product";
+ "Name of bookstore. Example: My Bookstore";
}
- leaf price {
- type uint64;
- mandatory "true";
+ leaf address {
+ type string;
description
- "Price of book";
+ "Address of store";
}
- leaf stock {
- type boolean;
- default "false";
+ leaf postal-code {
+ type string;
description
- "Book in stock or not. Example value: true";
+ "Postal code of store";
}
}
diff --git a/integration-test/src/test/resources/data/bookstore/bookstoreData.json b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
index 5f66a1d002..418acf8ef8 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstoreData.json
+++ b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
@@ -1,10 +1,9 @@
{
- "multiple-data-tree:invoice": [
+ "bookstore-address": [
{
- "ProductID": "1",
- "ProductName": "Apple",
- "price": "100",
- "stock": false
+ "bookstore-name": "Easons",
+ "address": "Dublin,Ireland",
+ "postal-code": "D02HA21"
}
],
"bookstore": {