From 6b8a2461faa1271cd1baaee7687bc8bdf0f805d1 Mon Sep 17 00:00:00 2001 From: seanbeirne Date: Fri, 28 Nov 2025 16:18:54 +0000 Subject: [PATCH] Error Handling for unsupported ProvMnS PATCH operations Issue-ID: CPS-3068 Change-Id: I906038c79e17b63ac228ccfcb8a39fcf72e294d7 Signed-off-by: seanbeirne --- .../impl/data/policyexecutor/OperationDetailsFactory.java | 3 ++- .../data/policyexecutor/OperationDetailsFactorySpec.groovy | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactory.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactory.java index 301979ee31..bdb96c0c93 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactory.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactory.java @@ -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); diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactorySpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactorySpec.groovy index 0264282672..61a3ceed35 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactorySpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/policyexecutor/OperationDetailsFactorySpec.groovy @@ -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.'() { -- 2.16.6