replace all fixed wiremock ports
[so.git] / bpmn / so-bpmn-infrastructure-common / src / test / groovy / org / onap / so / bpmn / infrastructure / scripts / DoUpdateVfModuleTest.groovy
index beaebce..f16bc57 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,9 @@ import org.mockito.ArgumentCaptor
 import org.mockito.Captor
 import org.mockito.Mockito
 import org.mockito.MockitoAnnotations
+import org.mockito.Spy
 import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
 import org.onap.so.bpmn.common.scripts.VfModule
 import org.onap.so.bpmn.core.WorkflowException
 import org.onap.so.bpmn.mock.FileUtil
@@ -45,7 +47,7 @@ import static org.mockito.Mockito.*
 import org.onap.so.bpmn.common.scripts.utils.XmlComparator
 
 @RunWith(MockitoJUnitRunner.class)
-class DoUpdateVfModuleTest {
+class DoUpdateVfModuleTest extends MsoGroovyTest{
 
     def prefix = "DOUPVfMod_"
     String doUpdateVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/DoUpdateVfModuleRequest.xml");
@@ -55,12 +57,14 @@ class DoUpdateVfModuleTest {
     @Captor
     static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
 
-    @Rule
-    public WireMockRule wireMockRule = new WireMockRule(28090);
+    @Spy
+    DoUpdateVfModule doUpdateVfModule
 
     @Before
     public void init() {
+        super.init("DoUpdateVfModule")
         MockitoAnnotations.initMocks(this)
+        when(doUpdateVfModule.getAAIClient()).thenReturn(client)
     }
 
     @Test
@@ -77,14 +81,14 @@ class DoUpdateVfModuleTest {
         Mockito.verify(mockExecution, atLeastOnce()).getVariable("mso.workflow.sdncadapter.callback")
     }
 
-  
+
 
     @Test
     void testPrepConfirmVolumeGroupTenant() {
         ExecutionEntity mockExecution = setupMock()
         when(mockExecution.getVariable("prefix")).thenReturn(prefix)
         when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
-        when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("att-aic")
+        when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("CloudOwner")
         when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region")
         when(mockExecution.getVariable("mso.workflow.default.aai.cloud-region.version")).thenReturn("8")
         when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
@@ -94,13 +98,13 @@ class DoUpdateVfModuleTest {
         DoUpdateVfModule obj = new DoUpdateVfModule()
         obj.prepConfirmVolumeGroupTenant(mockExecution)
 
-        Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic")
+        Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner")
         Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionReturnCode", "200")
         Mockito.verify(mockExecution).setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
         Mockito.verify(mockExecution).setVariable(prefix + "isCloudRegionGood", true)
     }
 
-  
+
     @Test
     void testPrepSDNCTopologyChg() {
         ExecutionEntity mockExecution = setupMock()
@@ -148,7 +152,7 @@ class DoUpdateVfModuleTest {
         XmlComparator.assertXMLEquals(sdncChangeAssignRequest, captor.getValue())
     }
 
-   
+
 
     @Test
     void testPrepSDNCTopologyQuery() {
@@ -168,13 +172,14 @@ class DoUpdateVfModuleTest {
         XmlComparator.assertXMLEquals(sdncTopologyRequest, captor.getValue())
     }
 
-  
+
 
     @Test
     void testPrepVnfAdapterRest() {
         ExecutionEntity mockExecution = setupMock()
         when(mockExecution.getVariable("prefix")).thenReturn(prefix)
         when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP")
+        when(mockExecution.getVariable(prefix + "cloudRegion")).thenReturn("CloudOwner")
         when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32")
         when(mockExecution.getVariable(prefix + "volumeGroupStackId")).thenReturn("12345")
         when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2")
@@ -219,7 +224,7 @@ class DoUpdateVfModuleTest {
         XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl")
     }
 
-   
+
 
     @Test
     void testPrepSDNCTopologyAct() {
@@ -258,19 +263,15 @@ class DoUpdateVfModuleTest {
 
     @Test
     void testQueryAAIVfModule() {
-        ExecutionEntity mockExecution = setupMock()
         when(mockExecution.getVariable("prefix")).thenReturn(prefix)
-        when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
         when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345")
-        when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8")
-        when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
-        when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
-        when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
 
-        mockData()
-        DoUpdateVfModule obj = new DoUpdateVfModule()
-        obj.queryAAIVfModule(mockExecution)
+        mockAAIGenericVnf("12345","__files/AAI/GenericVnfVfModule.json")
+        doUpdateVfModule.queryAAIVfModule(mockExecution)
         Mockito.verify(mockExecution).setVariable(prefix + "queryAAIVfModuleResponseCode", 200)
+        Mockito.verify(mockExecution).setVariable("DOUPVfMod_baseVfModuleId", "lukewarm")
+        Mockito.verify(mockExecution).setVariable("DOUPVfMod_baseVfModuleHeatStackId", "fastburn")
+
     }
 
 
@@ -296,7 +297,7 @@ class DoUpdateVfModuleTest {
     }
 
     private static void mockData() {
-        stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic"))
+        stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner"))
                 .willReturn(aResponse()
                 .withStatus(200).withHeader("Content-Type", "text/xml")
                 .withBodyFile("DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml")))