diff options
author | seanbeirne <sean.beirne@est.tech> | 2024-09-03 15:27:28 +0100 |
---|---|---|
committer | seanbeirne <sean.beirne@est.tech> | 2024-10-25 15:46:44 +0100 |
commit | ccf48efa15fa6cce9d2e245601105043f939bcce (patch) | |
tree | 77a1a6a13f8de8a1e1d4d745e3becf1898ca0a31 /cps-ncmp-service/src/test/groovy | |
parent | de910dce42459035b24f3b1ff2f843152312518a (diff) |
Support Alternate-Id for CPS-E05 id-searches and searchCmHandleIds
Issue-ID: CPS-2402
Issue-ID: CPS-2383
Change-Id: I5dd3132b70b401bf2f50f77c2c131d5d34aa0c0a
Signed-off-by: seanbeirne <sean.beirne@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
5 files changed, 88 insertions, 49 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacadeSpec.groovy index 5f83ad5f83..c62e93c214 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacadeSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacadeSpec.groovy @@ -42,9 +42,8 @@ class NetworkCmProxyFacadeSpec extends Specification { def mockDmiDataOperations = Mock(DmiDataOperations) def mockNcmpCachedResourceRequestHandler = Mock(NcmpCachedResourceRequestHandler) def mockNcmpPassthroughResourceRequestHandler = Mock(NcmpPassthroughResourceRequestHandler) - def mockAlternateIdMatcher = Mock(AlternateIdMatcher) - def objectUnderTest = new NetworkCmProxyFacade(mockNcmpCachedResourceRequestHandler, mockNcmpPassthroughResourceRequestHandler, mockDmiDataOperations, mockAlternateIdMatcher) + def objectUnderTest = new NetworkCmProxyFacade(mockNcmpCachedResourceRequestHandler, mockNcmpPassthroughResourceRequestHandler, mockDmiDataOperations) def NO_TOPIC = null @@ -89,7 +88,6 @@ class NetworkCmProxyFacadeSpec extends Specification { given: 'a cm resource address for datastore operational' def cmResourceAddress = new CmResourceAddress('ncmp-datastore:operational', 'some CM Handle', 'some resource Id') and: 'get resource data from DMI is called' - mockAlternateIdMatcher.getCmHandleId('some CM Handle') >> 'some CM Handle' mockNcmpCachedResourceRequestHandler.executeRequest(cmResourceAddress, 'options', NO_TOPIC, false, 'authorization') >> Mono.just('dmi response') when: 'get resource data operational for the given cm resource address is called' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImplSpec.groovy index 7e34fe2822..0c50e3d4ee 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImplSpec.groovy @@ -64,16 +64,16 @@ class CmHandleQueryServiceImplSpec extends Specification { given: 'the DataNodes queried for a given cpsPath are returned from the persistence service.' mockResponses() when: 'a query on cmhandle public properties is performed with a public property pair' - def result = objectUnderTest.queryCmHandlePublicProperties(publicPropertyPairs) + def result = objectUnderTest.queryCmHandlePublicProperties(publicPropertyPairs, outputAlternateId) then: 'the correct cm handle data objects are returned' - result.containsAll(expectedCmHandleIds) - result.size() == expectedCmHandleIds.size() + result.containsAll(expectedCmHandleReferences) + result.size() == expectedCmHandleReferences.size() where: 'the following data is used' - scenario | publicPropertyPairs || expectedCmHandleIds - 'single property matches' | [Contact: 'newemailforstore@bookstore.com'] || ['PNFDemo', 'PNFDemo2', 'PNFDemo4'] - 'public property does not match' | [wont_match: 'wont_match'] || [] - '2 properties, only one match' | [Contact: 'newemailforstore@bookstore.com', Contact2: 'newemailforstore2@bookstore.com'] || ['PNFDemo4'] - '2 properties, no matches' | [Contact: 'newemailforstore@bookstore.com', Contact2: ''] || [] + scenario | publicPropertyPairs | outputAlternateId || expectedCmHandleReferences + 'single property matches' | [Contact: 'newemailforstore@bookstore.com'] | false || ['PNFDemo', 'PNFDemo2', 'PNFDemo4'] + 'public property does not match' | [wont_match: 'wont_match'] | false || [] + '2 properties, only one match' | [Contact: 'newemailforstore@bookstore.com', Contact2: 'newemailforstore2@bookstore.com'] | true || ['alt-PNFDemo4'] + '2 properties, no matches' | [Contact: 'newemailforstore@bookstore.com', Contact2: ''] | false || [] } def 'Query cm handles on trust level'() { @@ -84,22 +84,26 @@ class CmHandleQueryServiceImplSpec extends Specification { and: 'the DataNodes queried for a given cpsPath are returned from the persistence service' mockResponses() when: 'the query is run' - def result = objectUnderTest.queryCmHandlesByTrustLevel(trustLevelPropertyQueryPairs) - then: 'the result contain trusted PNFDemo' + def result = objectUnderTest.queryCmHandlesByTrustLevel(trustLevelPropertyQueryPairs, outputAlternateId) + then: 'the result contain trusted cmHandle reference' assert result.size() == 1 - assert result[0] == 'PNFDemo' + assert result[0] == expectedCmHandleReference + where: 'the following data is used' + senario | outputAlternateId | expectedCmHandleReference + 'output cmHandleId' | false | 'PNFDemo' + 'output AlternateId' | true | 'alt-PNFDemo' } def 'Query CmHandles using empty public properties query pair.'() { when: 'a query on CmHandle public properties is executed using an empty map' - def result = objectUnderTest.queryCmHandlePublicProperties([:]) + def result = objectUnderTest.queryCmHandlePublicProperties([:], false) then: 'no cm handles are returned' result.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 result = objectUnderTest.queryCmHandleAdditionalProperties([:]) + def result = objectUnderTest.queryCmHandleAdditionalProperties([:], false) then: 'no cm handles are returned' result.size() == 0 } @@ -108,7 +112,7 @@ class CmHandleQueryServiceImplSpec extends Specification { given: 'a data node exists with a certain additional-property' mockCpsQueryService.queryDataNodes(_, _, dataNodeWithPrivateField, _) >> [pnfDemo5] when: 'a query on CmHandle private properties is executed using a map' - def result = objectUnderTest.queryCmHandleAdditionalProperties(['Contact3': 'newemailforstore3@bookstore.com']) + def result = objectUnderTest.queryCmHandleAdditionalProperties(['Contact3': 'newemailforstore3@bookstore.com'], false) then: 'one cm handle is returned' result.size() == 1 } @@ -206,6 +210,17 @@ class CmHandleQueryServiceImplSpec extends Specification { assert result.containsAll('PNFDemo', 'PNFDemo2', 'PNFDemo4') } + def 'Get all alternateIds by dmi plugin identifier'() { + given: 'the DataNodes queried for a given cpsPath are returned from the persistence service.' + mockResponses() + when: 'cm Handles are fetched for a given dmi plugin identifier' + def result = objectUnderTest.getCmHandleReferencesByDmiPluginIdentifier('my-dmi-plugin-identifier').values() + then: 'result is the correct size' + assert result.size() == 3 + and: 'result contains the correct alternate Ids' + assert result.containsAll('alt-PNFDemo', 'alt-PNFDemo2', 'alt-PNFDemo4') + } + void mockResponses() { mockCpsQueryService.queryDataNodes(_, _, '//public-properties[@name=\"Contact\" and @value=\"newemailforstore@bookstore.com\"]/ancestor::cm-handles', _) >> [pnfDemo, pnfDemo2, pnfDemo4] mockCpsQueryService.queryDataNodes(_, _, '//public-properties[@name=\"wont_match\" and @value=\"wont_match\"]/ancestor::cm-handles', _) >> [] @@ -219,6 +234,6 @@ class CmHandleQueryServiceImplSpec extends Specification { } def static createDataNode(dataNodeId) { - return new DataNode(xpath: '/dmi-registry/cm-handles[@id=\'' + dataNodeId + '\']', leaves: ['id':dataNodeId]) + return new DataNode(xpath: '/dmi-registry/cm-handles[@id=\'' + dataNodeId + '\']', leaves: ['id':dataNodeId, 'alternate-id':'alt-' + dataNodeId]) } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy index 1830f1331d..e2261f4b7c 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy @@ -38,6 +38,7 @@ import org.onap.cps.spi.model.ModuleDefinition import org.onap.cps.spi.model.ModuleReference import org.onap.cps.utils.ContentType import org.onap.cps.utils.JsonObjectMapper +import org.testcontainers.shaded.com.fasterxml.jackson.databind.introspect.BasicClassIntrospector import spock.lang.Shared import spock.lang.Specification @@ -332,13 +333,25 @@ class InventoryPersistenceImplSpec extends Specification { 0 * mockCmHandleQueries.queryNcmpRegistryByCpsPath(_, _) } - def 'Get CM handles that has given module names'() { + def 'Get CM handle ids for CM Handles that has given module names'() { when: 'the method to get cm handles is called' - objectUnderTest.getCmHandleIdsWithGivenModules(['sample-module-name']) + objectUnderTest.getCmHandleReferencesWithGivenModules(['sample-module-name'], false) then: 'the admin persistence service method to query anchors is invoked once with the same parameter' 1 * mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name']) } + def 'Get Alternate Ids for CM Handles that has given module names'() { + given: 'A Collection of data nodes' + def dataNodes = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='ch-1']", leaves: ['id': 'ch-1', 'alternate-id': 'alt-1'])] + when: 'the methods to get dataNodes is called and returns correct values' + mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name']) >> ['ch-1'] + mockCpsDataService.getDataNodesForMultipleXpaths(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, ["/dmi-registry/cm-handles[@id='ch-1']"], INCLUDE_ALL_DESCENDANTS) >> dataNodes + and: 'the method returns a result' + def result = objectUnderTest.getCmHandleReferencesWithGivenModules(['sample-module-name'], true) + then: 'the result contains the correct alternate Id' + assert result == ['alt-1'] as HashSet + } + def 'Replace list content'() { when: 'replace list content method is called with xpath and data nodes collection' objectUnderTest.replaceListContent('sample xpath', [new DataNode()]) diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy index fec07556eb..42f0a08ac3 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy @@ -61,7 +61,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { 1 * mockCmHandleRegistrationService.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) } - def 'Execute cm handle id search for inventory'() { + def 'Execute cm handle reference search for inventory'() { given: 'a ConditionApiProperties object' def conditionProperties = new ConditionProperties() conditionProperties.conditionName = 'hasAllProperties' @@ -71,7 +71,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { and: 'the system returns an set of cmHandle ids' mockParameterizedCmHandleQueryService.queryCmHandleIdsForInventory(*_) >> [ 'cmHandle1', 'cmHandle2' ] when: 'executing the search' - def result = objectUnderTest.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters) + def result = objectUnderTest.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, false) then: 'the result returns the correct 2 elements' assert result.size() == 2 assert result.contains('cmHandle1') @@ -191,7 +191,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { 'Cm Handle Reference as alternate-id' | 'some-alternate-id' } - def 'Execute cm handle id search'() { + def 'Execute cm handle reference search'() { given: 'valid CmHandleQueryApiParameters input' def cmHandleQueryApiParameters = new CmHandleQueryApiParameters() def conditionApiProperties = new ConditionApiProperties() @@ -199,11 +199,11 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { conditionApiProperties.conditionParameters = [[moduleName: 'module-name-1']] cmHandleQueryApiParameters.cmHandleQueryParameters = [conditionApiProperties] and: 'query cm handle method return with a data node list' - mockParameterizedCmHandleQueryService.queryCmHandleIds( - spiedJsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class)) + mockParameterizedCmHandleQueryService.queryCmHandleReferenceIds( + spiedJsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class), false) >> ['cm-handle-id-1'] when: 'execute cm handle search is called' - def result = objectUnderTest.executeCmHandleIdSearch(cmHandleQueryApiParameters) + def result = objectUnderTest.executeCmHandleIdSearch(cmHandleQueryApiParameters, false) then: 'result is the same collection as returned by the CPS Data Service' assert result == ['cm-handle-id-1'] } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy index 013bace04d..9a81807ef9 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation + * Copyright (C) 2022-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,11 +50,15 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { 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.queryCmHandleAncestorsByCpsPath('/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', 'alternate-id':'some-alternate-id'])] when: 'the query is executed for cm handle ids' - def result = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters) + def result = objectUnderTest.queryCmHandleReferenceIds(cmHandleQueryParameters, outputAlternateId) then: 'the correct expected cm handles ids are returned' - assert result == ['some-cmhandle-id'] as Set + assert result == expectedCmhandleReference + where: 'the following data is used' + senario | outputAlternateId || expectedCmhandleReference + 'output CmHandle Ids' | false || ['some-cmhandle-id'] as Set + 'output Alternate Ids' | true || ['some-alternate-id'] as Set } def 'Query cm handle where cps path itself is ancestor axis.'() { @@ -63,11 +67,15 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']]) cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) and: 'the query get the cm handle data nodes excluding all descendants returns a datanode' - cmHandleQueries.queryCmHandleAncestorsByCpsPath('/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', 'alternate-id':'some-alternate-id'])] when: 'the query is executed for cm handle ids' - def result = objectUnderTest.queryCmHandleIdsForInventory(cmHandleQueryParameters) + def result = objectUnderTest.queryCmHandleIdsForInventory(cmHandleQueryParameters, outputAlternateId) then: 'the correct expected cm handles ids are returned' - assert result == ['some-cmhandle-id'] as Set + assert result == expectedCmhandleReference + where: 'the following data is used' + senario | outputAlternateId || expectedCmhandleReference + 'outputAlternate is false' | false || ['some-cmhandle-id'] as Set + 'outputAlternate is true' | true || ['some-alternate-id'] as Set } def 'Cm handle ids query with error: #scenario.'() { @@ -78,7 +86,7 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { and: 'cmHandleQueries throws a path parsing exception' cmHandleQueries.queryCmHandleAncestorsByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> { throw thrownException } when: 'the query is executed for cm handle ids' - objectUnderTest.queryCmHandleIds(cmHandleQueryParameters) + objectUnderTest.queryCmHandleReferenceIds(cmHandleQueryParameters, false) then: 'a data validation exception is thrown' thrown(expectedException) where: 'the following data is used' @@ -93,7 +101,7 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/additional-properties']]) cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) when: 'the query is executed for cm handle ids' - def result = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters) + def result = objectUnderTest.queryCmHandleReferenceIds(cmHandleQueryParameters, false) then: 'empty result is returned' assert result.isEmpty() } @@ -104,9 +112,9 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { def conditionProperties = createConditionProperties('hasAllModules', [['moduleName': 'some-module-name']]) cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) when: 'the query is executed for cm handle ids' - def result = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters) + def result = objectUnderTest.queryCmHandleReferenceIds(cmHandleQueryParameters, false) then: 'the inventory service is called with the correct module names' - 1 * mockInventoryPersistence.getCmHandleIdsWithGivenModules(['some-module-name']) >> cmHandleIdsFromService + 1 * mockInventoryPersistence.getCmHandleReferencesWithGivenModules(['some-module-name'], false) >> cmHandleIdsFromService and: 'the correct expected cm handles ids are returned' assert result.size() == cmHandleIdsFromService.size() assert result.containsAll(cmHandleIdsFromService) @@ -122,9 +130,9 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { def trustLevelConditionProperties = createConditionProperties('cmHandleWithTrustLevel', [['trustLevel': 'COMPLETE'] as Map]) trustLevelQueryParameters.setCmHandleQueryParameters([trustLevelConditionProperties]) when: 'the query is being executed' - objectUnderTest.queryCmHandleIds(trustLevelQueryParameters) + objectUnderTest.queryCmHandleReferenceIds(trustLevelQueryParameters, false) then: 'the query is being delegated to the cm handle query service with correct parameter' - 1 * cmHandleQueries.queryCmHandlesByTrustLevel(['trustLevel': 'COMPLETE'] as Map) + 1 * cmHandleQueries.queryCmHandlesByTrustLevel(['trustLevel': 'COMPLETE'] as Map, false) } def 'Query cm handle details with module names when #scenario from query.'() { @@ -135,7 +143,7 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { when: 'the query is executed for cm handle ids' def result = objectUnderTest.queryCmHandles(cmHandleQueryParameters) then: 'the inventory service is called with the correct module names' - 1 * mockInventoryPersistence.getCmHandleIdsWithGivenModules(['some-module-name']) >> ['ch1'] + 1 * mockInventoryPersistence.getCmHandleReferencesWithGivenModules(['some-module-name'], false) >> ['ch1'] and: 'the inventory service is called with teh correct if and returns a yang model cm handle' 1 * mockInventoryPersistence.getYangModelCmHandles(['ch1']) >> [new YangModelCmHandle(id: 'abc', dmiProperties: [new YangModelCmHandle.Property('name','value')], publicProperties: [])] @@ -145,15 +153,19 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { assert result[0].dmiProperties == [name:'value'] } - def 'Query cm handle ids when the query is empty.'() { + def 'Query cm handle references when the query is empty.'() { given: 'We use an empty query' def cmHandleQueryParameters = new CmHandleQueryServiceParameters() and: 'the inventory persistence returns the dmi registry datanode with just ids' mockInventoryPersistence.getDataNode(NCMP_DMI_REGISTRY_PARENT, FetchDescendantsOption.DIRECT_CHILDREN_ONLY) >> [dmiRegistry] when: 'the query is executed for both cm handle ids' - def result = objectUnderTest.queryCmHandleIds(cmHandleQueryParameters) + def result = objectUnderTest.queryCmHandleReferenceIds(cmHandleQueryParameters, outputAlternateId) then: 'the correct expected cm handles are returned' - assert result.containsAll('PNFDemo1', 'PNFDemo2', 'PNFDemo3', 'PNFDemo4') + assert result.containsAll(expectedCmhandleReferences) + where: 'the following data is used' + senario | outputAlternateId || expectedCmhandleReferences + 'outputAlternate is false' | false || ['PNFDemo1', 'PNFDemo2', 'PNFDemo3', 'PNFDemo4'] + 'outputAlternate is true' | true || ['alt-PNFDemo1', 'alt-PNFDemo2', 'alt-PNFDemo3', 'alt-PNFDemo4'] } def 'Query cm handle details when the query is empty.'() { @@ -177,7 +189,7 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { partiallyMockedCmHandleQueries.queryCmHandlePublicProperties(*_) >> cmHandlesWithMatchingPublicProperties partiallyMockedCmHandleQueries.queryCmHandleAdditionalProperties(*_) >> cmHandlesWithMatchingPrivateProperties when: 'the query executed' - def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters) + def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters, false) then: 'the expected number of results are returned.' assert result.size() == expectedCmHandleIdsSize where: 'the following data is used' @@ -195,14 +207,15 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) and: 'the inventoryPersistence returns different CmHandleIds' partiallyMockedCmHandleQueries.getCmHandleIdsByDmiPluginIdentifier(*_) >> cmHandleQueryResult + partiallyMockedCmHandleQueries.getCmHandleReferencesByDmiPluginIdentifier(*_) >> cmHandleQueryResult when: 'the query executed' - def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters) + def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters, outputAlternateId) then: 'the expected number of results are returned.' assert result.size() == expectedCmHandleIdsSize where: 'the following data is used' - scenario | cmHandleQueryResult || expectedCmHandleIdsSize - 'some matches' | ['h1','h2'] || 2 - 'no matches' | [] || 0 + scenario | cmHandleQueryResult | outputAlternateId || expectedCmHandleIdsSize + 'some matches' | ['h1','h2'] | false || 2 + 'no matches' | [:] | true || 0 } def 'Combine two query results where #scenario.'() { @@ -227,7 +240,7 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { def static createDataNodeList(dataNodeIds) { def dataNodes =[] - dataNodeIds.each{ dataNodes << new DataNode(xpath: "/dmi-registry/cm-handles[@id='${it}']", leaves: ['id':it]) } + dataNodeIds.each{ dataNodes << new DataNode(xpath: "/dmi-registry/cm-handles[@id='${it}']", leaves: ['id':it, 'alternate-id':'alt-' + it]) } return dataNodes } } |