diff options
author | Priyank Maheshwari <priyank.maheshwari@est.tech> | 2024-11-15 10:36:04 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-11-15 10:36:04 +0000 |
commit | 12dd22ec92526bb2782f3c1e55b6e9a4e0e9e77c (patch) | |
tree | b772c2918a7e640c298cb0d8b66b9bf3e41002a9 /cps-ncmp-service/src/test/groovy/org/onap | |
parent | e14acc9d0d51a47c0827401c318e549aba753dd2 (diff) | |
parent | c37dee4816f51f750a9c92946dc9d4a558f3b812 (diff) |
Merge "Support alternate Id interface for ncmp inventory /ch/cmhandles endpoint"
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap')
4 files changed, 40 insertions, 24 deletions
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 0c50e3d4ee..ce08156fec 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 @@ -199,22 +199,26 @@ class CmHandleQueryServiceImplSpec extends Specification { assert result.contains(cmHandleDataNode) } - def 'Get all cm handles by dmi plugin identifier'() { + def 'Get all cm handles by dmi plugin identifier and alternate id output option where #scenario'() { 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.getCmHandleIdsByDmiPluginIdentifier('my-dmi-plugin-identifier') + when: 'cm Handles are fetched for a given dmi plugin identifier and alternate id output option' + def result = objectUnderTest.getCmHandleReferencesByDmiPluginIdentifier('my-dmi-plugin-identifier', outputAlternateId) then: 'result is the correct size' assert result.size() == 3 and: 'result contains the correct cm handles' - assert result.containsAll('PNFDemo', 'PNFDemo2', 'PNFDemo4') + assert result.containsAll(expectedResult) + where: + scenario | outputAlternateId || expectedResult + 'output is for alternate ids' | true || ['alt-PNFDemo', 'alt-PNFDemo2', 'alt-PNFDemo4'] + 'output is for cm handle ids' | false || ['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() + def result = objectUnderTest.getCmHandleReferencesMapByDmiPluginIdentifier('my-dmi-plugin-identifier').values() then: 'result is the correct size' assert result.size() == 3 and: 'result contains the correct alternate Ids' 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 34d9374f78..00f092ff75 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 @@ -381,9 +381,7 @@ class InventoryPersistenceImplSpec extends Specification { def 'Check if cm handle exists for a given cm handle id'() { given: 'data service returns a datanode with correct cm handle id' mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, xpath, INCLUDE_ALL_DESCENDANTS) >> [dataNode] - when: 'method is called to check if cm handle exists from cm handle id' - def result = objectUnderTest.isExistingCmHandleId('some-cm-handle') - then: 'check if cm handle id in datanode is equal to given cm handle id' - assert result == true + expect: 'cm handle exists for given cm handle id' + assert true == objectUnderTest.isExistingCmHandleId('some-cm-handle') } } 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 4c554c6af5..282bd9e89b 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 @@ -78,15 +78,20 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { assert result.contains('cmHandle2') } - def 'Get all cm handle IDs by DMI plugin identifier.' () { - given: 'cm handle queries service returns cm handles' - 1 * mockCmHandleQueryService.getCmHandleIdsByDmiPluginIdentifier('some-dmi-plugin-identifier') >> ['cm-handle-1','cm-handle-2'] - when: 'cm handle Ids are requested with dmi plugin identifier' - def result = objectUnderTest.getAllCmHandleIdsByDmiPluginIdentifier('some-dmi-plugin-identifier') + def 'Get all cm handle references by DMI plugin identifier and alternate id output option where #scenario.' () { + given: 'cm handle queries service returns cm handle references' + mockCmHandleQueryService.getCmHandleReferencesByDmiPluginIdentifier('some-dmi-plugin-identifier', false) >> ['cm-handle-1','cm-handle-2'] + mockCmHandleQueryService.getCmHandleReferencesByDmiPluginIdentifier('some-dmi-plugin-identifier', true) >> ['alternate-id-1','alternate-id-2'] + when: 'cm handle references are requested with dmi plugin identifier and alternate id output option' + def result = objectUnderTest.getAllCmHandleReferencesByDmiPluginIdentifier('some-dmi-plugin-identifier', outputAlternateId) then: 'the result size is correct' assert result.size() == 2 and: 'the result returns the correct details' - assert result.containsAll('cm-handle-1','cm-handle-2') + assert result.containsAll(expectedResult) + where: + scenario | outputAlternateId || expectedResult + 'output is for alternate ids' | true || ['alternate-id-1', 'alternate-id-2'] + 'output is for cm handle ids' | false || ['cm-handle-1','cm-handle-2'] } def 'Getting Yang Resources for a given #scenario'() { 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 9a81807ef9..0c44196348 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 @@ -200,22 +200,31 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { 'additional properties, no matching cm handles' | 'hasAllAdditionalProperties' | null | [] || 0 } - def 'Retrieve CMHandleIds by different DMI properties with #scenario.' () { + def 'Retrieve alternate ids by different DMI properties.' () { given: 'a query object created with dmi plugin as condition' def cmHandleQueryParameters = new CmHandleQueryServiceParameters() def conditionProperties = createConditionProperties('cmHandleWithDmiPlugin', [['some-key': 'some-value']]) cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) and: 'the inventoryPersistence returns different CmHandleIds' - partiallyMockedCmHandleQueries.getCmHandleIdsByDmiPluginIdentifier(*_) >> cmHandleQueryResult - partiallyMockedCmHandleQueries.getCmHandleReferencesByDmiPluginIdentifier(*_) >> cmHandleQueryResult + partiallyMockedCmHandleQueries.getCmHandleReferencesMapByDmiPluginIdentifier(*_) >> [:] when: 'the query executed' - def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters, outputAlternateId) + def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters, true) then: 'the expected number of results are returned.' - assert result.size() == expectedCmHandleIdsSize - where: 'the following data is used' - scenario | cmHandleQueryResult | outputAlternateId || expectedCmHandleIdsSize - 'some matches' | ['h1','h2'] | false || 2 - 'no matches' | [:] | true || 0 + assert result.size() == 0 + } + + def 'Retrieve cm handle ids by different DMI properties.' () { + given: 'a query object created with dmi plugin as condition' + def cmHandleQueryParameters = new CmHandleQueryServiceParameters() + def conditionProperties = createConditionProperties('cmHandleWithDmiPlugin', [['some-key': 'some-value']]) + cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) + and: 'the inventoryPersistence returns different CmHandleIds' + partiallyMockedCmHandleQueries.getCmHandleReferencesByDmiPluginIdentifier(_, _) >> ['h1','h2'] + when: 'the query executed' + def result = objectUnderTestWithPartiallyMockedQueries.queryCmHandleIdsForInventory(cmHandleQueryParameters, false) + then: 'the expected number of results are returned.' + assert result.size() == 2 + } def 'Combine two query results where #scenario.'() { |