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.onap.so.bpmn.common.scripts
23 import org.junit.Before
24 import org.mockito.MockitoAnnotations
26 import static org.mockito.Mockito.*
27 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
28 import static org.junit.Assert.*;
29 import org.junit.Test;
31 class NetworkUtilsTest {
33 def volumeRequestXml = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
35 <action>CREATE_VF_MODULE_VOL</action>
37 <service-instance-id/>
41 <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
42 <vnf-type>Test/vSAMP12</vnf-type>
43 <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
44 <asdc-service-model-version>2.0</asdc-service-model-version>
45 <aic-cloud-region>mdt1</aic-cloud-region>
46 <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
47 <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>
48 <backout-on-failure></backout-on-failure>
51 <param name="vnf_name">STMTN5MMSC20</param>
52 <param name="vnf_name2">US1117MTSNJVBR0246</param>
58 public void testIsRollbackEnabled() {
60 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
61 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
62 when(mockExecution.getVariable("mso.rollback")).thenReturn(true)
64 NetworkUtils networkUtils = new NetworkUtils()
65 def rollbackEnabled = networkUtils.isRollbackEnabled(mockExecution, volumeRequestXml)
67 assertEquals(true, rollbackEnabled)
72 public void testIsRollbackEnabled2() {
74 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
75 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
76 when(mockExecution.getVariable("mso.rollback")).thenReturn(false)
78 NetworkUtils networkUtils = new NetworkUtils()
79 def rollbackEnabled = networkUtils.isRollbackEnabled(mockExecution, volumeRequestXml)
81 assertEquals(false, rollbackEnabled)
86 public void testGetIpvVersion() {
88 NetworkUtils networkUtils = new NetworkUtils()
90 String version4 = networkUtils.getIpvVersion("ipv4")
91 assertEquals("4", version4)
93 String version6 = networkUtils.getIpvVersion("ipv6")
94 assertEquals("6", version6)
96 String versionDigit4 = networkUtils.getIpvVersion("4")
97 assertEquals("4", versionDigit4)