From 49bb3328fe6d538606ce75506314be1e91e1a7e7 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 1 Mar 2019 12:53:12 -0500 Subject: use async activity call in UpdateNetwork BB remove references to AIC in comments use async activity call in UpdateNetwork BB Change-Id: I46472571078ac335bc85c865fdd82964b68c0d75 Issue-ID: SO-1583 Signed-off-by: Benjamin, Max (mb388a) --- .../aai/tasks/AAIUpdateTasksTest.java | 24 +++++++++++++ .../tasks/NetworkAdapterUpdateTasksTest.java | 39 ++++++---------------- 2 files changed, 35 insertions(+), 28 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/test/java') diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index 73d7257632..a8a249f386 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -43,6 +43,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -456,6 +457,29 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue(); assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId()); } + + @Test + public void updateNetworkUpdatedTest() throws Exception { + UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse(); + updateNetworkResponse.setNeutronNetworkId("testNeutronNetworkId"); + HashMap subnetMap = new HashMap<>(); + subnetMap.put("testSubnetId", "testNeutronSubnetId"); + updateNetworkResponse.setSubnetMap(subnetMap); + + network.getSubnets().add(subnet); + + execution.setVariable("updateNetworkResponse", updateNetworkResponse); + + doNothing().when(aaiNetworkResources).updateNetwork(network); + doNothing().when(aaiNetworkResources).updateSubnet(network, subnet); + + aaiUpdateTasks.updateNetworkUpdated(execution); + verify(aaiNetworkResources, times(1)).updateNetwork(network); + verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet); + + String neutronSubnetId = updateNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue(); + assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId()); + } @Test public void updateOrchestrationStatusNetworkTest() { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java index 9f2f2fbdcc..478c512b0a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -39,6 +40,8 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -83,35 +86,15 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{ @Test public void updateNetworkTest() throws Exception { - UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse(); - updateNetworkResponse.setMessageId("messageId"); - updateNetworkResponse.setNetworkId("networkId"); - Optional oUpdateNetworkResponse = Optional.of(updateNetworkResponse); - - doReturn(oUpdateNetworkResponse).when(networkAdapterResources).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - - networkAdapterUpdateTasks.updateNetwork(execution); - - verify(networkAdapterResources, times(1)).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - assertEquals(updateNetworkResponse, execution.getVariable("NetworkAdapterUpdateNetworkResponse")); - } - - @Test - public void updateNetworkNoResponseTest() throws Exception { - doReturn(Optional.empty()).when(networkAdapterResources).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - + String cloudRegionPo = "cloudRegionPo"; + UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); + execution.setVariable("cloudRegionPo", cloudRegionPo); + + doReturn(updateNetworkRequest).when(networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class)); networkAdapterUpdateTasks.updateNetwork(execution); - - verify(networkAdapterResources, times(1)).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - assertNull(execution.getVariable("NetworkAdapterUpdateNetworkResponse")); + verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); + assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest")); } - @Test - public void updateNetworkExceptionTest() throws UnsupportedEncodingException, NetworkAdapterClientException { - expectedException.expect(BpmnError.class); - doThrow(new NetworkAdapterClientException("ERROR")).when(networkAdapterResources).updateNetwork(any(RequestContext.class),any(CloudRegion.class), - any(OrchestrationContext.class),eq(serviceInstance),eq(network),any(Map.class),any(Customer.class)); - doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); - networkAdapterUpdateTasks.updateNetwork(execution); - } + } -- cgit 1.2.3-korg