No properties found when trying to add a node filter to a VF
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / validation / NodeFilterValidatorTest.java
index e1d8e46..cf6bc72 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,31 +27,38 @@ import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
 import fj.data.Either;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
 import org.openecomp.sdc.be.config.ConfigurationManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
 import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
 import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
 import org.openecomp.sdc.be.datatypes.enums.PropertySource;
 import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
 import org.openecomp.sdc.be.model.PropertyDefinition;
 import org.openecomp.sdc.be.model.Service;
 import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
@@ -67,18 +74,45 @@ class NodeFilterValidatorTest {
     private static final String INNER_SERVICE = "innerService";
     private static final String PROPERTY_NAME = "Prop1";
     private static final String COMPONENT1_ID = "component1";
-    private static final String PARENTSERVICE_ID = "parentservice";
+    private static final String PARENT_SERVICE_ID = "parentservice";
     private static final String COMPONENT2_ID = "component2";
     private ComponentsUtils componentsUtils;
 
     @Mock
-    ApplicationDataTypeCache applicationDataTypeCache;
+    private ApplicationDataTypeCache applicationDataTypeCache;
     @Mock
     private FilterConstraintValidator filterConstraintValidator;
     @InjectMocks
     private NodeFilterValidator nodeFilterValidator;
     private FilterConstraintDto baseFilterConstraintDto;
 
+    protected static ToscaGetFunctionDataDefinition createToscaGetFunction(final String sourceName,
+                                                                           final PropertySource propertySource,
+                                                                           final ToscaGetFunctionType toscaGetFunctionType,
+                                                                           final List<String> propertyPathFromSource,
+                                                                           final List<Object> toscaIndexList) {
+        final var toscaGetFunction = new ToscaGetFunctionDataDefinition();
+        toscaGetFunction.setFunctionType(toscaGetFunctionType);
+        toscaGetFunction.setPropertyPathFromSource(propertyPathFromSource);
+        toscaGetFunction.setSourceName(sourceName);
+        toscaGetFunction.setPropertySource(propertySource);
+        toscaGetFunction.setPropertyName(propertyPathFromSource.get(0));
+        toscaGetFunction.setToscaIndexList(toscaIndexList);
+        return toscaGetFunction;
+    }
+
+    private static FilterConstraintDto buildFilterConstraintDto(final String propertyName, final FilterValueType valueType,
+                                                                final ConstraintType constraintType,
+                                                                final PropertyFilterTargetType targetType, Object value) {
+        final var filterConstraintDto = new FilterConstraintDto();
+        filterConstraintDto.setPropertyName(propertyName);
+        filterConstraintDto.setValueType(valueType);
+        filterConstraintDto.setOperator(constraintType);
+        filterConstraintDto.setTargetType(targetType);
+        filterConstraintDto.setValue(value);
+        return filterConstraintDto;
+    }
+
     @BeforeEach
     void setup() {
         componentsUtils = Mockito.mock(ComponentsUtils.class);
@@ -98,14 +132,14 @@ class NodeFilterValidatorTest {
         final ResponseFormat expectedResponse = new ResponseFormat();
         when(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND, "?", INNER_SERVICE)).thenReturn(expectedResponse);
         Either<Boolean, ResponseFormat> either =
-                nodeFilterValidator.validateComponentInstanceExist(null, INNER_SERVICE);
+            nodeFilterValidator.validateComponentInstanceExist(null, INNER_SERVICE);
         assertTrue(either.isRight());
         assertEquals(expectedResponse, either.right().value());
 
         Service service = createService("booleanIncorrect");
-        when(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND, service.getName(), INNER_SERVICE))
+        when(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND, service.getName(), "uniqueId"))
             .thenReturn(expectedResponse);
-        either = nodeFilterValidator.validateComponentInstanceExist(service, INNER_SERVICE);
+        either = nodeFilterValidator.validateComponentInstanceExist(service, "uniqueId");
         assertTrue(either.isRight());
         assertEquals(expectedResponse, either.right().value());
 
@@ -124,7 +158,7 @@ class NodeFilterValidatorTest {
         final FilterConstraintDto filterConstraintDto = buildFilterConstraintDto(PROPERTY_NAME, FilterValueType.STATIC, ConstraintType.EQUAL,
             PropertyFilterTargetType.PROPERTY, "true");
         Either<Boolean, ResponseFormat> either =
-                nodeFilterValidator.validateFilter(service, INNER_SERVICE, filterConstraintDto);
+            nodeFilterValidator.validateFilter(service, INNER_SERVICE, filterConstraintDto);
         assertTrue(either.isRight());
         filterConstraintDto.setTargetType(PropertyFilterTargetType.CAPABILITY);
         either = nodeFilterValidator.validateFilter(service, INNER_SERVICE, filterConstraintDto);
@@ -139,10 +173,10 @@ class NodeFilterValidatorTest {
             FilterValueType.GET_PROPERTY,
             ConstraintType.EQUAL,
             PropertyFilterTargetType.PROPERTY,
-            createToscaGetFunction("test", PropertySource.INSTANCE, ToscaGetFunctionType.GET_PROPERTY, List.of("test2"))
+            createToscaGetFunction("test", PropertySource.INSTANCE, ToscaGetFunctionType.GET_PROPERTY, List.of("test2"), null)
         );
         Either<Boolean, ResponseFormat> actualValidationResult =
-                nodeFilterValidator.validateSubstitutionFilter(service, Collections.singletonList(filterConstraint1));
+            nodeFilterValidator.validateSubstitutionFilter(service, Collections.singletonList(filterConstraint1));
         assertTrue(actualValidationResult.isRight());
 
         final var filterConstraint2 = buildFilterConstraintDto(
@@ -150,10 +184,10 @@ class NodeFilterValidatorTest {
             FilterValueType.GET_PROPERTY,
             ConstraintType.EQUAL,
             PropertyFilterTargetType.PROPERTY,
-            createToscaGetFunction(PARENTSERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of("Prop1"))
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of("Prop1"), null)
         );
         actualValidationResult =
-                nodeFilterValidator.validateSubstitutionFilter(service, Collections.singletonList(filterConstraint2));
+            nodeFilterValidator.validateSubstitutionFilter(service, Collections.singletonList(filterConstraint2));
         assertTrue(actualValidationResult.isLeft());
 
         final var staticFilter1 = buildFilterConstraintDto(
@@ -199,6 +233,41 @@ class NodeFilterValidatorTest {
         assertTrue(actualValidationResult.isRight());
     }
 
+    @Test
+    void testValidateComponentFilterWithIndex() {
+        Service service = createService("string", "schema");
+        final var filterConstraint1 = buildFilterConstraintDto(
+            PROPERTY_NAME,
+            FilterValueType.GET_PROPERTY,
+            ConstraintType.EQUAL,
+            PropertyFilterTargetType.PROPERTY,
+            createToscaGetFunction("test", PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME, "alist"), List.of("1"))
+        );
+        Map<String, DataTypeDefinition> data = new HashMap<>();
+        DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
+        List<PropertyDefinition> properties = new ArrayList<>();
+        PropertyDefinition propertyDefinition = new PropertyDefinition();
+        propertyDefinition.setName("alist");
+        propertyDefinition.setType("list");
+
+        SchemaDefinition schemaDefinition = new SchemaDefinition();
+        PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
+        schemaProperty.setType("string");
+        schemaDefinition.setProperty(schemaProperty);
+        propertyDefinition.setSchema(schemaDefinition);
+
+        properties.add(propertyDefinition);
+        dataTypeDefinition.setProperties(properties);
+
+        data.put("string", dataTypeDefinition);
+        Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
+        when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
+
+        Either<Boolean, ResponseFormat> actualValidationResult =
+            nodeFilterValidator.validateSubstitutionFilter(service, Collections.singletonList(filterConstraint1));
+        assertTrue(actualValidationResult.isLeft());
+    }
+
     @Test
     void testValidateNodeFilterStaticIncorrectOperatorProvidedBoolean() {
         Service service = createService(ToscaPropertyType.BOOLEAN.getType());
@@ -210,11 +279,11 @@ class NodeFilterValidatorTest {
             "true"
         );
         final ResponseFormat expectedResponse = new ResponseFormat();
-        when(componentsUtils.getResponseFormat(ActionStatus.UNSUPPORTED_OPERATOR_PROVIDED, filterConstraintDto.getPropertyName(),
-            filterConstraintDto.getOperator().getType())
+        when(componentsUtils.getResponseFormat(ActionStatus.UNSUPPORTED_VALUE_PROVIDED, ToscaPropertyType.BOOLEAN.getType(),
+            filterConstraintDto.getPropertyName(), "\"true\"")
         ).thenReturn(expectedResponse);
         final Either<Boolean, ResponseFormat> validationResult =
-                nodeFilterValidator.validateFilter(service, INNER_SERVICE, List.of(filterConstraintDto));
+            nodeFilterValidator.validateFilter(service, INNER_SERVICE, List.of(filterConstraintDto));
         assertTrue(validationResult.isRight());
         assertEquals(expectedResponse, validationResult.right().value());
     }
@@ -225,11 +294,11 @@ class NodeFilterValidatorTest {
         baseFilterConstraintDto.setValue("trues");
 
         final ResponseFormat responseFormat = new ResponseFormat();
-        when(componentsUtils
-            .getResponseFormat(eq(ActionStatus.UNSUPPORTED_VALUE_PROVIDED), eq(ToscaPropertyType.BOOLEAN.getType()), eq(PROPERTY_NAME), any())
+        when(componentsUtils.getResponseFormat
+            (ActionStatus.UNSUPPORTED_VALUE_PROVIDED, ToscaPropertyType.BOOLEAN.getType(), PROPERTY_NAME, "\"trues\"")
         ).thenReturn(responseFormat);
         final Either<Boolean, ResponseFormat> validationResult =
-                nodeFilterValidator.validateFilter(service, INNER_SERVICE, List.of(baseFilterConstraintDto));
+            nodeFilterValidator.validateFilter(service, INNER_SERVICE, List.of(baseFilterConstraintDto));
 
         assertTrue(validationResult.isRight());
         assertEquals(responseFormat, validationResult.right().value());
@@ -241,7 +310,7 @@ class NodeFilterValidatorTest {
         baseFilterConstraintDto.setValue("true");
         baseFilterConstraintDto.setOperator(ConstraintType.GREATER_THAN);
         Either<Boolean, ResponseFormat> either =
-                nodeFilterValidator.validateFilter(service, INNER_SERVICE, List.of(baseFilterConstraintDto));
+            nodeFilterValidator.validateFilter(service, INNER_SERVICE, List.of(baseFilterConstraintDto));
 
         assertTrue(either.isLeft());
     }
@@ -309,7 +378,7 @@ class NodeFilterValidatorTest {
     void testValidatePropertyConstraintBrotherSuccess() {
         Service service = createService(ToscaPropertyType.STRING.getType());
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(COMPONENT2_ID, PropertySource.INSTANCE, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(COMPONENT2_ID, PropertySource.INSTANCE, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -328,7 +397,7 @@ class NodeFilterValidatorTest {
     void testValidatePropertyConstraintParentSuccess() {
         final var service = createService(ToscaPropertyType.STRING.getType());
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(PARENTSERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -348,7 +417,7 @@ class NodeFilterValidatorTest {
         final Service service = createService(ToscaPropertyType.STRING.getType());
         service.getComponentInstancesProperties().get(COMPONENT2_ID).get(0).setType(ToscaPropertyType.INTEGER.getType());
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(COMPONENT2_ID, PropertySource.INSTANCE, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(COMPONENT2_ID, PropertySource.INSTANCE, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -374,7 +443,7 @@ class NodeFilterValidatorTest {
         final Service service = createService(ToscaPropertyType.STRING.getType());
         service.getComponentInstancesProperties().get(COMPONENT1_ID).get(0).setType(ToscaPropertyType.INTEGER.getType());
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(PARENTSERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -405,7 +474,7 @@ class NodeFilterValidatorTest {
             .thenReturn(expectedResponse);
 
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(PARENTSERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -413,11 +482,8 @@ class NodeFilterValidatorTest {
             PropertyFilterTargetType.PROPERTY,
             toscaGetFunction
         );
-        final Either<Boolean, ResponseFormat> validationResult =
-            nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto));
-
-        assertTrue(validationResult.isRight());
-        assertEquals(expectedResponse, validationResult.right().value());
+        Assertions.assertThrows(ComponentException.class,
+            () -> nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto)));
     }
 
     @Test
@@ -425,7 +491,7 @@ class NodeFilterValidatorTest {
         Service service = createService(ToscaPropertyType.STRING.getType());
         service.getComponentInstancesProperties().get(COMPONENT1_ID).get(0).setName("Prop2");
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(PARENTSERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -436,24 +502,8 @@ class NodeFilterValidatorTest {
         final ResponseFormat expectedResponse = new ResponseFormat();
         when(componentsUtils.getResponseFormat(ActionStatus.FILTER_PROPERTY_NOT_FOUND, "Target", PROPERTY_NAME))
             .thenReturn(expectedResponse);
-        Either<Boolean, ResponseFormat> either =
-            nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto));
-
-        assertTrue(either.isRight());
-        assertEquals(expectedResponse, either.right().value());
-    }
-
-    protected static ToscaGetFunctionDataDefinition createToscaGetFunction(final String sourceName,
-                                                                           final PropertySource propertySource,
-                                                                           final ToscaGetFunctionType toscaGetFunctionType,
-                                                                           final List<String> propertyPathFromSource) {
-        final var toscaGetFunction = new ToscaGetFunctionDataDefinition();
-        toscaGetFunction.setFunctionType(toscaGetFunctionType);
-        toscaGetFunction.setPropertyPathFromSource(propertyPathFromSource);
-        toscaGetFunction.setSourceName(sourceName);
-        toscaGetFunction.setPropertySource(propertySource);
-        toscaGetFunction.setPropertyName(propertyPathFromSource.get(0));
-        return toscaGetFunction;
+        Assertions.assertThrows(ComponentException.class,
+            () -> nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto)));
     }
 
     @Test
@@ -467,7 +517,7 @@ class NodeFilterValidatorTest {
         service.getComponentInstancesProperties().get(COMPONENT1_ID).get(0).setSchema(schemaDefinition);
 
         final ToscaGetFunctionDataDefinition toscaGetFunction =
-            createToscaGetFunction(PARENTSERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME));
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
         final var filterConstraintDto = buildFilterConstraintDto(
             PROPERTY_NAME,
             FilterValueType.GET_PROPERTY,
@@ -488,18 +538,83 @@ class NodeFilterValidatorTest {
         assertEquals(expectedResponse, either.right().value());
     }
 
+    @Test
+    void testValidateNodeFilterForVfStaticValue() {
+        Service service = createService(ToscaPropertyType.INTEGER.getType());
+        addComponentInstanceToService(service, OriginTypeEnum.VF, "vfInstance", ToscaPropertyType.INTEGER.getType());
+        baseFilterConstraintDto.setValue(1);
+        Either<Boolean, ResponseFormat> validationResult =
+            nodeFilterValidator.validateFilter(service, "vfInstance", List.of(baseFilterConstraintDto));
+
+        assertTrue(validationResult.isLeft());
+    }
+
+    @Test
+    void testValidateNodeFilterForVfToscaGetProperty() {
+        Service service = createService(ToscaPropertyType.INTEGER.getType());
+        addComponentInstanceToService(service, OriginTypeEnum.VF, "vfInstance", ToscaPropertyType.INTEGER.getType());
+        final ToscaGetFunctionDataDefinition toscaGetFunction =
+            createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
+        final var filterConstraintDto = buildFilterConstraintDto(
+            PROPERTY_NAME,
+            FilterValueType.GET_PROPERTY,
+            ConstraintType.EQUAL,
+            PropertyFilterTargetType.PROPERTY,
+            toscaGetFunction
+        );
+        Either<Boolean, ResponseFormat> validationResult =
+            nodeFilterValidator.validateFilter(service, "vfInstance", List.of(filterConstraintDto));
+
+        assertTrue(validationResult.isLeft());
+    }
+
+    private void addComponentInstanceToService(Service service, OriginTypeEnum originTypeEnum, String instanceName, String type) {
+        ComponentInstance componentInstance = new ComponentInstance();
+        componentInstance.setUniqueId(instanceName);
+        componentInstance.setName(instanceName);
+        componentInstance.setOriginType(originTypeEnum);
+
+        List<ComponentInstance> compInstances = new ArrayList<>();
+        service.getComponentInstances().forEach(compInstance -> compInstances.add(compInstance));
+        compInstances.add(componentInstance);
+        service.setComponentInstances(compInstances);
+
+        if (isInput(originTypeEnum)) {
+            ComponentInstanceInput componentInstanceInput = new ComponentInstanceInput();
+            componentInstanceInput.setName(PROPERTY_NAME);
+            componentInstanceInput.setType(type);
+            if (service.getComponentInstancesInputs() == null) {
+                service.setComponentInstancesInputs(new HashMap<>());
+            }
+            service.getComponentInstancesInputs().put(instanceName, Collections.singletonList(componentInstanceInput));
+        } else {
+            ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
+            componentInstanceProperty.setName(PROPERTY_NAME);
+            componentInstanceProperty.setType(type);
+            if (service.getComponentInstancesProperties() == null) {
+                service.setComponentInstancesProperties(new HashMap<>());
+            }
+            service.getComponentInstancesProperties().put(instanceName, Collections.singletonList(componentInstanceProperty));
+        }
+    }
+
+    private boolean isInput(OriginTypeEnum instanceType) {
+        return OriginTypeEnum.VF.equals(instanceType) || OriginTypeEnum.PNF.equals(instanceType) || OriginTypeEnum.CVFC.equals(instanceType) ||
+            OriginTypeEnum.CR.equals(instanceType);
+    }
+
     private Service createService(String type) {
         return createService(type, null);
     }
 
     private Service createService(String type, String schemaType) {
         Service service = new Service();
-        service.setName(PARENTSERVICE_ID);
+        service.setName(PARENT_SERVICE_ID);
 
         PropertyDefinition propertyDefinition = new PropertyDefinition();
         propertyDefinition.setName(PROPERTY_NAME);
         propertyDefinition.setType(type);
-        if (schemaType != null){
+        if (schemaType != null) {
             SchemaDefinition schemaDefinition = new SchemaDefinition();
             PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
             schemaProperty.setType(schemaType);
@@ -511,26 +626,33 @@ class NodeFilterValidatorTest {
         ComponentInstance componentInstance = new ComponentInstance();
         componentInstance.setUniqueId(COMPONENT1_ID);
         componentInstance.setName(COMPONENT1_ID);
+        componentInstance.setOriginType(OriginTypeEnum.VFC);
 
         ComponentInstance componentInstance2 = new ComponentInstance();
         componentInstance2.setUniqueId(COMPONENT2_ID);
         componentInstance2.setName(COMPONENT2_ID);
+        componentInstance2.setOriginType(OriginTypeEnum.VFC);
 
-        service.setComponentInstances(Arrays.asList(componentInstance, componentInstance2));
+        ComponentInstance componentInstance3 = new ComponentInstance();
+        componentInstance3.setUniqueId(INNER_SERVICE);
+        componentInstance3.setName(INNER_SERVICE);
+        componentInstance3.setOriginType(OriginTypeEnum.ServiceProxy);
 
-        ComponentInstanceProperty componentInstanceProperty  = new ComponentInstanceProperty();
+        service.setComponentInstances(Arrays.asList(componentInstance, componentInstance2, componentInstance3));
+
+        ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
         componentInstanceProperty.setName(PROPERTY_NAME);
         componentInstanceProperty.setType(type);
 
-        ComponentInstanceProperty componentInstanceProperty2  = new ComponentInstanceProperty();
+        ComponentInstanceProperty componentInstanceProperty2 = new ComponentInstanceProperty();
         componentInstanceProperty2.setName(PROPERTY_NAME);
         componentInstanceProperty2.setType(type);
 
         Map<String, List<ComponentInstanceProperty>> componentInstancePropertyMap = new HashMap<>();
         componentInstancePropertyMap.put(componentInstance.getUniqueId(),
-                Collections.singletonList(componentInstanceProperty));
+            Collections.singletonList(componentInstanceProperty));
         componentInstancePropertyMap.put(componentInstance2.getUniqueId(),
-                Collections.singletonList(componentInstanceProperty2));
+            Collections.singletonList(componentInstanceProperty2));
         componentInstancePropertyMap.put(INNER_SERVICE, Collections.singletonList(componentInstanceProperty));
 
         service.setComponentInstancesProperties(componentInstancePropertyMap);
@@ -538,16 +660,4 @@ class NodeFilterValidatorTest {
         return service;
     }
 
-    private static FilterConstraintDto buildFilterConstraintDto(final String propertyName, final FilterValueType valueType,
-                                                                final ConstraintType constraintType,
-                                                                final PropertyFilterTargetType targetType, Object value) {
-        final var filterConstraintDto = new FilterConstraintDto();
-        filterConstraintDto.setPropertyName(propertyName);
-        filterConstraintDto.setValueType(valueType);
-        filterConstraintDto.setOperator(constraintType);
-        filterConstraintDto.setTargetType(targetType);
-        filterConstraintDto.setValue(value);
-        return filterConstraintDto;
-    }
-
 }