summaryrefslogtreecommitdiffstats
path: root/cps-service/src/test
diff options
context:
space:
mode:
authorArpit Singh <as00745003@techmahindra.com>2023-07-27 14:48:30 +0530
committerArpit Singh <as00745003@techmahindra.com>2023-07-27 15:25:59 +0530
commit61f5e14c5cdebe659dfae0c7143a07d6f81cb06c (patch)
treea3c7d0f9b0b82c7bf295436ba9d3cd3242ea09c0 /cps-service/src/test
parentf1a506a235abe624704cfdd17aadbfe1760c4c04 (diff)
Fix: Make bookstore data consistent
- Removed list named invoice from all bookstore files - Added a new parent list as bookstore-address - Refactored tests Issue-ID: CPS-1813 Signed-off-by: Arpit Singh <as00745003@techmahindra.com> Change-Id: I5c7e83e1ee0ad9ac1d94d1906c2361c7a00d49af
Diffstat (limited to 'cps-service/src/test')
-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
3 files changed, 16 insertions, 26 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";
}
}