Release version 1.13.7
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / tosca / model / NodeFilterTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2020 Samsung Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.tosca.model;
22
23 import org.junit.jupiter.api.Test;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 import static org.junit.jupiter.api.Assertions.assertTrue;
30 import static org.junit.jupiter.api.Assertions.assertFalse;
31
32 public class NodeFilterTest {
33
34     private void createCapabilities(NodeFilter nodeFilter) {
35         List<Map<String, CapabilityFilter>> capabilitiesCopy = new ArrayList<>();
36         Map<String, CapabilityFilter> capabilityDataMap = new HashMap<>();
37         CapabilityFilter capabilityFilter = new CapabilityFilter();
38         capabilityDataMap.put("test", capabilityFilter);
39         capabilitiesCopy.add(capabilityDataMap);
40         nodeFilter.setCapabilities(capabilitiesCopy);
41     }
42
43     private void createProperties(NodeFilter nodeFilter) {
44         List<Map<String, List<Object>>> propertiesCopy = new ArrayList<>();
45         Map<String, List<Object>> propertyDataMap = new HashMap<>();
46         List<Object> dataObjectList = new ArrayList<>();
47         Object object = new Object();
48         dataObjectList.add(object);
49         propertyDataMap.put("test", dataObjectList);
50         propertiesCopy.add(propertyDataMap);
51         nodeFilter.setProperties(propertiesCopy);
52     }
53
54     @Test
55     public void testHasDataTrue() {
56         NodeFilter nodeFilter = new NodeFilter();
57         createCapabilities(nodeFilter);
58         createProperties(nodeFilter);
59         boolean result = nodeFilter.hasData();
60         assertTrue(result);
61     }
62
63     @Test
64     public void testHasDataCapabilityTrue() {
65         NodeFilter nodeFilter = new NodeFilter();
66         createCapabilities(nodeFilter);
67         boolean result = nodeFilter.hasData();
68         assertTrue(result);
69     }
70
71     @Test
72     public void testHasDataPropertiesTrue() {
73         NodeFilter nodeFilter = new NodeFilter();
74         createProperties(nodeFilter);
75         boolean result = nodeFilter.hasData();
76         assertTrue(result);
77     }
78
79     @Test
80     public void testHasDataFalse() {
81         NodeFilter nodeFilter = new NodeFilter();
82         boolean result = nodeFilter.hasData();
83         assertFalse(result);
84     }
85 }