Error Handling for unsupported ProvMnS PATCH operations 76/142576/1
authorseanbeirne <sean.beirne@est.tech>
Fri, 28 Nov 2025 16:18:54 +0000 (16:18 +0000)
committerseanbeirne <sean.beirne@est.tech>
Fri, 28 Nov 2025 16:20:20 +0000 (16:20 +0000)
Issue-ID: CPS-3068
Change-Id: I906038c79e17b63ac228ccfcb8a39fcf72e294d7
Signed-off-by: seanbeirne <sean.beirne@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactory.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactorySpec.groovy

index 301979e..bdb96c0 100644 (file)
@@ -66,7 +66,8 @@ public class OperationDetailsFactory {
                                         requestPathParameters,
                                         patchItem));
                 case REMOVE -> operations.add(buildDeleteOperationDetails(requestPathParameters.toAlternateId()));
-                default -> log.warn("Unsupported Patch Operation Type:{}", patchItem.getOp().getValue());
+                default -> throw new ProvMnSException("UNSUPPORTED_OP",
+                    "Unsupported Patch Operation Type: " + patchItem.getOp().getValue());
             }
         }
         return new PatchOperationsDetails("Some Permission Id", "cm-legacy", operations);
index 0264282..61a3cee 100644 (file)
@@ -22,7 +22,8 @@ package org.onap.cps.ncmp.impl.data.policyexecutor
 
 import com.fasterxml.jackson.core.JsonProcessingException
 import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.ncmp.api.exceptions.NcmpException;
+import org.onap.cps.ncmp.api.exceptions.NcmpException
+import org.onap.cps.ncmp.api.exceptions.ProvMnSException;
 import org.onap.cps.ncmp.impl.provmns.RequestPathParameters;
 import org.onap.cps.ncmp.impl.provmns.model.PatchItem;
 import org.onap.cps.ncmp.impl.provmns.model.ResourceOneOf
@@ -105,11 +106,10 @@ class OperationDetailsFactorySpec extends Specification {
         given: 'a provMnsRequestParameter and a patchItem list'
             def path = new RequestPathParameters(uriLdnFirstPart: 'myUriLdnFirstPart', className: 'someClassName', id: 'someId')
             def patchItemsList = [new PatchItem(op: 'TEST', 'path':'myUriLdnFirstPart')]
-        when: 'a configurationManagementOperation is created and converted to JSON'
-            def result = objectUnderTest.buildPatchOperationDetails(path, patchItemsList)
-        then: 'the result is as expected (using json to compare)'
-            def expectedJsonString = '{"permissionId":"Some Permission Id","changeRequestFormat":"cm-legacy","operations":[]}'
-            assert expectedJsonString == jsonObjectMapper.asJsonString(result)
+        when: 'a build is attempted with an invalid op'
+            objectUnderTest.buildPatchOperationDetails(path, patchItemsList)
+        then: 'the result is as expected (exception thrown)'
+            thrown(ProvMnSException)
     }
 
     def 'Build policy executor create operation details from ProvMnS request parameters where #scenario.'() {