X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2Foperations%2FYangModelCmHandleRetrieverSpec.groovy;h=7fbfa779dc5b3ed952b726b1261298af313df060;hb=7f298238337e4f88952a2c0938fee9c34cea5fdd;hp=5ecc8b0da376ea5466224663ab051f38f8e8e7b9;hpb=4cf4962b74765a5afe234aa258a9143ea6936f73;p=cps.git diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy index 5ecc8b0da..7fbfa779d 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy @@ -22,6 +22,8 @@ package org.onap.cps.ncmp.api.impl.operations import org.onap.cps.api.CpsDataService import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle +import org.onap.cps.ncmp.api.inventory.CmHandleState +import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder import org.onap.cps.spi.exceptions.DataValidationException import spock.lang.Shared @@ -39,6 +41,9 @@ class YangModelCmHandleRetrieverSpec extends Specification { def leaves = ["dmi-service-name":"common service name","dmi-data-service-name":"data service name","dmi-model-service-name":"model service name"] def xpath = "/dmi-registry/cm-handles[@id='some-cm-handle']" + @Shared + def compositeState = new CompositeStateBuilder().withCmHandleState(CmHandleState.ADVISED).build() + @Shared def childDataNodesForCmHandleWithAllProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/additional-properties[@name='name1']", leaves: ["name":"name1", "value":"value1"]), new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/public-properties[@name='name2']", leaves: ["name":"name2","value":"value2"])] @@ -49,6 +54,9 @@ class YangModelCmHandleRetrieverSpec extends Specification { @Shared def childDataNodesForCmHandleWithPublicProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some-cm-handle']/public-properties[@name='name2']", leaves: ["name":"name2","value":"value2"])] + @Shared + def childDataNodesForCmHandleWithState = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some-cm-handle']/state", leaves: ['cm-handle-state': 'ADVISED'])] + def "Retrieve CmHandle using datanode with #scenario."() { given: 'the cps data service returns a data node from the DMI registry' def dataNode = new DataNode(childDataNodes:childDataNodes, leaves: leaves) @@ -63,12 +71,15 @@ class YangModelCmHandleRetrieverSpec extends Specification { and: 'the expected DMI properties' result.dmiProperties == expectedDmiProperties result.publicProperties == expectedPublicProperties + and: 'the state details are returned' + result.compositeState.cmhandleState == expectedCompositeState where: 'the following parameters are used' - scenario | childDataNodes || expectedDmiProperties || expectedPublicProperties - 'no properties' | [] || [] || [] - 'DMI and public properties' | childDataNodesForCmHandleWithAllProperties || [new YangModelCmHandle.Property("name1", "value1")] || [new YangModelCmHandle.Property("name2", "value2")] - 'just DMI properties' | childDataNodesForCmHandleWithDMIProperties || [new YangModelCmHandle.Property("name1", "value1")] || [] - 'just public properties' | childDataNodesForCmHandleWithPublicProperties || [] || [new YangModelCmHandle.Property("name2", "value2")] + scenario | childDataNodes || expectedDmiProperties || expectedPublicProperties || expectedCompositeState + 'no properties' | [] || [] || [] || null + 'DMI and public properties' | childDataNodesForCmHandleWithAllProperties || [new YangModelCmHandle.Property("name1", "value1")] || [new YangModelCmHandle.Property("name2", "value2")] || null + 'just DMI properties' | childDataNodesForCmHandleWithDMIProperties || [new YangModelCmHandle.Property("name1", "value1")] || [] || null + 'just public properties' | childDataNodesForCmHandleWithPublicProperties || [] || [new YangModelCmHandle.Property("name2", "value2")] || null + 'with state details' | childDataNodesForCmHandleWithState || [] || [] || CmHandleState.ADVISED } def "Retrieve CmHandle using datanode with invalid CmHandle id."() {