2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.be.nodeFilter;
19 import static org.junit.jupiter.api.Assertions.assertNotNull;
20 import static org.junit.jupiter.api.Assertions.assertTrue;
22 import java.util.List;
24 import org.junit.jupiter.api.Test;
25 import org.openecomp.sdc.be.datatypes.elements.PropertyFilterConstraintDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
27 import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
28 import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
29 import org.openecomp.sdc.be.datatypes.enums.PropertySource;
30 import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
31 import org.openecomp.sdc.be.impl.ServiceFilterUtils;
32 import org.openecomp.sdc.be.model.InputDefinition;
34 class ServiceFilterUtilsServiceInputTest extends BaseServiceFilterUtilsTest {
36 private static final String CONSTRAINT_NAME = "InputName";
39 void checkInputStreamIsFound() {
40 Set<String> nodesFiltersToBeDeleted = getNodeFiltersToBeDeleted(CONSTRAINT_NAME);
41 assertNotNull(nodesFiltersToBeDeleted);
42 assertTrue(nodesFiltersToBeDeleted.contains(CI_NAME));
45 private Set<String> getNodeFiltersToBeDeleted(String constraintName) {
46 final var propertyFilterConstraint = new PropertyFilterConstraintDataDefinition();
47 propertyFilterConstraint.setPropertyName("mem_size");
48 propertyFilterConstraint.setOperator(ConstraintType.EQUAL);
50 propertyFilterConstraint.setValue(
51 createToscaGetFunction(PropertySource.SELF.getName(), ToscaGetFunctionType.GET_INPUT, List.of(CONSTRAINT_NAME))
53 propertyFilterConstraint.setValueType(FilterValueType.GET_INPUT);
54 propertyFilterConstraint.setTargetType(PropertyFilterTargetType.PROPERTY);
55 propertyFilterDataDefinition.setConstraints(List.of(propertyFilterConstraint));
56 InputDefinition inputDefinition = new InputDefinition();
57 inputDefinition.setName(constraintName);
58 return ServiceFilterUtils.getNodesFiltersToBeDeleted(service, inputDefinition);
62 public void checkInputStreamIsNotFound() {
63 Set<String> nodesFiltersToBeDeleted = getNodeFiltersToBeDeleted(CONSTRAINT_NAME + " aaa bbb");
64 assertNotNull(nodesFiltersToBeDeleted);
65 assertTrue(nodesFiltersToBeDeleted.isEmpty());