Catalog alignment
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / NodeFilterUploadCreatorTest.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.components.impl;
18
19 import org.apache.commons.collections4.MapUtils;
20 import org.junit.Test;
21 import org.onap.sdc.tosca.services.YamlUtil;
22 import org.openecomp.sdc.be.model.UploadNodeFilterCapabilitiesInfo;
23 import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
24 import org.openecomp.sdc.be.model.UploadNodeFilterPropertyInfo;
25
26 import java.util.List;
27 import java.util.Map;
28
29 import static org.junit.Assert.assertEquals;
30 import static org.junit.Assert.assertNotNull;
31 import static org.junit.Assert.assertTrue;
32
33 public class NodeFilterUploadCreatorTest {
34
35     @Test
36     public void testSampleNodeFiler4Properties() {
37         String nodeFilterStr = "        properties:\n        - str:\n            equal: str\n"
38                                        + "        - int:\n            equal: 3\n        - str:\n            equal:\n"
39                                        + "              get_property:\n              - yyyyy_proxy 1\n              - str\n"
40                                        + "        - str:\n            equal:\n              get_property:\n"
41                                        + "              - testFilter\n              - xxx";
42         final Object o = new YamlUtil().yamlToObject(nodeFilterStr, Object.class);
43         final UploadNodeFilterInfo nodeFilterData = new NodeFilterUploadCreator().createNodeFilterData(o);
44         assertNotNull(nodeFilterData);
45         final Map<String, UploadNodeFilterCapabilitiesInfo> capabilities = nodeFilterData.getCapabilities();
46         assertTrue(MapUtils.isEmpty(capabilities));
47         final List<UploadNodeFilterPropertyInfo> properties = nodeFilterData.getProperties();
48         assertEquals(4, properties.size());
49     }
50
51     @Test
52     public void testSampleNodeFiler1Property() {
53         String nodeFilterStr = "                       properties:\n"
54                                        + "                         - TimeOut: [{ less_or_equal : { get_input: TimeOutFilter } }]";
55         final Object o = new YamlUtil().yamlToObject(nodeFilterStr, Object.class);
56         final UploadNodeFilterInfo nodeFilterData = new NodeFilterUploadCreator().createNodeFilterData(o);
57         assertNotNull(nodeFilterData);
58         final Map<String, UploadNodeFilterCapabilitiesInfo> capabilities = nodeFilterData.getCapabilities();
59         assertTrue(MapUtils.isEmpty(capabilities));
60         final List<UploadNodeFilterPropertyInfo> properties = nodeFilterData.getProperties();
61         assertEquals(1, properties.size());
62     }
63
64 }