diff options
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImplSpec.groovy')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImplSpec.groovy | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImplSpec.groovy index 752b9f3ec..2800f5c24 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImplSpec.groovy @@ -37,10 +37,13 @@ class CmHandleQueriesImplSpec extends Specification { @Shared def static sampleDataNodes = [new DataNode()] + def dataNodeWithPrivateField = '//additional-properties[@name=\"Contact3\" and @value=\"newemailforstore3@bookstore.com\"]/ancestor::cm-handles' + def static pnfDemo = createDataNode('PNFDemo') def static pnfDemo2 = createDataNode('PNFDemo2') def static pnfDemo3 = createDataNode('PNFDemo3') def static pnfDemo4 = createDataNode('PNFDemo4') + def static pnfDemo5 = createDataNode('PNFDemo5') def static pnfDemoCmHandle = new NcmpServiceCmHandle(cmHandleId: 'PNFDemo') def static pnfDemo2CmHandle = new NcmpServiceCmHandle(cmHandleId: 'PNFDemo2') @@ -69,6 +72,22 @@ class CmHandleQueriesImplSpec extends Specification { returnedCmHandlesWithData.keySet().size() == 0 } + def 'Query CmHandles using empty private properties query pair.'() { + when: 'a query on CmHandle private properties is executed using an empty map' + def returnedCmHandlesWithData = objectUnderTest.queryCmHandleAdditionalProperties([:]) + then: 'no cm handles are returned' + returnedCmHandlesWithData.keySet().size() == 0 + } + + def 'Query CmHandles by a private field\'s value.'() { + given: 'a data node exists with a certain additional-property' + cpsDataPersistenceService.queryDataNodes(_, _, dataNodeWithPrivateField, _) >> [pnfDemo5] + when: 'a query on CmHandle private properties is executed using a map' + def returnedCmHandlesWithData = objectUnderTest.queryCmHandleAdditionalProperties(['Contact3': 'newemailforstore3@bookstore.com']) + then: 'one cm handle is returned' + returnedCmHandlesWithData.keySet().size() == 1 + } + def 'Combine two query results where #scenario.'() { when: 'two query results in the form of a map of NcmpServiceCmHandles are combined into a single query result' def result = objectUnderTest.combineCmHandleQueries(firstQuery, secondQuery) @@ -85,7 +104,7 @@ class CmHandleQueriesImplSpec extends Specification { 'both queries are null' | null | null || null } - def 'Get Cm Handles By State'() { + def 'Get CmHandles by it\'s state.'() { given: 'a cm handle state to query' def cmHandleState = CmHandleState.ADVISED and: 'the persistence service returns a list of data nodes' @@ -97,6 +116,22 @@ class CmHandleQueriesImplSpec extends Specification { assert result == sampleDataNodes } + def 'Check the state of a cmHandle when #scenario.'() { + given: 'a cm handle state to compare' + def cmHandleState = state + and: 'the persistence service returns a list of data nodes' + cpsDataPersistenceService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry', + '/dmi-registry/cm-handles[@id=\'some-cm-handle\']/state', OMIT_DESCENDANTS) >> new DataNode(leaves: ['cm-handle-state': 'READY']) + when: 'cm handles are compared by state' + def result = objectUnderTest.cmHandleHasState('some-cm-handle', cmHandleState) + then: 'the returned result matches the expected result from the persistence service' + result == expectedResult + where: + scenario | state || expectedResult + 'the provided state matches' | CmHandleState.READY || true + 'the provided state does not match'| CmHandleState.DELETED || false + } + def 'Get Cm Handles state by Cm-Handle Id'() { given: 'a cm handle state to query' def cmHandleState = CmHandleState.READY |