summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2023-02-15 10:52:19 +0000
committerGerrit Code Review <gerrit@onap.org>2023-02-15 10:52:19 +0000
commit9575b84ab4e2db885d8761a98eaae9ff3a06aa81 (patch)
tree86c2d2952a9847ddf6db444d72c74d05f5c534b2 /cps-ncmp-service/src/test
parentb2c8bc6b9bfd502be01e524c24628fcd10b1e177 (diff)
parentc006702473c605450801b353d0c97e99968eced1 (diff)
Merge "Use getDataNodes (plural version) into NCMP to get CM handles Performance improvement"
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy26
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy11
2 files changed, 15 insertions, 22 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy
index dd673eb8f8..6d733dc475 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START========================================================
- * Copyright (C) 2022 Nordix Foundation
+ * Copyright (C) 2022-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,31 +25,33 @@ import spock.lang.Specification
class YangDataConverterSpec extends Specification{
- def 'Convert a cm handle data node with private properties.'() {
- given: 'a datanode with some additional (dmi, private) properties'
+ def 'Convert a cm handle data node with private and public properties.'() {
+ given: 'a datanode with some additional (dmi, private) and public properties'
def dataNodeAdditionalProperties = new DataNode(xpath:'/additional-properties[@name="dmiProp1"]',
- leaves: ['name': 'dmiProp1', 'value': 'dmiValue1'])
- def dataNode = new DataNode(childDataNodes:[dataNodeAdditionalProperties])
+ leaves: ['name': 'dmiProp1', 'value': 'dmiValue1'])
+ def dataNodePublicProperties = new DataNode(xpath:'/public-properties[@name="pubProp1"]',
+ leaves: ['name': 'pubProp1', 'value': 'pubValue1'])
+ def dataNodeCmHandle = new DataNode(childDataNodes:[dataNodeAdditionalProperties, dataNodePublicProperties])
when: 'the dataNode is converted'
- def yangModelCmHandle = YangDataConverter.convertCmHandleToYangModel(dataNode,'sample-id')
+ def yangModelCmHandle = YangDataConverter.convertCmHandleToYangModel(dataNodeCmHandle,'sample-id')
then: 'the converted object has the correct id'
assert yangModelCmHandle.id == 'sample-id'
and: 'the additional (dmi, private) properties are included'
assert yangModelCmHandle.dmiProperties[0].name == 'dmiProp1'
assert yangModelCmHandle.dmiProperties[0].value == 'dmiValue1'
+ and: 'the public properties are included'
+ assert yangModelCmHandle.publicProperties[0].name == 'pubProp1'
+ assert yangModelCmHandle.publicProperties[0].value == 'pubValue1'
}
def 'Convert multiple cm handle data nodes'(){
- given: 'two data nodes in a collection one with private properties'
- def dataNodeAdditionalProperties = new DataNode(xpath:'/additional-properties[@name="dmiProp1"]',
- leaves: ['name': 'dmiProp1', 'value': 'dmiValue1'])
+ given: 'two data nodes in a collection'
def dataNodes = [new DataNode(xpath:'/dmi-registry/cm-handles[@id=\'some-cm-handle\']'),
- new DataNode(xpath:'/dmi-registry/cm-handles[@id=\'another-cm-handle\']', childDataNodes:[dataNodeAdditionalProperties])]
+ new DataNode(xpath:'/dmi-registry/cm-handles[@id=\'another-cm-handle\']')]
when: 'the data nodes are converted'
def yangModelCmHandles = YangDataConverter.convertDataNodesToYangModelCmHandles(dataNodes)
- then: 'verify both have returned and cmhandleIds are correct'
+ then: 'verify both have returned and CmHandleIds are correct'
assert yangModelCmHandles.size() == 2
assert yangModelCmHandles.id.containsAll(['some-cm-handle', 'another-cm-handle'])
}
-
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
index 93e79f6824..929ea84e36 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
@@ -134,15 +134,6 @@ class InventoryPersistenceImplSpec extends Specification {
assert results.id.containsAll([cmHandleId, cmHandleId2])
}
- def "Handling name validation errors in getYangModelCmHandles."() {
- given: 'the cps data service returns one of two data nodes from the DMI registry with empty leaf attributes'
- mockCpsValidator.validateNameCharacters(cmHandleId) >> {throw new DataValidationException('some message', 'some detail')}
- when:
- objectUnderTest.getYangModelCmHandle(cmHandleId)
- then: 'exception is thrown'
- thrown(DataValidationException)
- }
-
def 'Get a Cm Handle Composite State'() {
given: 'a valid cm handle id'
def cmHandleId = 'Some-Cm-Handle'
@@ -300,7 +291,7 @@ class InventoryPersistenceImplSpec extends Specification {
objectUnderTest.deleteDataNodes(['xpath1', 'xpath2'])
then: 'the cps data service method to delete data nodes is invoked once with the same xPaths'
1 * mockCpsDataService.deleteDataNodes('NCMP-Admin', 'ncmp-dmi-registry',
- ['xpath1', 'xpath2'], NO_TIMESTAMP);
+ ['xpath1', 'xpath2'], NO_TIMESTAMP);
}
}