class NetworkCmProxyCmHandleQueryServiceSpec extends Specification {
def cmHandleQueries = Mock(CmHandleQueries)
- def partiallyMockedCmHandleQueries = Spy(CmHandleQueriesImpl)
+ def partiallyMockedCmHandleQueries = Spy(CmHandleQueries)
def mockInventoryPersistence = Mock(InventoryPersistence)
def dmiRegistry = new DataNode(xpath: NCMP_DMI_REGISTRY_PARENT, childDataNodes: createDataNodeList(['PNFDemo1', 'PNFDemo2', 'PNFDemo3', 'PNFDemo4']))
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'])]
+ cmHandleQueries.queryCmHandleAncestorsByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> [new DataNode(leaves: ['id':'some-cmhandle-id'])]
when: 'the query is executed for cm handle ids'
def result = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
then: 'the correct expected cm handles ids are returned'
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 }
+ cmHandleQueries.queryCmHandleAncestorsByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> { throw thrownException }
when: 'the query is executed for cm handle ids'
objectUnderTest.queryCmHandleIds(cmHandleQueryParameters)
then: 'a data validation exception is thrown'
'No anchors are returned' | []
}
+ def 'Query cm handles with some trust level query parameters'() {
+ given: 'a trust level condition property'
+ def trustLevelQueryParameters = new CmHandleQueryServiceParameters()
+ def trustLevelConditionProperties = createConditionProperties('cmHandleWithTrustLevel', [['trustLevel': 'COMPLETE'] as Map])
+ trustLevelQueryParameters.setCmHandleQueryParameters([trustLevelConditionProperties])
+ when: 'the query is being executed'
+ objectUnderTest.queryCmHandleIds(trustLevelQueryParameters)
+ then: 'the query is being delegated to the cm handle query service with correct parameter'
+ 1 * cmHandleQueries.queryCmHandlesByTrustLevel(['trustLevel': 'COMPLETE'] as Map)
+ }
+
def 'Query cm handle details with module names when #scenario from query.'() {
given: 'a modules condition property'
def cmHandleQueryParameters = new CmHandleQueryServiceParameters()