From: emaclee Date: Mon, 5 Jan 2026 13:29:16 +0000 (+0000) Subject: fix: 100% code coverage for ParameterMapper X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d413428f8afd2db8394573748ac4cbf48a78686d;p=cps.git fix: 100% code coverage for ParameterMapper Issue-ID: CPS-3093 Change-Id: I7eefa3cf389d10b737a990704de74e8c455ff839 Signed-off-by: emaclee --- diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/provmns/ParameterMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/provmns/ParameterMapper.java index fd53be48ee..8717bd7d03 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/provmns/ParameterMapper.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/provmns/ParameterMapper.java @@ -46,7 +46,7 @@ public class ParameterMapper { "org.springframework.web.servlet.HandlerMapping.pathWithinHandlerMapping"); final String[] pathVariables = uriPath.split(PROVMNS_BASE_PATH); if (pathVariables.length != PATH_VARIABLES_EXPECTED_LENGTH) { - throwProvMnSException(httpServletRequest.getMethod(), uriPath); + throw createProvMnSException(httpServletRequest.getMethod(), uriPath); } final int lastSlashIndex = pathVariables[1].lastIndexOf('/'); final RequestParameters requestParameters = new RequestParameters(); @@ -62,16 +62,16 @@ public class ParameterMapper { } final String[] splitClassNameId = classNameAndId.split("=", 2); if (splitClassNameId.length != 2) { - throwProvMnSException(httpServletRequest.getMethod(), uriPath); + throw createProvMnSException(httpServletRequest.getMethod(), uriPath); } requestParameters.setClassName(splitClassNameId[0]); requestParameters.setId(splitClassNameId[1]); return requestParameters; } - private void throwProvMnSException(final String httpMethodName, final String uriPath) { + private ProvMnSException createProvMnSException(final String httpMethodName, final String uriPath) { final String title = String.format(INVALID_PATH_DETAILS_TEMPLATE, uriPath); - throw new ProvMnSException(httpMethodName, HttpStatus.UNPROCESSABLE_ENTITY, title); + return new ProvMnSException(httpMethodName, HttpStatus.UNPROCESSABLE_ENTITY, title); } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/provmns/ParameterMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/provmns/ParameterMapperSpec.groovy index 3dad062903..07ac96fe6a 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/provmns/ParameterMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/provmns/ParameterMapperSpec.groovy @@ -66,5 +66,6 @@ class ParameterMapperSpec extends Specification { 'missing ProvMnS prefix' | 'v1/segment1/myClass=myId' 'wrong version' | 'ProvMnS/wrongVersion/myClass=myId' 'empty path' | '' + 'multiple ProvMnS segments' | 'ProvMnS/v1/myClass=myId/ProvMnS/v2/otherSegment' } } diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml index e23dd42893..2cbb8c3282 100644 --- a/cps-parent/pom.xml +++ b/cps-parent/pom.xml @@ -67,7 +67,7 @@ ${project.build.directory}/code-coverage/jacoco-ut.exec ${project.reporting.outputDirectory}/jacoco-ut ${project.reporting.outputDirectory}/jacoco-aggregate - 0.10 + 1.00 ../jacoco-report/target/site/jacoco-aggregate/jacoco.xml