From 164c1b520ae15c5e2a71559586309a532126f7fe Mon Sep 17 00:00:00 2001 From: "Kalkere Ramesh, Sharan (sk720x)" Date: Thu, 6 Dec 2018 15:26:31 -0500 Subject: change all sdnc calls Change-Id: I85c9e0c35b543f86818f6689df6c64198fe2bf35 Issue-ID: SO-1287 Signed-off-by: Kalkere Ramesh, Sharan (sk720x) --- .../sdnc/tasks/SDNCActivateTasks.java | 46 ++--- .../infrastructure/sdnc/tasks/SDNCAssignTasks.java | 27 ++- .../sdnc/tasks/SDNCChangeAssignTasks.java | 37 ++-- .../sdnc/tasks/SDNCDeactivateTasks.java | 61 +++---- .../sdnc/tasks/SDNCUnassignTasks.java | 58 ++++--- .../client/orchestration/SDNCNetworkResources.java | 113 ++++++------- .../SDNCServiceInstanceResources.java | 77 ++++----- .../orchestration/SDNCVfModuleResources.java | 77 ++++----- .../so/client/orchestration/SDNCVnfResources.java | 44 ++--- .../sdnc/tasks/SDNCActivateTaskTest.java | 25 +-- .../sdnc/tasks/SDNCAssignTasksTest.java | 34 ++-- .../sdnc/tasks/SDNCChangeAssignTasksTest.java | 28 ++- .../sdnc/tasks/SDNCDeactivateTaskTest.java | 60 +++---- .../sdnc/tasks/SDNCUnassignTasksTest.java | 43 ++--- .../orchestration/SDNCNetworkResourcesTest.java | 188 +++++++++------------ .../SDNCServiceInstanceResourcesTest.java | 49 ++---- .../orchestration/SDNCVfModuleResourcesTest.java | 74 ++++---- .../client/orchestration/SDNCVnfResourcesTest.java | 71 +++----- 18 files changed, 496 insertions(+), 616 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java index e587e80251..43ee71e676 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java @@ -20,6 +20,9 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -36,6 +39,8 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.SDNCNetworkResources; import org.onap.so.client.orchestration.SDNCVfModuleResources; import org.onap.so.client.orchestration.SDNCVnfResources; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -63,8 +68,11 @@ public class SDNCActivateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); Customer customer = gBBInput.getCustomer(); - String response = sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("SDNCResponse", response); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VNF); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -76,18 +84,18 @@ public class SDNCActivateTasks { * @throws BBObjectNotFoundException */ public void activateNetwork(BuildingBlockExecution execution) throws BBObjectNotFoundException { - execution.setVariable("sdncNetworkActivateRollback", false); - GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - - Customer customer = gBBInput.getCustomer(); - RequestContext requestContext = gBBInput.getRequestContext(); - CloudRegion cloudRegion = gBBInput.getCloudRegion(); - try { - sdncNetworkResources.activateNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion); - execution.setVariable("sdncNetworkActivateRollback", true); + try{ + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + Customer customer = gBBInput.getCustomer(); + RequestContext requestContext = gBBInput.getRequestContext(); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.activateNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.NETWORK); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -108,12 +116,12 @@ public class SDNCActivateTasks { execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - execution.setVariable("sdncActivateVfModuleRollback", false); - - String response = sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("SDNCActivateVfModuleResponse", response); - execution.setVariable("sdncActivateVfModuleRollback", true); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VFMODULE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index 30f38fc2ed..2695a170b4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -20,6 +20,9 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -67,8 +70,11 @@ public class SDNCAssignTasks { RequestContext requestContext = gBBInput.getRequestContext(); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); Customer customer = gBBInput.getCustomer(); - String response = sdncSIResources.assignServiceInstance(serviceInstance, customer, requestContext); - execution.setVariable("SDNCResponse", response); + GenericResourceApiServiceOperationInformation req = sdncSIResources.assignServiceInstance(serviceInstance, customer, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.SERVICE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -107,9 +113,11 @@ public class SDNCAssignTasks { } Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - - String response = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("SDNCAssignResponse_"+ vfModule.getVfModuleId(), response); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VFMODULE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -123,15 +131,16 @@ public class SDNCAssignTasks { public void assignNetwork(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - Customer customer = gBBInput.getCustomer(); RequestContext requestContext = gBBInput.getRequestContext(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - - sdncNetworkResources.assignNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion); + GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.assignNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.NETWORK); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java index cae4dc26de..592b831d62 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java @@ -20,6 +20,10 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -36,6 +40,8 @@ import org.onap.so.client.orchestration.SDNCNetworkResources; import org.onap.so.client.orchestration.SDNCServiceInstanceResources; import org.onap.so.client.orchestration.SDNCVfModuleResources; import org.onap.so.client.orchestration.SDNCVnfResources; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -58,9 +64,11 @@ public class SDNCChangeAssignTasks { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - - String response = sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext()); - execution.setVariable("SDNCChangeAssignTasks.changeModelServiceInstance.response", response); + GenericResourceApiServiceOperationInformation req = sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext()); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.SERVICE); + execution.setVariable("SDNCRequest", sdncRequest); } catch(Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -71,9 +79,11 @@ public class SDNCChangeAssignTasks { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - - String response = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext()); - execution.setVariable("SDNCChangeModelVnfResponse", response); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext()); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VNF); + execution.setVariable("SDNCRequest", sdncRequest); } catch(Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -84,9 +94,11 @@ public class SDNCChangeAssignTasks { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - - String sdncResponse = sdncNetworkResources.changeAssignNetwork(network, serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext(), gBBInput.getCloudRegion()); - execution.setVariable("SDNCChangeAssignNetworkResponse", sdncResponse); + GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.changeAssignNetwork(network, serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext(), gBBInput.getCloudRegion()); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.NETWORK); + execution.setVariable("SDNCRequest", sdncRequest); } catch(Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -101,8 +113,11 @@ public class SDNCChangeAssignTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); Customer customer = gBBInput.getCustomer(); - String response = sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("SDNCChangeAssignVfModuleResponse", response); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VFMODULE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java index 1f6ec72f34..eb078e04b4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java @@ -20,6 +20,10 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -36,6 +40,8 @@ import org.onap.so.client.orchestration.SDNCNetworkResources; import org.onap.so.client.orchestration.SDNCServiceInstanceResources; import org.onap.so.client.orchestration.SDNCVfModuleResources; import org.onap.so.client.orchestration.SDNCVnfResources; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -61,23 +67,17 @@ public class SDNCDeactivateTasks { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); RequestContext requestContext = gBBInput.getRequestContext(); - - ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, - execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, - execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); - VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, - execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); - + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - execution.setVariable("sdncDeactivateVfModuleRollback", false); - - String response = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("SDNCDeactivateVfModuleResponse", response); - execution.setVariable("sdncDeactivateVfModuleRollback", true); - } catch (Exception ex) { + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VFMODULE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -93,15 +93,15 @@ public class SDNCDeactivateTasks { RequestContext requestContext = gBBInput.getRequestContext(); ServiceInstance serviceInstance = null; GenericVnf vnf = null; - - serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, - execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, - execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); Customer customer = gBBInput.getCustomer(); - String response = sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("SDNCDeactivateVnfResponse", response); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VNF); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -119,10 +119,11 @@ public class SDNCDeactivateTasks { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); Customer customer = gBBInput.getCustomer(); - execution.setVariable("sdncServiceInstanceRollback", false); - String response = sdncSIResources.deactivateServiceInstance(serviceInstance, customer, requestContext); - execution.setVariable("deactivateServiceInstanceSDNCResponse", response); - execution.setVariable("sdncServiceInstanceRollback", true); + GenericResourceApiServiceOperationInformation req = sdncSIResources.deactivateServiceInstance(serviceInstance, customer, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.SERVICE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -134,7 +135,6 @@ public class SDNCDeactivateTasks { * @param execution */ public void deactivateNetwork(BuildingBlockExecution execution) { - execution.setVariable("SDNCDeactivateTasks.deactivateNetwork.rollback", false); try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); @@ -142,11 +142,12 @@ public class SDNCDeactivateTasks { Customer customer = gBBInput.getCustomer(); RequestContext requestContext = gBBInput.getRequestContext(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - - String response = sdncNetworkResources.deactivateNetwork(l3Network, serviceInstance, customer, + GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.deactivateNetwork(l3Network, serviceInstance, customer, requestContext, cloudRegion); - execution.setVariable("SDNCDeactivateTasks.deactivateNetwork.response", response); - execution.setVariable("SDNCDeactivateTasks.deactivateNetwork.rollback", true); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.NETWORK); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java index ab4a7f8a2c..960fb9988a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java @@ -20,6 +20,10 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -36,6 +40,8 @@ import org.onap.so.client.orchestration.SDNCNetworkResources; import org.onap.so.client.orchestration.SDNCServiceInstanceResources; import org.onap.so.client.orchestration.SDNCVfModuleResources; import org.onap.so.client.orchestration.SDNCVnfResources; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -59,11 +65,14 @@ public class SDNCUnassignTasks { public void unassignServiceInstance(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); RequestContext requestContext = gBBInput.getRequestContext(); Customer customer = gBBInput.getCustomer(); - String sdncUnassignResponse = sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext); - execution.setVariable("sdncUnassignResponse", sdncUnassignResponse); + GenericResourceApiServiceOperationInformation req = sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.SERVICE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -74,11 +83,11 @@ public class SDNCUnassignTasks { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); - execution.setVariable("sdncVfModuleRollback", false); - String response = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance); - execution.setVariable("SDNCResponse", response); - execution.setVariable("sdncVfModuleRollback", true); - } catch (Exception ex) { + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VFMODULE); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -91,28 +100,31 @@ public class SDNCUnassignTasks { RequestContext requestContext = gBBInput.getRequestContext(); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - execution.setVariable("sdncVnfRollback", false); - String response = sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); - execution.setVariable("sdncUnassignVnfResponse", response); - execution.setVariable("sdncVnfRollback", true); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.VNF); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } public void unassignNetwork(BuildingBlockExecution execution) throws Exception { - GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - Customer customer = gBBInput.getCustomer(); - RequestContext requestContext = gBBInput.getRequestContext(); - CloudRegion cloudRegion = gBBInput.getCloudRegion(); - String cloudRegionSdnc = execution.getVariable("cloudRegionSdnc"); - cloudRegion.setLcpCloudRegionId(cloudRegionSdnc); try { - String response = sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - execution.setVariable("SDNCUnAssignNetworkResponse", response); - execution.setVariable("isRollbackNeeded", true); + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + Customer customer = gBBInput.getCustomer(); + RequestContext requestContext = gBBInput.getRequestContext(); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + String cloudRegionSdnc = execution.getVariable("cloudRegionSdnc"); + cloudRegion.setLcpCloudRegionId(cloudRegionSdnc); + GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); + SDNCRequest sdncRequest = new SDNCRequest(); + sdncRequest.setSDNCPayload(req); + sdncRequest.setTopology(SDNCTopology.NETWORK); + execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java index d3589db101..8b53c28547 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java @@ -20,92 +20,81 @@ package org.onap.so.client.orchestration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; - @Component public class SDNCNetworkResources { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCNetworkResources.class); - + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, + SDNCNetworkResources.class); + @Autowired private NetworkTopologyOperationRequestMapper sdncRM; - - @Autowired - private SDNCClient sdncClient; - public String assignNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext, CloudRegion cloudRegion) - throws MapperException, BadResponseException { - - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, - SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); + public GenericResourceApiNetworkOperationInformation assignNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - - public String rollbackAssignNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext, CloudRegion cloudRegion) - throws MapperException, BadResponseException { - - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, - SDNCSvcAction.UNASSIGN, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); + + public GenericResourceApiNetworkOperationInformation rollbackAssignNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - public String activateNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext, CloudRegion cloudRegion) - throws MapperException, BadResponseException { - - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, - SDNCSvcAction.ACTIVATE, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); + public GenericResourceApiNetworkOperationInformation activateNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - - public String deactivateNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, CloudRegion cloudRegion) throws MapperException, BadResponseException { - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, - SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); + + public GenericResourceApiNetworkOperationInformation deactivateNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - public String deleteNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext, CloudRegion cloudRegion) - throws MapperException, BadResponseException { - - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, - SDNCSvcAction.DELETE, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); + public GenericResourceApiNetworkOperationInformation deleteNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - - public String changeAssignNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext, CloudRegion cloudRegion) - throws MapperException, BadResponseException { - - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); + + public GenericResourceApiNetworkOperationInformation changeAssignNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - public String unassignNetwork(L3Network network, ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext, CloudRegion cloudRegion) - throws MapperException, BadResponseException { - - GenericResourceApiNetworkOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, - SDNCSvcAction.UNASSIGN, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - return sdncClient.post(sdncReq, SDNCTopology.NETWORK); - } - + public GenericResourceApiNetworkOperationInformation unassignNetwork(L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java index ad9e201862..a4c9b8fe05 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java @@ -20,37 +20,28 @@ package org.onap.so.client.orchestration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; -import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; - @Component public class SDNCServiceInstanceResources { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, - SDNCServiceInstanceResources.class); - @Autowired private ServiceTopologyOperationMapper sdncRM; - - @Autowired - private SDNCClient sdncClient; - + /** - * SDNC call to perform Service Topology Assign for ServiceInsatnce + * SDNC call to perform Service Topology Assign for ServiceInsatnce + * * @param serviceInstance * @param customer * @param requestContext @@ -58,16 +49,16 @@ public class SDNCServiceInstanceResources { * @throws BadResponseException * @return the response as a String */ - public String assignServiceInstance(ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext) throws MapperException, BadResponseException { - GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper( - SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, + public GenericResourceApiServiceOperationInformation assignServiceInstance(ServiceInstance serviceInstance, + Customer customer, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, requestContext); - return sdncClient.post(sdncReq, SDNCTopology.SERVICE); } /** - * SDNC call to perform Service Topology Delete for ServiceInsatnce + * SDNC call to perform Service Topology Delete for ServiceInsatnce + * * @param serviceInstance * @param customer * @param requestContext @@ -75,24 +66,23 @@ public class SDNCServiceInstanceResources { * @throws BadResponseException * @return the response as a String */ - public String deleteServiceInstance(ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext) throws MapperException, BadResponseException { - GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper( - SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer, + public GenericResourceApiServiceOperationInformation deleteServiceInstance(ServiceInstance serviceInstance, + Customer customer, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, + GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer, requestContext); - return sdncClient.post(sdncReq, SDNCTopology.SERVICE); } - - public String unassignServiceInstance(ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext) throws MapperException, BadResponseException { - GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper( - SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer, + + public GenericResourceApiServiceOperationInformation unassignServiceInstance(ServiceInstance serviceInstance, + Customer customer, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, + GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer, requestContext); - return sdncClient.post(sdncReq, SDNCTopology.SERVICE); } - + /** * SDNC call to perform Service Topology Deactivate for ServiceInstance + * * @param serviceInstance * @param customer * @param requestContext @@ -100,16 +90,17 @@ public class SDNCServiceInstanceResources { * @throws BadResponseException * @return the response as a String */ - public String deactivateServiceInstance(ServiceInstance serviceInstance, Customer customer, - RequestContext requestContext) throws MapperException, BadResponseException { - GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper( - SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer, + public GenericResourceApiServiceOperationInformation deactivateServiceInstance(ServiceInstance serviceInstance, + Customer customer, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, + GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer, requestContext); - return sdncClient.post(sdncReq, SDNCTopology.SERVICE); } - + /** - * SDNC call to perform Service Topology Change Assign for the ServiceInstance + * SDNC call to perform Service Topology Change Assign for the + * ServiceInstance + * * @param serviceInstance * @param customer * @param requestContext @@ -117,8 +108,10 @@ public class SDNCServiceInstanceResources { * @throws BadResponseException * @return the response as a String */ - public String changeModelServiceInstance(ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) throws MapperException, BadResponseException { - GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, requestContext); - return sdncClient.post(sdncReq, SDNCTopology.SERVICE); + public GenericResourceApiServiceOperationInformation changeModelServiceInstance(ServiceInstance serviceInstance, + Customer customer, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, + requestContext); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java index 3c192e1b1c..e7f0a40d2a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java @@ -33,7 +33,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; @@ -41,59 +40,51 @@ import org.springframework.stereotype.Component; @Component public class SDNCVfModuleResources { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCVfModuleResources.class); - + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, + SDNCVfModuleResources.class); + @Autowired private VfModuleTopologyOperationRequestMapper sdncRM; - + @Autowired private SDNCClient sdncClient; - - public String assignVfModule(VfModule vfModule, VolumeGroup volumeGroup,GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - - GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, - SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); - return sdncClient.post(sdncReq, SDNCTopology.VFMODULE); - } - public String unassignVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance) - throws MapperException, BadResponseException { - - GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, - SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null); - return sdncClient.post(sdncReq, SDNCTopology.VFMODULE); + public GenericResourceApiVfModuleOperationInformation assignVfModule(VfModule vfModule, VolumeGroup volumeGroup, + GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, + RequestContext requestContext) throws MapperException { + return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, + volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); } - public String deactivateVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { + public GenericResourceApiVfModuleOperationInformation unassignVfModule(VfModule vfModule, GenericVnf vnf, + ServiceInstance serviceInstance) throws MapperException { + return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, + vnf, serviceInstance, null, null, null, null); + } - GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper( - SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, - customer, cloudRegion, requestContext, null); - return sdncClient.post(sdncReq, SDNCTopology.VFMODULE); + public GenericResourceApiVfModuleOperationInformation deactivateVfModule(VfModule vfModule, GenericVnf vnf, + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) + throws MapperException { + return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, + vnf, serviceInstance, customer, cloudRegion, requestContext, null); } - - public String queryVfModule(VfModule vfModule) - throws MapperException, BadResponseException { - - String objectPath = vfModule.getSelflink(); + + public String queryVfModule(VfModule vfModule) throws MapperException, BadResponseException { + String objectPath = vfModule.getSelflink(); return sdncClient.get(objectPath); } - - public String activateVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - - GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, - SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); - return sdncClient.post(sdncReq, SDNCTopology.VFMODULE); + + public GenericResourceApiVfModuleOperationInformation activateVfModule(VfModule vfModule, GenericVnf vnf, + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) + throws MapperException { + return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null, + vnf, serviceInstance, customer, cloudRegion, requestContext, null); } - - public String changeAssignVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) throws MapperException, BadResponseException { - GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); - return sdncClient.post(sdncReq, SDNCTopology.VFMODULE); + + public GenericResourceApiVfModuleOperationInformation changeAssignVfModule(VfModule vfModule, GenericVnf vnf, + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) + throws MapperException { + return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, + null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index b30fc932c0..e5194e3e37 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -32,7 +32,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; @@ -49,52 +48,41 @@ public class SDNCVnfResources { private SDNCClient sdncClient; public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext, boolean homing) - throws MapperException, BadResponseException { + CloudRegion cloudRegion, RequestContext requestContext, boolean homing) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, homing); } - public String activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, + public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, + CloudRegion cloudRegion, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false); - return sdncClient.post(sdncReq, SDNCTopology.VNF); } - public String deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, + public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, + CloudRegion cloudRegion, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false); - return sdncClient.post(sdncReq, SDNCTopology.VNF); } - public String unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, + public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, + CloudRegion cloudRegion, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false); - return sdncClient.post(sdncReq, SDNCTopology.VNF); } - public String deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, + public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, + CloudRegion cloudRegion, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE,vnf, serviceInstance, customer, cloudRegion, requestContext, false); - return sdncClient.post(sdncReq, SDNCTopology.VNF); } - public String changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, - CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException, BadResponseException { - GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, + public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, + CloudRegion cloudRegion, RequestContext requestContext) { + return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false); - return sdncClient.post(sdncReq, SDNCTopology.VNF); } public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java index a556346252..65e7d249c5 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; @@ -34,6 +35,9 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -45,8 +49,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BBObjectNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; - +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; public class SDNCActivateTaskTest extends BaseTaskTest{ @@ -83,47 +87,48 @@ public class SDNCActivateTaskTest extends BaseTaskTest{ @Test public void activateVnfTest() throws Exception { - doReturn("success").when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer, cloudRegion,requestContext); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer, cloudRegion,requestContext); sdncActivateTasks.activateVnf(execution); verify(sdncVnfResources, times(1)).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VNF,sdncRequest.getTopology()); } @Test public void activateVnfTestException() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext); sdncActivateTasks.activateVnf(execution); } @Test public void activateNetworkTest() throws Exception { - doReturn("response").when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class)); + doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class)); sdncActivateTasks.activateNetwork(execution); verify(sdncNetworkResources, times(1)).activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology()); } @Test public void activateNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class)); sdncActivateTasks.activateNetwork(execution); } @Test public void activateVfModuleTest() throws Exception { - doReturn("success").when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncActivateTasks.activateVfModule(execution); - verify(sdncVfModuleResources, times(1)).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology()); } @Test public void activateVfModuleTestException() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncActivateTasks.activateVfModule(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java index 24ae88b98c..d021df56e0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -35,6 +34,9 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -87,30 +89,25 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ @Test public void assignServiceInstanceTest() throws Exception { - doReturn("response").when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext); - + doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext); sdncAssignTasks.assignServiceInstance(execution); - verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext); - assertTrue(execution.getVariable("SDNCResponse").equals("response")); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology()); } @Test public void assignServiceInstanceExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext); - sdncAssignTasks.assignServiceInstance(execution); } @Test public void assignVnfTest() throws Exception { doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); - execution.setVariable("generalBuildingBlock", gBBInput); sdncAssignTasks.assignVnf(execution); - verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance,customer, cloudRegion, requestContext, false); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VNF,sdncRequest.getTopology()); @@ -119,46 +116,39 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ @Test public void assignVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); - sdncAssignTasks.assignVnf(execution); } @Test public void assignVfModuleTest() throws Exception { - doReturn("response").when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncAssignTasks.assignVfModule(execution); - verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - assertTrue(execution.getVariable("SDNCAssignResponse_" + vfModule.getVfModuleId()).equals("response")); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology()); } @Test public void assignVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - sdncAssignTasks.assignVfModule(execution); } @Test public void assignNetworkTest() throws Exception { - doReturn("response").when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); sdncAssignTasks.assignNetwork(execution); - verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology()); } @Test public void assignNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - sdncAssignTasks.assignNetwork(execution); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java index 99c680d8bb..f01596c86f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java @@ -20,7 +20,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -34,6 +33,8 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -44,7 +45,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BBObjectNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; public class SDNCChangeAssignTasksTest extends BaseTaskTest{ @InjectMocks @@ -74,15 +76,11 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest{ @Test public void changeModelVnfTest() throws Exception { - String response = "sdncChangeModelServiceInstance"; - - doReturn(response).when(sdncServiceInstanceResources).changeModelServiceInstance(serviceInstance, customer, requestContext); - - sdncChangeAssignTasks.changeModelServiceInstance(execution); - - verify(sdncServiceInstanceResources, times(1)).changeModelServiceInstance(serviceInstance, customer, requestContext); - - assertEquals(response, execution.getVariable("SDNCChangeAssignTasks.changeModelServiceInstance.response")); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + sdncChangeAssignTasks.changeModelVnf(execution); + verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VNF,sdncRequest.getTopology()); } @Test @@ -94,13 +92,11 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest{ @Test public void changeAssignModelVfModuleTest() throws Exception { - String response = "response"; - doReturn(response).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncChangeAssignTasks.changeAssignModelVfModule(execution); - verify(sdncVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - assertTrue(execution.getVariable("SDNCChangeAssignVfModuleResponse").equals(response)); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology()); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java index 66b8ecfb20..3d25addb9c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java @@ -21,9 +21,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -37,6 +34,10 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -48,7 +49,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BBObjectNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; public class SDNCDeactivateTaskTest extends BaseTaskTest { @InjectMocks @@ -82,29 +84,27 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest { @Test public void deactivateVfModuleTest() throws Exception { - doReturn("success").when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncDeactivateTasks.deactivateVfModule(execution); - verify(sdncVfModuleResources, times(1)).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology()); } @Test public void deactivateVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); - sdncDeactivateTasks.deactivateVfModule(execution); } @Test public void deactivateVnfTest() throws Exception { - doReturn("success").when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncDeactivateTasks.deactivateVnf(execution); - verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VNF,sdncRequest.getTopology()); } @Test @@ -116,13 +116,11 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest { @Test public void deactivateServiceInstanceTest() throws Exception { - doReturn("response").when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext); - + doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext); sdncDeactivateTasks.deactivateServiceInstance(execution); - verify(sdncServiceInstanceResources, times(1)).deactivateServiceInstance(serviceInstance, customer, requestContext); - assertEquals("response", execution.getVariable("deactivateServiceInstanceSDNCResponse")); - assertTrue(execution.getVariable("sdncServiceInstanceRollback")); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology()); } @Test @@ -134,34 +132,18 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest { @Test public void test_deactivateNetwork() throws Exception { - String expectedResponse = "return"; - - doReturn(expectedResponse).when(sdncNetworkResources).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); sdncDeactivateTasks.deactivateNetwork(execution); - verify(sdncNetworkResources, times(1)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - assertEquals(expectedResponse, execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.response")); - - assertTrue(execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.rollback")); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology()); } @Test public void test_deactivateNetwork_exception() throws Exception { expectedException.expect(BpmnError.class); - - try { - doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any()); - - sdncDeactivateTasks.deactivateNetwork(execution); - } finally { - verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - assertNull(execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.response")); - - assertFalse(execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.rollback")); - } + doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any()); + sdncDeactivateTasks.deactivateNetwork(execution); + verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); } - } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java index 07f03b592b..1301787dff 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -37,6 +36,10 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -48,8 +51,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BBObjectNotFoundException; -import org.onap.so.db.catalog.beans.OrchestrationStatus; -import org.springframework.beans.factory.annotation.Autowired; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; public class SDNCUnassignTasksTest extends BaseTaskTest{ @InjectMocks @@ -81,11 +84,11 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{ @Test public void unassignServiceInstanceTest() throws Exception { - doReturn("test").when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext); - + doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext); sdncUnassignTasks.unassignServiceInstance(execution); - verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer, requestContext); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology()); } @@ -93,20 +96,17 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{ @Test public void unassignServiceInstanceExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext); - sdncUnassignTasks.unassignServiceInstance(execution); } @Test public void unassignVfModuleTest() throws Exception { - doReturn("response").when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance); - + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance); sdncUnassignTasks.unassignVfModule(execution); - verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance); - assertEquals("response", execution.getVariable("SDNCResponse")); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology()); } @@ -115,20 +115,17 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{ @Test public void unassignVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance); - sdncUnassignTasks.unassignVfModule(execution); } @Test public void unassignVnfTest() throws Exception { - doReturn("response").when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncUnassignTasks.unassignVnf(execution); - verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - assertTrue(execution.getVariable("sdncUnassignVnfResponse").equals("response")); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.VNF,sdncRequest.getTopology()); } @@ -142,18 +139,14 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{ @Test public void unassignNetworkTest() throws Exception { String cloudRegionSdnc = "AAIAIC25"; - cloudRegion.setCloudRegionVersion("2.5"); - execution.setVariable("cloudRegionSdnc", cloudRegionSdnc); - - doReturn("response").when(sdncNetworkResources).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); assertNotEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId()); sdncUnassignTasks.unassignNetwork(execution); - verify(sdncNetworkResources, times(1)).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - assertEquals("response", execution.getVariable("SDNCUnAssignNetworkResponse")); assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId()); + SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); + assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology()); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java index b93328ffe8..f275f3c484 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java @@ -20,10 +20,6 @@ package org.onap.so.client.orchestration; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -31,47 +27,42 @@ import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; -import org.onap.so.db.catalog.beans.OrchestrationStatus; - -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; @RunWith(MockitoJUnitRunner.Silent.class) -public class SDNCNetworkResourcesTest extends TestDataSetup{ - +public class SDNCNetworkResourcesTest extends TestDataSetup { + @InjectMocks private SDNCNetworkResources sdncNetworkResources; - + @Mock protected SDNCClient MOCK_sdncClient; - + @Mock - protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper; - + protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper; + private L3Network network; private ServiceInstance serviceInstance; private Customer customer; private RequestContext requestContext; private CloudRegion cloudRegion; - + @Before public void before() { network = buildL3Network(); @@ -81,125 +72,98 @@ public class SDNCNetworkResourcesTest extends TestDataSetup{ serviceInstance = buildServiceInstance(); requestContext = buildRequestContext(); - + cloudRegion = new CloudRegion(); } @Test public void assignNetworkTest() throws Exception { - network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK)); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); sdncNetworkResources.assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_sdncClient, times(1)).post(ArgumentMatchers.isNull(), eq(SDNCTopology.NETWORK)); - - assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus()); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - + @Test public void rollbackAssignNetworkTest() throws Exception { - network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK)); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); sdncNetworkResources.rollbackAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_sdncClient, times(1)).post(ArgumentMatchers.isNull(), eq(SDNCTopology.NETWORK)); - - assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus()); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - + @Test public void activateNetworkTest() throws Exception { - network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK)); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); sdncNetworkResources.activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_sdncClient, times(1)).post(ArgumentMatchers.isNull(), eq(SDNCTopology.NETWORK)); - - assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus()); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - + @Test public void deleteNetworkTest() throws Exception { - network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK)); - + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); sdncNetworkResources.deleteNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_sdncClient, times(1)).post(ArgumentMatchers.isNull(), eq(SDNCTopology.NETWORK)); - - assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus()); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - + @Test public void test_deactivateNetwork() throws MapperException, BadResponseException { - serviceInstance.getNetworks().add(network); - - Customer customer = new Customer(); - customer.setGlobalCustomerId("gcustId"); - customer.setServiceSubscription(new ServiceSubscription()); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - - GenericResourceApiNetworkOperationInformation expectedGenericResourceApiNetworkOperationInformation = new GenericResourceApiNetworkOperationInformation(); - - String expectedResponse = "response"; - - doReturn(expectedResponse).when(MOCK_sdncClient).post(expectedGenericResourceApiNetworkOperationInformation, SDNCTopology.NETWORK); - - doReturn(expectedGenericResourceApiNetworkOperationInformation).when(MOCK_networkTopologyOperationRequestMapper).reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - - String actualResponse = sdncNetworkResources.deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_sdncClient).post(expectedGenericResourceApiNetworkOperationInformation, SDNCTopology.NETWORK); - - assertEquals(expectedResponse, actualResponse); + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + sdncNetworkResources.deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - + @Test public void changeAssignNetworkTest() throws MapperException, BadResponseException { - String expectedSdncResponse = "SDNCChangeAssignNetworkResponse"; - - serviceInstance.getNetworks().add(network); - - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - customer.setServiceSubscription(new ServiceSubscription()); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - - GenericResourceApiNetworkOperationInformation sdncReq = new GenericResourceApiNetworkOperationInformation(); - - doReturn(sdncReq).when(MOCK_networkTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class)); - - doReturn(expectedSdncResponse).when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), isA(SDNCTopology.class)); - - String actualSdncResponse = sdncNetworkResources.changeAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); - - verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); - verify(MOCK_sdncClient, times(1)).post(sdncReq, SDNCTopology.NETWORK); - assertEquals(actualSdncResponse, expectedSdncResponse); + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + sdncNetworkResources.changeAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); } - + @Test public void unassignNetwork_Test() throws Exception { - network.setOrchestrationStatus(OrchestrationStatus.CREATED); - - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK)); - - sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, - requestContext, cloudRegion); - - verify(MOCK_sdncClient, times(1)).post(ArgumentMatchers.isNull(), eq(SDNCTopology.NETWORK)); - - assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus()); - } + doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper) + .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); + verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper( + SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, + requestContext, cloudRegion); + } } \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java index 42672e1180..509dc1de0d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.orchestration; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -30,121 +30,100 @@ import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; - @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCServiceInstanceResourcesTest extends TestDataSetup{ + @InjectMocks private SDNCServiceInstanceResources sdncServiceInstanceResources; - - @Mock protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper; - private RequestContext requestContext; private ServiceInstance serviceInstance; private Customer customer; - @Mock - protected SDNCClient MOCK_sdncClient; - @Before public void before() { requestContext = buildRequestContext(); - serviceInstance = buildServiceInstance(); - customer = buildCustomer(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); } @Test public void assignServiceInstanceSuccessTest() throws Exception { doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); } @Test public void assignServiceInstanceExceptionTest() throws Exception { expectedException.expect(Exception.class); - doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext); } @Test public void deleteServiceInstanceSuccessTest() throws Exception { doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); } @Test public void deleteServiceInstanceExceptionTest() throws Exception { expectedException.expect(Exception.class); - doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext); } @Test public void unassignServiceInstanceSuccessTest() throws Exception { doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); } @Test public void unassignServiceInstanceExceptionTest() throws Exception { expectedException.expect(Exception.class); - doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); sdncServiceInstanceResources.unassignServiceInstance(serviceInstance,customer, requestContext); } @Test public void deactivateServiceInstanceSuccessTest() throws Exception { - doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext); - verify(MOCK_sdncClient, times(1)).post(ArgumentMatchers.isNull(), eq(SDNCTopology.SERVICE)); + verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); } @Test public void deactivateServiceInstanceExceptionTest() throws Exception { expectedException.expect(Exception.class); - doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext); } @Test public void test_changeModelServiceInstance() throws MapperException, BadResponseException { doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE)); + verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class)); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java index e27f0fcfa1..7d05758129 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java @@ -20,8 +20,6 @@ package org.onap.so.client.orchestration; -import static org.mockito.Matchers.eq; -import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -31,8 +29,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -43,16 +41,18 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SDNCClient; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper; - -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVfModuleResourcesTest extends TestDataSetup{ + @InjectMocks - private SDNCVfModuleResources sdncVfModuleResources = new SDNCVfModuleResources(); + private SDNCVfModuleResources sdncVfModuleResources; + + @Mock + protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper; private VfModule vfModule; private GenericVnf vnf; @@ -61,12 +61,7 @@ public class SDNCVfModuleResourcesTest extends TestDataSetup{ private Customer customer; private CloudRegion cloudRegion; private RequestContext requestContext; - - @Mock - protected SDNCClient MOCK_sdncClient; - - @Spy - protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper; + private GenericResourceApiVfModuleOperationInformation sdncReq; @Before public void before() { @@ -77,50 +72,51 @@ public class SDNCVfModuleResourcesTest extends TestDataSetup{ customer = buildCustomer(); cloudRegion = buildCloudRegion(); requestContext = buildRequestContext(); + sdncReq = new GenericResourceApiVfModuleOperationInformation(); } @Test - public void assignVfModuleTest() throws MapperException, BadResponseException { - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class)); - + public void assignVfModuleTest() throws MapperException { + doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, + volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE)); + verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, + volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); } @Test - public void unassignVfModuleTest() throws MapperException, BadResponseException { - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE)); - + public void unassignVfModuleTest() throws MapperException { + doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, + vnf, serviceInstance, null, null, null, null); sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE)); + verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, + vnf, serviceInstance, null, null, null, null); } @Test - public void activateVfModuleTest() throws MapperException, BadResponseException { - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class)); - + public void activateVfModuleTest() throws MapperException { + doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null, + vnf, serviceInstance, customer, cloudRegion, requestContext, null); sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE)); + verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null, + vnf, serviceInstance, customer, cloudRegion, requestContext, null); } @Test - public void deactivateVfModuleTest() throws MapperException, BadResponseException { - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class)); - + public void deactivateVfModuleTest() throws MapperException { + doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, + vnf, serviceInstance, customer, cloudRegion, requestContext, null); sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE)); + verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, + vnf, serviceInstance, customer, cloudRegion, requestContext, null); } @Test public void changeAssignVfModuleTest() throws MapperException, BadResponseException { - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class)); - + doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, + null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE)); + verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, + null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java index 3329842924..9bbf790ecb 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java @@ -20,10 +20,9 @@ package org.onap.so.client.orchestration; -import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; @@ -49,7 +48,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) @@ -73,112 +71,83 @@ public class SDNCVnfResourcesTest extends TestDataSetup{ @Before public void before() { serviceInstance = buildServiceInstance(); - genericVnf = buildGenericVnf(); - customer = buildCustomer(); - cloudRegion = buildCloudRegion(); - requestContext = buildRequestContext(); - sdncReq = new GenericResourceApiVnfOperationInformation(); } @Test - public void assignVnfTest() throws MapperException, BadResponseException { + public void assignVnfTest() { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); - sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); - verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); } @Test - public void activateVnfTest() throws MapperException, BadResponseException { + public void activateVnfTest() { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); - sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); + verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); } @Test - public void deleteVnfTest() throws MapperException, BadResponseException { - doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); - doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); - + public void deleteVnfTest() { + doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - - verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); + verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); } @Test public void queryVnfTest() throws MapperException, BadResponseException { doReturn("test").when(MOCK_sdncClient).get(isA(String.class)); - genericVnf.setSelflink("testSelflink"); - sdncVnfResources.queryVnf(genericVnf); - verify(MOCK_sdncClient, times(1)).get(isA(String.class)); } @Test public void queryVnfWithResourcePrefixTest() throws MapperException, BadResponseException { doReturn("test").when(MOCK_sdncClient).get(isA(String.class)); - genericVnf.setSelflink("restconf/test:testSelflink"); - sdncVnfResources.queryVnf(genericVnf); - verify(MOCK_sdncClient, times(1)).get(isA(String.class)); } @Test - public void changeModelVnfTest() throws MapperException, BadResponseException { + public void changeModelVnfTest() { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean()); - doReturn("SDNCChangeModelVnfResponse").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), isA(SDNCTopology.class)); - - String actualResponse = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - + sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); - verify(MOCK_sdncClient, times(1)).post(sdncReq, SDNCTopology.VNF); - assertEquals("SDNCChangeModelVnfResponse", actualResponse); } @Test - public void deactivateVnfSuccessTest() throws Exception { + public void deactivateVnfSuccessTest() { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); + verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); } - @Test(expected = Exception.class) - public void deactivateVnfExceptionTest() throws Exception { - doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); - doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); + @Test + public void deactivateVnfExceptionTest() { + expectedException.expect(Exception.class); + doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); } @Test public void unassignVnfSuccessTest() throws Exception { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); - doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); + verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); } - @Test(expected = Exception.class) + @Test public void unassignVnfExceptionTest() throws Exception { - doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); - doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF)); + expectedException.expect(Exception.class); + doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean()); sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - //verify(client, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.VNF)); } - } -- cgit 1.2.3-korg