Updating etsi-sol003-lcm-api module
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / adapter / vnfm / tasks / utils / UserParamInputParametersProviderTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertTrue;
25 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.ADDITIONAL_PARAMS_VALUE;
26 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINKS_VALUE;
27 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINK_VALUE;
28 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getUserParamsMap;
29 import java.util.Collections;
30 import java.util.List;
31 import java.util.Map;
32 import org.junit.Test;
33 import org.onap.etsi.sol003.adapter.lcm.v1.model.ExternalVirtualLink;
34
35 /**
36  * @author Waqas Ikram (waqas.ikram@ericsson.com)
37  *
38  */
39 public class UserParamInputParametersProviderTest {
40
41     @Test
42     public void testGetInputParameter_ValidUserParams_NotEmptyInputParameter() throws Exception {
43         final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
44
45         final InputParameter actual =
46                 objUnderTest.getInputParameter(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINKS_VALUE));
47         assertNotNull(actual);
48
49         final Map<String, String> actualAdditionalParams = actual.getAdditionalParams();
50         assertEquals(3, actualAdditionalParams.size());
51
52         final String actualInstanceType = actualAdditionalParams.get("instance_type");
53         assertEquals("m1.small", actualInstanceType);
54
55         final List<ExternalVirtualLink> actualExtVirtualLinks = actual.getExtVirtualLinks();
56         assertEquals(1, actualExtVirtualLinks.size());
57
58         final ExternalVirtualLink actualExternalVirtualLink = actualExtVirtualLinks.get(0);
59         assertEquals("ac1ed33d-8dc1-4800-8ce8-309b99c38eec", actualExternalVirtualLink.getId());
60
61     }
62
63     @Test
64     public void testGetInputParameter_EmptyOrNullUserParams_EmptyInputParameter() throws Exception {
65         final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
66
67         InputParameter actual = objUnderTest.getInputParameter(Collections.emptyMap());
68         assertNotNull(actual);
69         assertTrue(actual.getAdditionalParams().isEmpty());
70         assertTrue(actual.getExtVirtualLinks().isEmpty());
71
72         actual = objUnderTest.getInputParameter(null);
73         assertNotNull(actual);
74         assertTrue(actual instanceof NullInputParameter);
75         assertTrue(actual.getAdditionalParams().isEmpty());
76         assertTrue(actual.getExtVirtualLinks().isEmpty());
77
78     }
79
80     @Test
81     public void testGetInputParameter_InValidExtVirtualLinks_NotEmptyInputParameter() throws Exception {
82         final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
83
84         final InputParameter actual =
85                 objUnderTest.getInputParameter(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINK_VALUE));
86         assertNotNull(actual);
87
88         final Map<String, String> actualAdditionalParams = actual.getAdditionalParams();
89         assertEquals(3, actualAdditionalParams.size());
90
91         final String actualInstanceType = actualAdditionalParams.get("instance_type");
92         assertEquals("m1.small", actualInstanceType);
93
94         assertTrue(actual.getExtVirtualLinks().isEmpty());
95
96     }
97
98 }