diff options
Diffstat (limited to 'catalog-be')
4 files changed, 26 insertions, 12 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java index ac5af15d6e..962407ca92 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java @@ -225,7 +225,8 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic { final String constraint, final int position, final boolean shouldLock, - final ComponentTypeEnum componentTypeEnum) + final ComponentTypeEnum componentTypeEnum, + final NodeFilterConstraintType nodeFilterConstraintType) throws BusinessLogicException { final Component component = getComponent(componentId); @@ -238,7 +239,8 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic { wasLocked = true; } final Either<CINodeFilterDataDefinition, StorageOperationStatus> result = nodeFilterOperation - .deleteConstraint(componentId, componentInstanceId, nodeFilterDataDefinition, position); + .deleteConstraint(componentId, componentInstanceId, nodeFilterDataDefinition, position, + nodeFilterConstraintType); if (result.isRight()) { janusGraphDao.rollback(); throw new BusinessLogicException(componentsUtils.getResponseFormatByResource(componentsUtils diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java index a682dc9bed..5146d5e5b5 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java @@ -256,9 +256,16 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet { componentNodeFilterBusinessLogic.validateUser(userId); try { - final Optional<CINodeFilterDataDefinition>actionResponse = componentNodeFilterBusinessLogic + final Optional<NodeFilterConstraintType> nodeFilterConstraintType = + NodeFilterConstraintType.parse(constraintType); + if (!nodeFilterConstraintType.isPresent()) { + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT_PARAM, + "Invalid value for NodeFilterConstraintType enum %s", constraintType)); + } + final Optional<CINodeFilterDataDefinition> actionResponse = componentNodeFilterBusinessLogic .deleteNodeFilter(componentId.toLowerCase(), componentInstanceId, NodeFilterConstraintAction.DELETE, - null, index, true, ComponentTypeEnum.findByParamName(componentType)); + null, index, true, ComponentTypeEnum.findByParamName(componentType), + nodeFilterConstraintType.get()); if (!actionResponse.isPresent()) { LOGGER.debug(FAILED_TO_DELETE_NODE_FILTER); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java index 6996465a82..a475943735 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java @@ -376,7 +376,8 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock .thenReturn(StorageOperationStatus.OK); when(nodeFilterOperation - .deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0)) + .deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0, + NodeFilterConstraintType.PROPERTIES)) .thenReturn(Either.left(ciNodeFilterDataDefinition)); when(graphLockOperation.unlockComponent(componentId, NodeTypeEnum.Resource)) @@ -384,7 +385,7 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock final Optional<CINodeFilterDataDefinition> deleteNodeFilterResult = componentNodeFilterBusinessLogic .deleteNodeFilter(componentId, componentInstanceId, NodeFilterConstraintAction.DELETE, constraint, - 0, true, ComponentTypeEnum.RESOURCE); + 0, true, ComponentTypeEnum.RESOURCE, NodeFilterConstraintType.PROPERTIES); assertThat(deleteNodeFilterResult).isPresent(); @@ -396,7 +397,8 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock .validateFilter(resource, componentInstanceId, singletonList(constraint), NodeFilterConstraintAction.DELETE); verify(nodeFilterOperation, times(1)) - .deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0); + .deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0, + NodeFilterConstraintType.PROPERTIES); verify(graphLockOperation, times(1)).unlockComponent(componentId, NodeTypeEnum.Resource); } @@ -413,7 +415,8 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock .thenReturn(StorageOperationStatus.OK); when(nodeFilterOperation - .deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0)) + .deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0, + NodeFilterConstraintType.PROPERTIES)) .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR)); when(graphLockOperation.unlockComponent(componentId, NodeTypeEnum.Resource)) @@ -421,7 +424,7 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic .deleteNodeFilter(componentId, componentInstanceId, NodeFilterConstraintAction.DELETE, constraint, - 0, true, ComponentTypeEnum.RESOURCE)); + 0, true, ComponentTypeEnum.RESOURCE, NodeFilterConstraintType.PROPERTIES)); verify(toscaOperationFacade, times(1)).getToscaElement(componentId); verify(graphLockOperation, times(1)).lockComponent(componentId, NodeTypeEnum.Resource); @@ -443,7 +446,7 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic .deleteNodeFilter(componentId, componentInstanceId, NodeFilterConstraintAction.DELETE, constraint, - 0, true, ComponentTypeEnum.RESOURCE)); + 0, true, ComponentTypeEnum.RESOURCE, NodeFilterConstraintType.PROPERTIES)); verify(toscaOperationFacade, times(1)).getToscaElement(componentId); verify(nodeFilterValidator, times(1)) diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java index 3bad7dd497..31cb1ac4e4 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java @@ -437,7 +437,8 @@ public class ComponentNodeFilterServletTest extends JerseyTest { when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat); when(componentNodeFilterBusinessLogic.deleteNodeFilter(componentId, componentInstance, - NodeFilterConstraintAction.DELETE, null, 0, true, ComponentTypeEnum.RESOURCE)) + NodeFilterConstraintAction.DELETE, null, 0, true, ComponentTypeEnum.RESOURCE, + NodeFilterConstraintType.PROPERTIES)) .thenReturn(Optional.of(ciNodeFilterDataDefinition)); final Response response = target() @@ -449,7 +450,8 @@ public class ComponentNodeFilterServletTest extends JerseyTest { verify(componentNodeFilterBusinessLogic, times(1)) .deleteNodeFilter(anyString(), anyString(), ArgumentMatchers.any(NodeFilterConstraintAction.class), - nullable(String.class), anyInt(), anyBoolean(), ArgumentMatchers.any(ComponentTypeEnum.class)); + nullable(String.class), anyInt(), anyBoolean(), ArgumentMatchers.any(ComponentTypeEnum.class), + ArgumentMatchers.any(NodeFilterConstraintType.class)); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200); } |