+ @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);
+ }
+