2 * ============LICENSE_START=======================================================
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
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.onap.sdc.impl;
23 import org.junit.jupiter.api.Test;
24 import org.junit.jupiter.api.extension.ExtendWith;
25 import org.onap.sdc.toscaparser.api.parameters.Input;
27 import java.util.List;
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;
33 @ExtendWith({SdcToscaParserBasicTest.class})
34 class ToscaParserServiceInputTest extends SdcToscaParserBasicTest {
36 //region getServiceInputs
38 public void testGetServiceInputs(){
39 List<Input> serviceInputs = fdntCsarHelper.getServiceInputs();
40 assertNotNull(serviceInputs);
41 assertEquals(1, serviceInputs.size());
45 public void testServiceInputs() {
46 List<Input> inputs = rainyCsarHelperSingleVf.getServiceInputs();
47 assertNotNull(inputs);
48 assertEquals(0, inputs.size());
52 //region getServiceInputLeafValueOfDefault
54 public void testGetServiceInputLeafValue(){
55 String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
56 assertEquals("test service naming", serviceInputLeafValue);
60 // public void testGetServiceInputLeafValueWithGetInput(){
61 // String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("my_input#default");
62 // assertEquals(null, serviceInputLeafValue);
66 public void testGetServiceInputLeafValueNotExists(){
67 String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
68 assertNull(serviceInputLeafValue);
72 public void testGetServiceInputLeafValueNull(){
73 String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault(null);
74 assertNull(serviceInputLeafValue);
78 //region getServiceInputLeafValueOfDefaultAsObject
80 public void testGetServiceInputLeafValueOfDefaultAsObject() {
81 Object serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
82 assertEquals("test service naming", serviceInputLeafValue);
86 public void testGetServiceComplexInputLeafValueOfDefault() {
87 String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#cidr_mask");
88 assertEquals(serviceInputLeafValue, "24");
92 public void testGetServiceDummyComplexInputLeafValueOfDefault() {
93 String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#XXX");
94 assertNull(serviceInputLeafValue);