d6bbc934149933945b03f4be6a4fe747a5b8efec
[sdc/sdc-tosca.git] / sdc-tosca / src / test / java / org / onap / sdc / impl / ToscaParserServiceInputTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc-tosca
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T 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.onap.sdc.impl;
22
23 import org.testng.annotations.Test;
24 import org.onap.sdc.toscaparser.api.parameters.Input;
25
26 import java.util.List;
27
28 import static org.testng.Assert.assertEquals;
29 import static org.testng.Assert.assertNotNull;
30 import static org.testng.Assert.assertNull;
31
32 public class ToscaParserServiceInputTest extends SdcToscaParserBasicTest {
33
34     //region getServiceInputs
35     @Test
36     public void testGetServiceInputs(){
37         List<Input> serviceInputs = fdntCsarHelper.getServiceInputs();
38         assertNotNull(serviceInputs);
39         assertEquals(1, serviceInputs.size());
40     }
41
42     @Test
43     public void testServiceInputs() {
44         List<Input> inputs = rainyCsarHelperSingleVf.getServiceInputs();
45         assertNotNull(inputs);
46         assertEquals(0, inputs.size());
47     }
48     //endregion
49
50     //region getServiceInputLeafValueOfDefault
51     @Test
52     public void testGetServiceInputLeafValue(){
53         String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
54         assertEquals("test service naming", serviceInputLeafValue);
55     }
56
57 //    @Test
58 //    public void testGetServiceInputLeafValueWithGetInput(){
59 //        String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("my_input#default");
60 //        assertEquals(null, serviceInputLeafValue);
61 //    }
62
63     @Test
64     public void testGetServiceInputLeafValueNotExists(){
65         String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
66         assertNull(serviceInputLeafValue);
67     }
68
69     @Test
70     public void testGetServiceInputLeafValueNull(){
71         String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault(null);
72         assertNull(serviceInputLeafValue);
73     }
74     //endregion
75
76     //region getServiceInputLeafValueOfDefaultAsObject
77     @Test
78     public void testGetServiceInputLeafValueOfDefaultAsObject() {
79         Object serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
80         assertEquals("test service naming", serviceInputLeafValue);
81     }
82     
83     @Test
84     public void testGetServiceComplexInputLeafValueOfDefault() {
85         String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#cidr_mask");
86         assertEquals(serviceInputLeafValue, "24");
87     }
88     
89     @Test
90     public void testGetServiceDummyComplexInputLeafValueOfDefault() {
91         String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#XXX");
92         assertNull(serviceInputLeafValue);
93     }
94     
95     
96     //endregion
97 }