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