summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authorlukegleeson <luke.gleeson@est.tech>2023-02-23 14:08:10 +0000
committerlukegleeson <luke.gleeson@est.tech>2023-02-23 14:08:59 +0000
commit003de55a8e6c53643032731e68edc43c0698fd81 (patch)
tree426f55c257c2b7283004ffa69f2fef49c91e8cfb /cps-ncmp-service/src/test
parent60cff5c74886d5bd31657d292cc23ac45455b0d9 (diff)
Revert "Omit descendants when not need in ncmp inventory queries"
This reverts commit eba77598601a7e3430f9582dfe433495ded3244c. Signed-off-by: lukegleeson <luke.gleeson@est.tech> Change-Id: I76a0d1252177c4115de9190ee7f3bb6d15c4e19a
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy46
1 files changed, 9 insertions, 37 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy
index a918801c7e..5cd702a6b9 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceSpec.groovy
@@ -49,62 +49,34 @@ class NetworkCmProxyCmHandlerQueryServiceSpec extends Specification {
def objectUnderTest = new NetworkCmProxyCmHandlerQueryServiceImpl(cmHandleQueries, mockInventoryPersistence)
def objectUnderTestSpy = new NetworkCmProxyCmHandlerQueryServiceImpl(partiallyMockedCmHandleQueries, mockInventoryPersistence)
- def 'Retrieve cm handle objects with cpsPath when combined with no Module Query.'() {
+ def 'Retrieve cm handles with cpsPath when combined with no Module Query.'() {
given: 'a cmHandleWithCpsPath condition property'
def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']])
cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties])
- and: 'the query to get the cm handle datanodes including all descendants returns a datanode'
+ and: 'cmHandleQueries returns a non null query result'
cmHandleQueries.queryCmHandleDataNodesByCpsPath('/some/cps/path', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> [new DataNode(leaves: ['id':'some-cmhandle-id'])]
and: 'CmHandleQueries returns cmHandles with the relevant query result'
cmHandleQueries.combineCmHandleQueries(*_) >> ['PNFDemo1': new NcmpServiceCmHandle(cmHandleId: 'PNFDemo1'), 'PNFDemo3': new NcmpServiceCmHandle(cmHandleId: 'PNFDemo3')]
- when: 'the query is executed for cm handle details'
- def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
- then: 'the correct ncmp service cm handles are returned'
- returnedCmHandlesWithData.stream().map(CmHandle -> CmHandle.cmHandleId).collect(Collectors.toSet()) == ['PNFDemo1', 'PNFDemo3'] as Set
- }
-
- def 'Retrieve cm handle ids with cpsPath when combined with no Module Query.'() {
- given: 'a cmHandleWithCpsPath condition property'
- def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
- def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']])
- cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties])
- and: 'the query get the cm handle datanodes excluding all descendants returns a datanode'
- cmHandleQueries.queryCmHandleDataNodesByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> [new DataNode(leaves: ['id':'some-cmhandle-id'])]
- and: 'CmHandleQueries returns cmHandles with the relevant query result'
- cmHandleQueries.combineCmHandleQueries(*_) >> ['PNFDemo1': new NcmpServiceCmHandle(cmHandleId: 'PNFDemo1'), 'PNFDemo3': new NcmpServiceCmHandle(cmHandleId: 'PNFDemo3')]
- when: 'the query is executed for cm handle ids'
+ when: 'the query is executed for both cm handle ids and details'
def returnedCmHandlesJustIds = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
+ def returnedCmHandlesWithData = objectUnderTest.queryCmHandles(cmHandleQueryParameters)
then: 'the correct expected cm handles ids are returned'
returnedCmHandlesJustIds == ['PNFDemo1', 'PNFDemo3'] as Set
+ and: 'the correct ncmp service cm handles are returned'
+ returnedCmHandlesWithData.stream().map(CmHandle -> CmHandle.cmHandleId).collect(Collectors.toSet()) == ['PNFDemo1', 'PNFDemo3'] as Set
}
- def 'Retrieve cm handle details with cpsPath where #scenario.'() {
+ def 'Retrieve cm handles with cpsPath where #scenario.'() {
given: 'a cmHandleWithCpsPath condition property'
def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']])
cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties])
and: 'cmHandleQueries throws a path parsing exception'
cmHandleQueries.queryCmHandleDataNodesByCpsPath('/some/cps/path', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> { throw thrownException }
- when: 'the query is executed for cm handle details'
- objectUnderTest.queryCmHandles(cmHandleQueryParameters)
- then: 'a data validation exception is thrown'
- thrown(expectedException)
- where: 'the following data is used'
- scenario | thrownException || expectedException
- 'a PathParsingException is thrown' | new PathParsingException('some message', 'some details') || DataValidationException
- 'any other Exception is thrown' | new DataInUseException('some message', 'some details') || DataInUseException
- }
-
- def 'Retrieve cm handle ids with cpsPath where #scenario.'() {
- given: 'a cmHandleWithCpsPath condition property'
- def cmHandleQueryParameters = new CmHandleQueryServiceParameters()
- def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']])
- cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties])
- and: 'cmHandleQueries throws a path parsing exception'
- cmHandleQueries.queryCmHandleDataNodesByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> { throw thrownException }
- when: 'the query is executed for cm handle ids'
+ when: 'the query is executed for both cm handle ids and details'
objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
+ objectUnderTest.queryCmHandles(cmHandleQueryParameters)
then: 'a data validation exception is thrown'
thrown(expectedException)
where: 'the following data is used'