2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.mso.bpmn.common.scripts
23 import static org.mockito.Mockito.*
24 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
25 import static org.junit.Assert.*;
26 import org.junit.Test;
28 class NetworkUtilsTest {
30 def volumeRequestXml = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
32 <action>CREATE_VF_MODULE_VOL</action>
34 <service-instance-id/>
38 <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
39 <vnf-type>Test/vSAMP12</vnf-type>
40 <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
41 <asdc-service-model-version>2.0</asdc-service-model-version>
42 <aic-cloud-region>mdt1</aic-cloud-region>
43 <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
44 <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>
45 <backout-on-failure></backout-on-failure>
48 <param name="vnf_name">STMTN5MMSC20</param>
49 <param name="vnf_name2">US1117MTSNJVBR0246</param>
54 public void testIsRollbackEnabled() {
56 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
57 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
58 when(mockExecution.getVariable("URN_mso_rollback")).thenReturn(true)
60 NetworkUtils networkUtils = new NetworkUtils()
61 def rollbackEnabled = networkUtils.isRollbackEnabled(mockExecution, volumeRequestXml)
63 assertEquals(true, rollbackEnabled)
68 public void testIsRollbackEnabled2() {
70 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
71 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
72 when(mockExecution.getVariable("URN_mso_rollback")).thenReturn(false)
74 NetworkUtils networkUtils = new NetworkUtils()
75 def rollbackEnabled = networkUtils.isRollbackEnabled(mockExecution, volumeRequestXml)
77 assertEquals(false, rollbackEnabled)
82 public void testGetIpvVersion() {
84 NetworkUtils networkUtils = new NetworkUtils()
86 String version4 = networkUtils.getIpvVersion("ipv4")
87 assertEquals("4", version4)
89 String version6 = networkUtils.getIpvVersion("ipv6")
90 assertEquals("6", version6)
92 String versionDigit4 = networkUtils.getIpvVersion("4")
93 assertEquals("4", versionDigit4)