Catalog alignment
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / nodeFilter / ServiceFilterUtilsServiceInputTest.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.sdc.be.nodeFilter;
18
19 import org.junit.Test;
20 import org.openecomp.sdc.be.impl.ServiceFilterUtils;
21 import org.openecomp.sdc.be.model.InputDefinition;
22
23 import java.util.Arrays;
24 import java.util.Set;
25
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
29
30 public class ServiceFilterUtilsServiceInputTest extends BaseServiceFilterUtilsTest {
31
32     private static final String CONSTRAINT_NAME = "InputName";
33
34
35     @Test
36     public void checkInputStreamIsFound() {
37         Set<String> nodesFiltersToBeDeleted = getNodeFiltersToBeDeleted(CONSTRAINT_NAME);
38         assertNotNull(nodesFiltersToBeDeleted);
39         assertTrue(nodesFiltersToBeDeleted.contains(CI_NAME));
40     }
41
42     private Set<String> getNodeFiltersToBeDeleted(String constraintName) {
43         requirementNodeFilterPropertyDataDefinition
44                 .setConstraints(Arrays.asList("mem_size:\n  equal: {get_input: " + CONSTRAINT_NAME + "}\n"));
45         InputDefinition inputDefinition = new InputDefinition();
46         inputDefinition.setName(constraintName);
47         return ServiceFilterUtils.getNodesFiltersToBeDeleted(service, inputDefinition);
48     }
49
50     @Test
51     public void checkInputStreamIsNOtFound() {
52         Set<String> nodesFiltersToBeDeleted = getNodeFiltersToBeDeleted(CONSTRAINT_NAME + " aaa bbb");
53         assertNotNull(nodesFiltersToBeDeleted);
54         assertTrue(nodesFiltersToBeDeleted.isEmpty());
55         assertFalse(nodesFiltersToBeDeleted.contains(CI_NAME));
56     }
57 }