diff options
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/YangDataConverterSpec.groovy | 26 |
1 files changed, 14 insertions, 12 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 dd673eb8f..6d733dc47 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']) } - } |