fix: 100% code coverage for ParameterMapper 43/142843/1
authoremaclee <lee.anjella.macabuhay@est.tech>
Mon, 5 Jan 2026 13:29:16 +0000 (13:29 +0000)
committerLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>
Mon, 5 Jan 2026 13:39:58 +0000 (13:39 +0000)
Issue-ID: CPS-3093
Change-Id: I7eefa3cf389d10b737a990704de74e8c455ff839
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/provmns/ParameterMapper.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/provmns/ParameterMapperSpec.groovy
cps-parent/pom.xml

index fd53be4..8717bd7 100644 (file)
@@ -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);
     }
 
 }
index 3dad062..07ac96f 100644 (file)
@@ -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'
     }
 }
index e23dd42..2cbb8c3 100644 (file)
@@ -67,7 +67,7 @@
         <jacoco.execFile>${project.build.directory}/code-coverage/jacoco-ut.exec</jacoco.execFile>
         <jacoco.outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</jacoco.outputDirectory>
         <jacoco.reportDirectory.aggregate>${project.reporting.outputDirectory}/jacoco-aggregate</jacoco.reportDirectory.aggregate>
-        <minimum-coverage>0.10</minimum-coverage>
+        <minimum-coverage>1.00</minimum-coverage>
         <sonar.coverage.jacoco.xmlReportPaths>
             ../jacoco-report/target/site/jacoco-aggregate/jacoco.xml
         </sonar.coverage.jacoco.xmlReportPaths>