2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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.openecomp.sdc.translator.services.heattotosca;
23 import org.junit.Test;
25 import static org.junit.Assert.assertEquals;
27 public class ConsolidationDataUtilTest {
28 private static final String PORT_TYPE_FORMAT_1 = "a_11_network_port_22";
29 private static final String PORT_TYPE_FORMAT_2 = "a_11_network_port22";
30 private static final String PORT_TYPE_FORMAT_3 = "a_network_port_22";
31 private static final String PORT_TYPE_FORMAT_4 = "a_network_port22";
32 private static final String PORT_TYPE_FORMAT_5 = "network_port_22";
33 private static final String PORT_TYPE_FORMAT_6 = "network_port22";
34 private static final String PORT_TYPE_FORMAT_7 = "a_network_11_port22";
35 private static final String PORT_TYPE_OUTPUT_1 = "a_network_port_22";
36 private static final String PORT_TYPE_OUTPUT_2 = "a_network_port22";
37 private static final String PORT_TYPE_OUTPUT_3 = "network_port_22";
38 private static final String PORT_TYPE_OUTPUT_4 = "network_port22";
39 private static final String PORT_TYPE_OUTPUT_5 = "a_network_11_port22";
41 private static final String VM_TYPE = "a";
44 public void testGetPortType_Empty() {
46 assertEquals(ConsolidationDataUtil.getPortType(port, VM_TYPE), port);
50 public void testGetPortType_Spaces() {
52 assertEquals(ConsolidationDataUtil.getPortType(port, VM_TYPE), port);
56 public void testGetPortType_Null() {
58 assertEquals(ConsolidationDataUtil.getPortType(port, VM_TYPE), port);
62 public void testGetPortType_OnlyPortType() {
63 String port = "network";
64 assertEquals(ConsolidationDataUtil.getPortType(port, VM_TYPE), port);
68 public void testGetPortType_WithServerAndPortIndex() {
69 assertEquals(PORT_TYPE_OUTPUT_1, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_1, VM_TYPE));
73 public void testGetPortType_Input_WithServerAndPortIndexWithoutUnderscore() {
74 assertEquals(PORT_TYPE_OUTPUT_2, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_2, VM_TYPE));
78 public void testGetPortType_Input_WithoutServerIndexAndWithPortIndex() {
79 assertEquals(PORT_TYPE_OUTPUT_1, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_3, VM_TYPE));
83 public void testGetPortType_Input_WithoutServerIndexAndWithPortIndexWithoutUnderscore() {
84 assertEquals(PORT_TYPE_OUTPUT_2, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_4, VM_TYPE));
88 public void testGetPortType_Input_PortTypeWithIndex() {
89 assertEquals(PORT_TYPE_OUTPUT_3, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_5, VM_TYPE));
93 public void testGetPortType_Input_PortIndexWithoutUnderscore() {
94 assertEquals(PORT_TYPE_OUTPUT_4, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_6, VM_TYPE));
98 public void testGetPortType_Input_PortIndexAndDigitInBetween() {
99 assertEquals(PORT_TYPE_OUTPUT_5, ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_7, VM_TYPE));