From ca1cef5e1c74dc5e8d2fb17864648e94b9b66aa0 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Wed, 9 Mar 2022 12:10:41 +0000 Subject: Fix node filter capability issue Signed-off-by: MichaelMorris Issue-ID: SDC-3901 Change-Id: I877fcf99d154939eafe765073ecddf38bc7d9ba7 --- .../sdc/be/components/validation/NodeFilterValidator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java index 01e07eb6cd..db5de58129 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java @@ -257,11 +257,11 @@ public class NodeFilterValidator { capabilityDefinition -> capabilityDefinition.getProperties().stream().anyMatch( componentInstanceProperty -> uiConstraint.getServicePropertyName() .equalsIgnoreCase(componentInstanceProperty.getName())))).findFirst(); - if (optionalCapabilityDefinitionList.isPresent()) { - optionalComponentInstanceProperty = optionalCapabilityDefinitionList.get().stream().findAny() - .map(capabilityDefinition -> capabilityDefinition.getProperties().get(0)); + if (optionalCapabilityDefinitionList.isPresent() && !optionalCapabilityDefinitionList.get().isEmpty()) { + optionalComponentInstanceProperty = getComponentInstanceProperty(optionalCapabilityDefinitionList.get().get(0), uiConstraint.getServicePropertyName()); } } + if (optionalComponentInstanceProperty.isEmpty()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.SELECTED_PROPERTY_NOT_PRESENT, uiConstraint.getServicePropertyName())); } @@ -273,6 +273,10 @@ public class NodeFilterValidator { return isValidValueCheck(optionalComponentInstanceProperty.get().getType(), String.valueOf(uiConstraint.getValue()), uiConstraint.getServicePropertyName()); } + + private Optional getComponentInstanceProperty(CapabilityDefinition capabilityDefinition, final String propertyName){ + return capabilityDefinition.getProperties().stream().filter(property -> property.getName().equals(propertyName)).findAny(); + } private Either isValidValueCheck(String type, String value, String propertyName) { ToscaPropertyType toscaPropertyType = ToscaPropertyType.isValidType(type); -- cgit 1.2.3-korg