2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.tosca.model;
23 import org.junit.jupiter.api.Test;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
29 import static org.junit.jupiter.api.Assertions.assertTrue;
30 import static org.junit.jupiter.api.Assertions.assertFalse;
32 public class NodeFilterTest {
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);
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);
55 public void testHasDataTrue() {
56 NodeFilter nodeFilter = new NodeFilter();
57 createCapabilities(nodeFilter);
58 createProperties(nodeFilter);
59 boolean result = nodeFilter.hasData();
64 public void testHasDataCapabilityTrue() {
65 NodeFilter nodeFilter = new NodeFilter();
66 createCapabilities(nodeFilter);
67 boolean result = nodeFilter.hasData();
72 public void testHasDataPropertiesTrue() {
73 NodeFilter nodeFilter = new NodeFilter();
74 createProperties(nodeFilter);
75 boolean result = nodeFilter.hasData();
80 public void testHasDataFalse() {
81 NodeFilter nodeFilter = new NodeFilter();
82 boolean result = nodeFilter.hasData();