From: ToineSiebelink Date: Wed, 25 Jun 2025 12:22:38 +0000 (+0100) Subject: Fix validation northbound cm handle searches X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=35faa11f7e99a7a9e056d235a2ba57f6c71adbd9;p=cps.git Fix validation northbound cm handle searches - Renamed related methods and Enum using terms north (client facing) and southbound (dmi) for more clarity - Northbound Cm Handle search was using the wrong Enum for validation (this caused the issue) - Grouped and ordered renamed methods in facade impl - Enums also had the wrong values: unsupported values in one and missing values in the other (southbound can/should support all possible queries, no reason not too) TODO (separate subtasks and commits) - Update RTD documentation to properly describe options in each ifc - Update Postman collection to have cleared separation between north and southbound interfaces Issue-ID: CPS-2864 Change-Id: I6523b368e504b5e99dde794e7e716193d2cadf23 Signed-off-by: ToineSiebelink --- diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java index 258b884761..fd4ced3f74 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java @@ -266,9 +266,9 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { final CmHandleQueryApiParameters cmHandleQueryApiParameters = deprecationHelper.mapOldConditionProperties(cmHandleQueryParameters); final List restOutputCmHandles = - networkCmProxyInventoryFacade.executeCmHandleSearch(cmHandleQueryApiParameters) - .map(handle -> restOutputCmHandleMapper - .toRestOutputCmHandle(handle, false)).collectList().block(); + networkCmProxyInventoryFacade.northboundCmHandleSearch(cmHandleQueryApiParameters) + .map(ncmpServiceCmHandle -> restOutputCmHandleMapper + .toRestOutputCmHandle(ncmpServiceCmHandle, false)).collectList().block(); return ResponseEntity.ok(restOutputCmHandles); } @@ -288,7 +288,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { final CmHandleQueryApiParameters cmHandleQueryApiParameters = jsonObjectMapper.convertToValueType(cmHandleQueryParameters, CmHandleQueryApiParameters.class); final Collection cmHandleIds - = networkCmProxyInventoryFacade.executeCmHandleIdSearch(cmHandleQueryApiParameters, outputAlternateId); + = networkCmProxyInventoryFacade.northboundCmHandleIdSearch(cmHandleQueryApiParameters, outputAlternateId); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java index 3a5102ceeb..055ac7e4b8 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java @@ -75,7 +75,7 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor .toCmHandleQueryServiceParameters(cmHandleQueryParameters); final Collection cmHandleIds = networkCmProxyInventoryFacade - .executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, outputAlternateId); + .southboundCmHandleIdSearch(cmHandleQueryServiceParameters, outputAlternateId); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } @@ -94,9 +94,9 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor deprecationHelper.mapOldConditionProperties(cmHandleQueryParameters); final boolean includeCmHandlePropertiesParameter = Boolean.TRUE.equals(includeCmHandlePropertiesInQuery); final List restOutputCmHandles = - networkCmProxyInventoryFacade.executeCmHandleInventorySearch(cmHandleQueryApiParameters) - .map(ncmpServiceCmHandle -> restOutputCmHandleMapper - .toRestOutputCmHandle(ncmpServiceCmHandle, includeCmHandlePropertiesParameter)) + networkCmProxyInventoryFacade.southboundCmHandleSearch(cmHandleQueryApiParameters) + .map(handle -> restOutputCmHandleMapper + .toRestOutputCmHandle(handle, includeCmHandlePropertiesParameter)) .collectList().block(); return ResponseEntity.ok(restOutputCmHandles); } diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy index ce7ef1fbf5..022bc1327c 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy @@ -272,7 +272,7 @@ class NetworkCmProxyControllerSpec extends Specification { and: 'the inventory facade returns two cm handles' def ncmpServiceCmHandle1 = new NcmpServiceCmHandle(cmHandleId: 'ch-1') def ncmpServiceCmHandle2 = new NcmpServiceCmHandle(cmHandleId: 'ch-2') - mockNetworkCmProxyInventoryFacade.executeCmHandleSearch(_) >> Flux.fromIterable([ncmpServiceCmHandle1, ncmpServiceCmHandle2]) + mockNetworkCmProxyInventoryFacade.northboundCmHandleSearch(_) >> Flux.fromIterable([ncmpServiceCmHandle1, ncmpServiceCmHandle2]) and: 'mapper converts cm handles without private properties' def restHandle1 = new RestOutputCmHandle(cmHandle: 'rest ch-1') def restHandle2 = new RestOutputCmHandle(cmHandle: 'rest ch-2') @@ -342,7 +342,7 @@ class NetworkCmProxyControllerSpec extends Specification { when: 'the searches api is invoked' mvc.perform(post(searchesEndpoint).contentType(MediaType.APPLICATION_JSON).content(jsonString)) then: 'the request was still accepted and forwarded to the correct services' - 1 * mockNetworkCmProxyInventoryFacade.executeCmHandleSearch(_) >> Flux.fromIterable([new NcmpServiceCmHandle()]) + 1 * mockNetworkCmProxyInventoryFacade.northboundCmHandleSearch(_) >> Flux.fromIterable([new NcmpServiceCmHandle()]) 1 * mockRestOutputCmHandleMapper.toRestOutputCmHandle(_, _) >> new RestOutputCmHandle(cmHandle: 'some cm handle') } @@ -350,7 +350,7 @@ class NetworkCmProxyControllerSpec extends Specification { given: 'an endpoint and json data' def searchesEndpoint = "$ncmpBasePathV1/ch/id-searches" and: 'the service method is invoked with module names and returns cm handle ids' - 1 * mockNetworkCmProxyInventoryFacade.executeCmHandleIdSearch(_, _) >> ['ch-1', 'ch-2'] + 1 * mockNetworkCmProxyInventoryFacade.northboundCmHandleIdSearch(_, _) >> ['ch-1', 'ch-2'] when: 'the searches api is invoked' def response = mvc.perform(post(searchesEndpoint).contentType(MediaType.APPLICATION_JSON).content('{}')).andReturn().response then: 'cm handle ids are returned' diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy index 366d1af920..90cbc845c5 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy @@ -124,7 +124,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { and: 'the mapper service returns a converted object' ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters and: 'the service returns the desired results' - mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse + mockNetworkCmProxyInventoryFacade.southboundCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse when: 'post request is performed & search is called with the given request parameters' def response = mvc.perform( post("$ncmpBasePathV1/ch/searches") @@ -147,7 +147,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { and: 'the mapper service returns a converted object' ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters and: 'the service returns the desired results' - mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse + mockNetworkCmProxyInventoryFacade.southboundCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse when: 'post request is performed & search is called with the given request parameters' def response = mvc.perform( post("$ncmpBasePathV1/ch/searches") @@ -168,7 +168,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { given: 'the mapper service returns a converted object' ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters and: 'the service returns the desired results' - mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters) >> [] + mockNetworkCmProxyInventoryFacade.southboundCmHandleIdSearch(cmHandleQueryServiceParameters) >> [] when: 'post request is performed & search is called with the given request parameters' def response = mvc.perform( post("$ncmpBasePathV1/ch/searches") @@ -274,7 +274,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { String jsonString = TestUtils.getResourceFileContent('cm-handle-search-by-dmi-service.json') and: 'a cm handle is returned' def ncmpServiceCmHandle = new NcmpServiceCmHandle(additionalProperties: ['someName': 'my dmi']) - mockNetworkCmProxyInventoryFacade.executeCmHandleInventorySearch(_) >> Flux.fromIterable([ncmpServiceCmHandle]) + mockNetworkCmProxyInventoryFacade.southboundCmHandleSearch(_) >> Flux.fromIterable([ncmpServiceCmHandle]) and: 'the mapper is requested to convert the object with additional properties' mockRestOutputCmHandleMapper.toRestOutputCmHandle(ncmpServiceCmHandle, true) >> new RestOutputCmHandle() when: 'the endpoint is invoked' diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java index 615264a9a0..baaa0f75fd 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java @@ -61,9 +61,9 @@ public interface NetworkCmProxyInventoryFacade { * cm handle id (false) or alternate id (true) * @return collection of cm handle references */ - Collection executeParameterizedCmHandleIdSearch(final CmHandleQueryServiceParameters + Collection southboundCmHandleIdSearch(final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, - final boolean outputAlternateId); + final boolean outputAlternateId); /** * Retrieve module references for the given cm handle reference. @@ -99,7 +99,7 @@ public interface NetworkCmProxyInventoryFacade { * @param cmHandleQueryApiParameters cm handle query parameters * @return cm handle objects as a reactive stream (flux) */ - Flux executeCmHandleSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters); + Flux northboundCmHandleSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters); /** * Retrieve cm handle ids for the given query parameters. @@ -108,8 +108,8 @@ public interface NetworkCmProxyInventoryFacade { * @param outputAlternateId boolean for cm handle reference type either cmHandleId (false) or AlternateId (true) * @return cm handle ids */ - Collection executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters, - final boolean outputAlternateId); + Collection northboundCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters, + final boolean outputAlternateId); /** * Set the data sync enabled flag, along with the data sync state @@ -150,6 +150,6 @@ public interface NetworkCmProxyInventoryFacade { * @param cmHandleQueryApiParameters cm handle query parameters * @return cm handle objects as a reactive stream (flux) */ - Flux executeCmHandleInventorySearch(final CmHandleQueryApiParameters + Flux southboundCmHandleSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java index 0c20aee007..f630dfac43 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java @@ -44,8 +44,8 @@ import org.onap.cps.ncmp.impl.inventory.CmHandleQueryService; import org.onap.cps.ncmp.impl.inventory.CmHandleRegistrationService; import org.onap.cps.ncmp.impl.inventory.InventoryPersistence; import org.onap.cps.ncmp.impl.inventory.ParameterizedCmHandleQueryService; -import org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions; -import org.onap.cps.ncmp.impl.inventory.models.InventoryQueryConditions; +import org.onap.cps.ncmp.impl.inventory.models.NorthboundCmHandleQuerySupportedConditions; +import org.onap.cps.ncmp.impl.inventory.models.SouthboundCmHandleQuerySupportedConditions; import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle; import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager; import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher; @@ -77,14 +77,6 @@ public class NetworkCmProxyInventoryFacadeImpl implements NetworkCmProxyInventor return cmHandleQueryService.getCmHandleReferencesByDmiPluginIdentifier(dmiPluginIdentifier, outputAlternateId); } - @Override - public Collection executeParameterizedCmHandleIdSearch( - final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, final boolean outputAlternateId) { - validateCmHandleQueryParameters(cmHandleQueryServiceParameters, InventoryQueryConditions.ALL_CONDITION_NAMES); - - return parameterizedCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters, - outputAlternateId); - } @Override public Collection getYangResourcesModuleReferences(final String cmHandleReference) { @@ -119,30 +111,42 @@ public class NetworkCmProxyInventoryFacadeImpl implements NetworkCmProxyInventor } @Override - public Flux executeCmHandleSearch( - final CmHandleQueryApiParameters cmHandleQueryApiParameters) { + public Collection northboundCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters, + final boolean outputAlternateId) { + final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType( + cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class); + validateCmHandleQueryParameters(cmHandleQueryServiceParameters, + NorthboundCmHandleQuerySupportedConditions.CONDITION_NAMES); + return parameterizedCmHandleQueryService.queryCmHandleReferenceIds(cmHandleQueryServiceParameters, + outputAlternateId); + } + + @Override + public Flux northboundCmHandleSearch( + final CmHandleQueryApiParameters cmHandleQueryApiParameters) { final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class); - validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES); + validateCmHandleQueryParameters(cmHandleQueryServiceParameters, + NorthboundCmHandleQuerySupportedConditions.CONDITION_NAMES); return parameterizedCmHandleQueryService.queryCmHandles(cmHandleQueryServiceParameters); } @Override - public Flux executeCmHandleInventorySearch( + public Flux southboundCmHandleSearch( final CmHandleQueryApiParameters cmHandleQueryApiParameters) { final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class); - validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES); + validateCmHandleQueryParameters(cmHandleQueryServiceParameters, + SouthboundCmHandleQuerySupportedConditions.CONDITION_NAMES); return parameterizedCmHandleQueryService.queryInventoryForCmHandles(cmHandleQueryServiceParameters); } @Override - public Collection executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters, - final boolean outputAlternateId) { - final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType( - cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class); - validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES); - return parameterizedCmHandleQueryService.queryCmHandleReferenceIds(cmHandleQueryServiceParameters, + public Collection southboundCmHandleIdSearch( + final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, final boolean outputAlternateId) { + validateCmHandleQueryParameters(cmHandleQueryServiceParameters, + SouthboundCmHandleQuerySupportedConditions.CONDITION_NAMES); + return parameterizedCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters, outputAlternateId); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java index c0fd13fcad..68d97fbbad 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java @@ -22,10 +22,10 @@ package org.onap.cps.ncmp.impl.inventory; import static org.onap.cps.ncmp.impl.inventory.CmHandleQueryParametersValidator.validateCpsPathConditionProperties; import static org.onap.cps.ncmp.impl.inventory.CmHandleQueryParametersValidator.validateModuleNameConditionProperties; -import static org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions.HAS_ALL_MODULES; -import static org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions.HAS_ALL_PROPERTIES; -import static org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions.WITH_CPS_PATH; -import static org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions.WITH_TRUST_LEVEL; +import static org.onap.cps.ncmp.impl.inventory.models.NorthboundCmHandleQuerySupportedConditions.HAS_ALL_MODULES; +import static org.onap.cps.ncmp.impl.inventory.models.NorthboundCmHandleQuerySupportedConditions.HAS_ALL_PROPERTIES; +import static org.onap.cps.ncmp.impl.inventory.models.NorthboundCmHandleQuerySupportedConditions.WITH_CPS_PATH; +import static org.onap.cps.ncmp.impl.inventory.models.NorthboundCmHandleQuerySupportedConditions.WITH_TRUST_LEVEL; import java.util.ArrayList; import java.util.Collection; @@ -40,8 +40,8 @@ import org.onap.cps.api.model.ConditionProperties; import org.onap.cps.cpspath.parser.PathParsingException; import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters; import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle; -import org.onap.cps.ncmp.impl.inventory.models.InventoryQueryConditions; import org.onap.cps.ncmp.impl.inventory.models.PropertyType; +import org.onap.cps.ncmp.impl.inventory.models.SouthboundCmHandleQuerySupportedConditions; import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle; import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager; import org.onap.cps.ncmp.impl.utils.YangDataConverter; @@ -96,7 +96,7 @@ public class ParameterizedCmHandleQueryServiceImpl implements ParameterizedCmHan final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, final boolean outputAlternateId) { final Map dmiPropertyQueryPairs = getPropertyPairs(cmHandleQueryServiceParameters.getCmHandleQueryParameters(), - InventoryQueryConditions.CM_HANDLE_WITH_DMI_PLUGIN.getName()); + SouthboundCmHandleQuerySupportedConditions.WITH_DMI_SERVICE.getConditionName()); if (dmiPropertyQueryPairs.isEmpty()) { return NO_QUERY_TO_EXECUTE; } @@ -114,7 +114,7 @@ public class ParameterizedCmHandleQueryServiceImpl implements ParameterizedCmHan final Map additionalPropertyQueryPairs = getPropertyPairs(cmHandleQueryServiceParameters.getCmHandleQueryParameters(), - InventoryQueryConditions.HAS_ALL_ADDITIONAL_PROPERTIES.getName()); + SouthboundCmHandleQuerySupportedConditions.HAS_ALL_ADDITIONAL_PROPERTIES.getConditionName()); if (additionalPropertyQueryPairs.isEmpty()) { return NO_QUERY_TO_EXECUTE; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/CmHandleQueryConditions.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/NorthboundCmHandleQuerySupportedConditions.java similarity index 71% rename from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/CmHandleQueryConditions.java rename to cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/NorthboundCmHandleQuerySupportedConditions.java index d96fdee75a..d2fbb465f0 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/CmHandleQueryConditions.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/NorthboundCmHandleQuerySupportedConditions.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,22 +23,22 @@ package org.onap.cps.ncmp.impl.inventory.models; import java.util.Arrays; import java.util.Collection; import java.util.stream.Collectors; +import lombok.AllArgsConstructor; import lombok.Getter; @Getter -public enum CmHandleQueryConditions { - HAS_ALL_PROPERTIES("hasAllProperties"), +@AllArgsConstructor + +public enum NorthboundCmHandleQuerySupportedConditions { HAS_ALL_MODULES("hasAllModules"), + HAS_ALL_PROPERTIES("hasAllProperties"), WITH_CPS_PATH("cmHandleWithCpsPath"), - WITH_TRUST_LEVEL("cmHandleWithTrustLevel"), - WITH_DMI_SERVICE("cmHandleWithDmiPlugin"); + WITH_TRUST_LEVEL("cmHandleWithTrustLevel"); - public static final Collection ALL_CONDITION_NAMES = Arrays.stream(CmHandleQueryConditions.values()) - .map(CmHandleQueryConditions::getConditionName).collect(Collectors.toList()); + public static final Collection CONDITION_NAMES = + Arrays.stream(NorthboundCmHandleQuerySupportedConditions.values()) + .map(NorthboundCmHandleQuerySupportedConditions::getConditionName).collect(Collectors.toList()); private final String conditionName; - CmHandleQueryConditions(final String conditionName) { - this.conditionName = conditionName; - } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/SouthboundCmHandleQuerySupportedConditions.java similarity index 67% rename from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java rename to cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/SouthboundCmHandleQuerySupportedConditions.java index e0b54d2197..cdbbbe6f44 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/SouthboundCmHandleQuerySupportedConditions.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,16 +28,18 @@ import lombok.Getter; @Getter @AllArgsConstructor -public enum InventoryQueryConditions { - +public enum SouthboundCmHandleQuerySupportedConditions { + HAS_ALL_MODULES("hasAllModules"), HAS_ALL_PROPERTIES("hasAllProperties"), HAS_ALL_ADDITIONAL_PROPERTIES("hasAllAdditionalProperties"), - CM_HANDLE_WITH_DMI_PLUGIN("cmHandleWithDmiPlugin"), - WITH_CPS_PATH("cmHandleWithCpsPath"); + WITH_CPS_PATH("cmHandleWithCpsPath"), + WITH_DMI_SERVICE("cmHandleWithDmiPlugin"), + WITH_TRUST_LEVEL("cmHandleWithTrustLevel"); - public static final List ALL_CONDITION_NAMES = Arrays.stream(InventoryQueryConditions.values()) - .map(InventoryQueryConditions::getName).collect(Collectors.toList()); + public static final List CONDITION_NAMES = + Arrays.stream(SouthboundCmHandleQuerySupportedConditions.values()) + .map(SouthboundCmHandleQuerySupportedConditions::getConditionName).collect(Collectors.toList()); - private final String name; + private final String conditionName; } 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 ff771c19c8..520d4e9e62 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 @@ -64,7 +64,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { 1 * mockCmHandleRegistrationService.updateDmiRegistration(dmiPluginRegistration) } - def 'Execute cm handle reference search for inventory'() { + def 'Execute southbound handle reference search (dmi)'() { given: 'a ConditionApiProperties object' def conditionProperties = new ConditionProperties() conditionProperties.conditionName = 'hasAllProperties' @@ -74,7 +74,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, false) + def result = objectUnderTest.southboundCmHandleIdSearch(cmHandleQueryServiceParameters, false) then: 'the result returns the correct 2 elements' assert result.size() == 2 assert result.contains('cmHandle1') @@ -198,7 +198,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { 'Cm Handle Reference as alternate-id' | 'some-alternate-id' } - def 'Execute cm handle reference search'() { + def 'Execute northbound cm handle reference search'() { given: 'valid CmHandleQueryApiParameters input' def cmHandleQueryApiParameters = new CmHandleQueryApiParameters() def conditionApiProperties = new ConditionApiProperties() @@ -209,8 +209,8 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { mockParameterizedCmHandleQueryService.queryCmHandleReferenceIds( spiedJsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class), false) >> ['cm-handle-id-1'] - when: 'execute cm handle search is called' - def result = objectUnderTest.executeCmHandleIdSearch(cmHandleQueryApiParameters, false) + when: 'cm handle id search is called' + def result = objectUnderTest.northboundCmHandleIdSearch(cmHandleQueryApiParameters, false) then: 'result is the same collection as returned by the CPS Data Service' assert result == ['cm-handle-id-1'] } @@ -241,7 +241,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { 'Cm Handle Reference as alternate-id' | 'some-alternate-id' } - def 'Execute cm handle search'() { + def 'Execute northbound cm handle search'() { given: 'valid CmHandleQueryApiParameters input' def cmHandleQueryApiParameters = new CmHandleQueryApiParameters() def conditionApiProperties = new ConditionApiProperties() @@ -253,8 +253,8 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { spiedJsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class)) >> Flux.fromIterable([new NcmpServiceCmHandle(cmHandleId: 'ch-0', currentTrustLevel: TrustLevel.COMPLETE), new NcmpServiceCmHandle(cmHandleId: 'ch-1', currentTrustLevel: TrustLevel.COMPLETE)]) - when: 'execute cm handle search is called' - def result = objectUnderTest.executeCmHandleSearch(cmHandleQueryApiParameters).collectList().block() + when: 'the cm handle search is called' + def result = objectUnderTest.northboundCmHandleSearch(cmHandleQueryApiParameters).collectList().block() then: 'result consists of the two cm handles returned by the CPS Data Service' assert result.size() == 2 assert result[0].cmHandleId == 'ch-0' @@ -264,7 +264,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { assert result[1].currentTrustLevel == TrustLevel.COMPLETE } - def 'Execute cm handle reference search with a valid condition name'() { + def 'Execute southbound cm handle reference search with a valid condition name'() { given: 'a valid API parameter with a supported condition' def apiParams = new CmHandleQueryApiParameters( cmHandleQueryParameters: [ @@ -278,7 +278,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { mockParameterizedCmHandleQueryService.queryInventoryForCmHandles(_) >> Flux.fromIterable([new NcmpServiceCmHandle(cmHandleId: 'cm handle from the query service')]) when: 'executing the cm handle search' - def result = objectUnderTest.executeCmHandleInventorySearch(apiParams).collectList().block() + def result = objectUnderTest.southboundCmHandleSearch(apiParams).collectList().block() then: 'the result returns the cm handle from the query service' assert result.size() == 1 assert result[0].cmHandleId == 'cm handle from the query service' @@ -292,7 +292,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification { ] ) when: 'executing the search' - objectUnderTest.executeCmHandleInventorySearch(apiParams).collectList().block() + objectUnderTest.southboundCmHandleSearch(apiParams).collectList().block() then: 'a data validation exception will be thrown' def exception = thrown(DataValidationException) assert exception.message == 'Invalid Query Parameter.' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/CmHandleQueryConditionsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/NorthboundCmHandleQuerySupportedConditionsSpec.groovy similarity index 70% rename from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/CmHandleQueryConditionsSpec.groovy rename to cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/NorthboundCmHandleQuerySupportedConditionsSpec.groovy index 0ca665604e..e322df286a 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/CmHandleQueryConditionsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/NorthboundCmHandleQuerySupportedConditionsSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================== - * Copyright (c) 2022 Nordix Foundation. + * Copyright (c) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,16 +23,15 @@ package org.onap.cps.ncmp.impl.inventory.models import spock.lang.Specification -class CmHandleQueryConditionsSpec extends Specification { +class NorthboundCmHandleQuerySupportedConditionsSpec extends Specification { - def 'CmHandle query condition names.'() { - expect: '5 conditions with the correct names' - assert CmHandleQueryConditions.ALL_CONDITION_NAMES.size() == 5 - assert CmHandleQueryConditions.ALL_CONDITION_NAMES.containsAll('hasAllProperties', + def 'Northbound cm handle query condition names.'() { + expect: '4 conditions with the correct names' + assert NorthboundCmHandleQuerySupportedConditions.CONDITION_NAMES.size() == 4 + assert NorthboundCmHandleQuerySupportedConditions.CONDITION_NAMES.containsAll('hasAllProperties', 'hasAllModules', 'cmHandleWithCpsPath', - 'cmHandleWithDmiPlugin', - 'cmHandleWithTrustLevel') + 'cmHandleWithTrustLevel') } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/SouthboundCmHandleQuerySupportedConditionsSpec.groovy similarity index 63% rename from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy rename to cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/SouthboundCmHandleQuerySupportedConditionsSpec.groovy index 2e7122268f..46462e2b1e 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/SouthboundCmHandleQuerySupportedConditionsSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================== - * Copyright (c) 2022-2024 Nordix Foundation. + * Copyright (c) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,14 +22,16 @@ package org.onap.cps.ncmp.impl.inventory.models import spock.lang.Specification -class InventoryQueryConditionsSpec extends Specification { +class SouthboundCmHandleQuerySupportedConditionsSpec extends Specification { - def 'Inventory query condition names.'() { - expect: '4 conditions with the correct names' - assert InventoryQueryConditions.ALL_CONDITION_NAMES.size() == 4 - assert InventoryQueryConditions.ALL_CONDITION_NAMES.containsAll('hasAllProperties', + def 'Southbound cm handle query condition names.'() { + expect: '6 conditions with the correct names' + assert SouthboundCmHandleQuerySupportedConditions.CONDITION_NAMES.size() == 6 + assert SouthboundCmHandleQuerySupportedConditions.CONDITION_NAMES.containsAll('hasAllModules', + 'hasAllProperties', 'hasAllAdditionalProperties', + 'cmHandleWithCpsPath', 'cmHandleWithDmiPlugin', - 'cmHandleWithCpsPath') + 'cmHandleWithTrustLevel') } }