aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authorseanbeirne <sean.beirne@est.tech>2023-02-10 16:42:38 +0000
committerseanbeirne <sean.beirne@est.tech>2023-02-14 15:22:40 +0000
commitc006702473c605450801b353d0c97e99968eced1 (patch)
treeb513479745ba34e87a497c393a6b3672329fdb90 /cps-ncmp-service/src/test
parentdb90c8758d43b1daab09c760a3fe3102d772d7df (diff)
Use getDataNodes (plural version) into NCMP to get CM handles Performance improvement
- Code clean-up on existing classes - Removed duplicate code Issue-ID: CPS-1426 Signed-off-by: seanbeirne <sean.beirne@est.tech> Change-Id: I3e2ce5b804d7a6e87838490d970cde3cd563f06b
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);
}
}