diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
37 files changed, 690 insertions, 1763 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index a7dfe7f7a4..28d2abc792 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -161,6 +161,26 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test + public void updateOrchestrationStatusInventoriedPnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.INVENTORIED); + + aaiUpdateTasks.updateOrchestrationStatusInventoriedPnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.INVENTORIED); + } + + @Test + public void updateOrchestrationStatusInventoriedPnfExceptionTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, + OrchestrationStatus.INVENTORIED); + + expectedException.expect(BpmnError.class); + aaiUpdateTasks.updateOrchestrationStatusInventoriedPnf(execution); + } + + @Test public void updateOrchestrationStatusActivePnfTest() throws Exception { Pnf pnf = preparePnfAndExtractForPnf(); doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java index 38c74eecc7..d7d6da209e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -149,6 +149,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { private void fillRequiredAppcExecutionFields() { RequestContext context = new RequestContext(); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); @@ -192,6 +193,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { "{\"request_parameters\":{\"host_ip_address\":\"10.10.10.10\"},\"configuration_parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}"); context.setRequestParameters(requestParameters); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java index 0eb0304cdf..d4f1660986 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.net.URISyntaxException; @@ -33,6 +33,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -78,81 +80,4 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup { Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId()); } - - - private VpnBondingLink getVpnBondingLink() { - VpnBondingLink vpnBondingLink = new VpnBondingLink(); - Configuration vrfConfiguration = getVRFConfiguration(); - vpnBondingLink.setVrfConfiguration(vrfConfiguration); - Configuration vnrConfiguration = getVNRConfiguration(); - vpnBondingLink.setVnrConfiguration(vnrConfiguration); - vpnBondingLink.setTransportServiceProxy(buildServiceProxy(buildServiceInstance(buildGenericVnf()))); - return vpnBondingLink; - } - - private RequestContext getRequestContext() { - RequestContext requestContext = new RequestContext(); - requestContext.setMsoRequestId("MsoRequestId"); - Map<String, Object> userParams = getUserParams(); - requestContext.setUserParams(userParams); - return requestContext; - } - - private Map<String, Object> getUserParams() { - Map<String, Object> userParams = new HashMap<>(); - userParams.put("lppCustomerId", "lppCustomerId"); - return userParams; - } - - private ServiceProxy buildServiceProxy(ServiceInstance serviceInstance) { - ServiceProxy serviceProxy = new ServiceProxy(); - serviceProxy.setServiceInstance(serviceInstance); - return serviceProxy; - } - - private Configuration getVRFConfiguration() { - Configuration vrfConfiguration = new Configuration(); - vrfConfiguration.setConfigurationId("ConfigurationId"); - vrfConfiguration.setConfigurationName("ConfigurationName"); - vrfConfiguration.setConfigurationSubType("ConfigurationSubType"); - vrfConfiguration.setConfigurationType("VRF-ENTRY"); - return vrfConfiguration; - } - - public Configuration getVNRConfiguration() { - Configuration vnrConfiguration = new Configuration(); - vnrConfiguration.setConfigurationId("ConfigurationId"); - vnrConfiguration.setConfigurationName("ConfigurationName"); - vnrConfiguration.setConfigurationSubType("ConfigurationSubType"); - vnrConfiguration.setConfigurationType("VNRConfiguration"); - L3Network l3Network = getL3Network(); - vnrConfiguration.setNetwork(l3Network); - return vnrConfiguration; - } - - public L3Network getL3Network() { - L3Network l3Network = new L3Network(); - l3Network.setNetworkId("l3NetworkId"); - Subnet ipv4subnet = getSubnet("ipv4CidrMask", "ipv4NetworkStartAddress", "IPV4"); - Subnet ipv6subnet = getSubnet("ipv6CidrMask", "ipv6NetworkStartAddress", "IPV6"); - l3Network.getSubnets().add(ipv4subnet); - l3Network.getSubnets().add(ipv6subnet); - return l3Network; - } - - private Subnet getSubnet(String ipv4CidrMask, String ipv4NetworkStartAddress, String ipv4) { - Subnet ipv4subnet = new Subnet(); - ipv4subnet.setCidrMask(ipv4CidrMask); - ipv4subnet.setNetworkStartAddress(ipv4NetworkStartAddress); - ipv4subnet.setIpVersion(ipv4); - return ipv4subnet; - } - - private ServiceInstance buildServiceInstance(GenericVnf vnf) { - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("ServiceInstanceId"); - List<GenericVnf> vnfs = serviceInstance.getVnfs(); - vnfs.add(vnf); - return serviceInstance; - } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java index 88a291e68b..92fc13b633 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; @@ -47,6 +47,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumerat import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java index 76e915781f..0952a35ab0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -38,6 +38,8 @@ import org.mockito.Spy; 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.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java index f4006ab5d5..bd5c234e50 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -33,6 +33,8 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 2fd684e0f0..e064300ab7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -40,6 +40,8 @@ import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java index 00836176f0..a042289281 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -35,6 +35,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index b9feeedc14..98f84414db 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,31 +22,20 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; import org.onap.so.bpmn.BaseTaskTest; -import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.exception.OrchestrationStatusValidationException; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -52,7 +43,16 @@ import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; import org.onap.so.db.catalog.beans.ResourceType; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class OrchestrationStatusValidatorTest extends BaseTaskTest { @@ -62,6 +62,9 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { private static final String vfModuleNotExistExpectedMessage = "The VfModule was not found, thus no VfModule was deleted in the cloud via this request"; + @Mock + private ExceptionBuilder exceptionBuilder; + @InjectMocks protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator(); @@ -72,11 +75,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -88,12 +88,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .thenReturn(serviceInstance); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, + OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, @@ -107,6 +103,19 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { Mockito.verifyZeroInteractions(requestsDbClient); } + private OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective( + OrchestrationStatusValidationDirective aContinue, OrchestrationStatus precreated, ResourceType service, + OrchestrationAction assign) { + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = + new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective.setFlowDirective(aContinue); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(precreated); + orchestrationStatusStateTransitionDirective.setResourceType(service); + orchestrationStatusStateTransitionDirective.setTargetAction(assign); + return orchestrationStatusStateTransitionDirective; + } + @Test public void test_validateOrchestrationStatusConfiguration() throws Exception { lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); @@ -124,11 +133,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { execution.setVariable("flowToBeCalled", flowToBeCalled); execution.setVariable("aLaCarte", true); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.CONFIGURATION); - buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN); + BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("UnassignFabricConfigurationBB", + ResourceType.CONFIGURATION, OrchestrationAction.UNASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -140,13 +146,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .thenReturn(configuration); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.CONFIGURATION); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.UNASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PRECREATED, ResourceType.CONFIGURATION, OrchestrationAction.UNASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION, @@ -160,44 +161,30 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { Mockito.verifyZeroInteractions(requestsDbClient); } - @Ignore @Test - public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception { - expectedException.expect(BpmnError.class); - + public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() { String flowToBeCalled = "AssignServiceInstanceBB"; - execution.setVariable("flowToBeCalled", flowToBeCalled); - doReturn(null).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); orchestrationStatusValidator.validateOrchestrationStatus(execution); + + verify(exceptionBuilder).buildAndThrowWorkflowException(eq(execution), eq(7000), + any(OrchestrationStatusValidationException.class)); } - @Ignore @Test - public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception { - expectedException.expect(BpmnError.class); - + public void test_validateOrchestrationStatus_orchestrationValidationFail() { String flowToBeCalled = "AssignServiceInstanceBB"; - execution.setVariable("flowToBeCalled", flowToBeCalled); - - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.FAIL, + OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, @@ -206,32 +193,23 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); Mockito.verifyZeroInteractions(requestsDbClient); + verify(exceptionBuilder).buildAndThrowWorkflowException(eq(execution), eq(7000), + any(NullPointerException.class)); } - @Ignore @Test - public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception { - expectedException.expect(BpmnError.class); - + public void test_validateOrchestrationStatus_orchestrationValidationNotFound() { String flowToBeCalled = "AssignServiceInstanceBB"; - execution.setVariable("flowToBeCalled", flowToBeCalled); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.FAIL, + OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.NETWORK, OrchestrationStatus.PRECREATED, @@ -240,24 +218,33 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); Mockito.verifyZeroInteractions(requestsDbClient); + verify(exceptionBuilder).buildAndThrowWorkflowException(eq(execution), eq(7000), + any(NullPointerException.class)); + } + + private BuildingBlockDetail getBuildingBlockDetail(String assignServiceInstanceBB, ResourceType service, + OrchestrationAction assign) { + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName(assignServiceInstanceBB); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(service); + buildingBlockDetail.setTargetAction(assign); + return buildingBlockDetail; } @Test - public void test_validateOrchestrationStatus_unassignNotFound() throws Exception { + public void test_validateOrchestrationStatus_unassignNotFound() { String flowToBeCalled = "UnassignServiceInstanceBB"; execution.setVariable("flowToBeCalled", flowToBeCalled); execution.setVariable("aLaCarte", true); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("UnassignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.UNASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); - lookupKeyMap = new HashMap<ResourceKey, String>(); + lookupKeyMap = new HashMap<>(); orchestrationStatusValidator.validateOrchestrationStatus(execution); @@ -285,21 +272,14 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -334,22 +314,14 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -387,11 +359,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -402,13 +371,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -446,11 +410,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -461,13 +422,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED, @@ -505,11 +461,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ACTIVATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -520,13 +473,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -564,11 +512,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -579,13 +524,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -611,11 +551,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { @Test public void continueValidationActivatedTest() throws Exception { String flowToBeCalled = "DeactivateVnfBB"; - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName(flowToBeCalled); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.DEACTIVATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail(flowToBeCalled, ResourceType.VF_MODULE, OrchestrationAction.DEACTIVATE); when(catalogDbClient.getBuildingBlockDetail(flowToBeCalled)).thenReturn(buildingBlockDetail); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = @@ -625,12 +562,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.ACTIVATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.DEACTIVATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, + OrchestrationStatus.ACTIVATED, ResourceType.VF_MODULE, OrchestrationAction.DEACTIVATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ACTIVATED, OrchestrationAction.DEACTIVATE); @@ -666,22 +599,14 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("DeleteVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("DeleteVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java index 23ffbac645..7f44c97f59 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java @@ -144,8 +144,7 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { @Test public void updateRequestStatusToFailedRollbackFabric() { BuildingBlock bb = new BuildingBlock().setBpmnFlowName("UnassignFabricConfigurationBB"); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ebb.setBuildingBlock(bb); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb); execution.setVariable("buildingBlock", ebb); execution.setVariable("mso-request-id", "123"); execution.setVariable("isRollbackComplete", false); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 9b41d0fada..a7ee89f073 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -44,7 +44,9 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.ModelInfo; @@ -53,7 +55,9 @@ import org.springframework.core.env.Environment; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; @@ -115,9 +119,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { ModelInfo mi = new ModelInfo(); mi.setModelUuid(modelUuid); rd.setModelInfo(mi); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ebb.setBuildingBlock(buildingBlock); - ebb.setRequestDetails(rd); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd); flowsToExecute.add(ebb); List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); @@ -152,9 +154,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { ModelInfo mi = new ModelInfo(); mi.setModelUuid(modelUuid); rd.setModelInfo(mi); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ebb.setBuildingBlock(buildingBlock); - ebb.setRequestDetails(rd); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd); ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); flowsToExecute.add(ebb); @@ -177,7 +177,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.selectBB(execution); boolean success = (boolean) execution.getVariable("completed"); int currentSequence = (int) execution.getVariable("gCurrentSequence"); - assertEquals(false, success); + assertFalse(success); assertEquals(1, currentSequence); } @@ -204,18 +204,15 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -238,18 +235,15 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -272,23 +266,19 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateNetworkCollectionBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(buildingBlock4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); execution.setVariable("flowsToExecute", flowsToExecute); @@ -312,18 +302,15 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -344,29 +331,24 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", "VfModule"); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("ChangeModelVnfBB"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(buildingBlock4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ChangeModelServiceInstanceBB"); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - ebb5.setBuildingBlock(buildingBlock5); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5); flowsToExecute.add(ebb5); execution.setVariable("flowsToExecute", flowsToExecute); @@ -389,23 +371,19 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(buildingBlock4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); execution.setVariable("flowsToExecute", flowsToExecute); @@ -422,6 +400,42 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionRollbackToCreatedWithFabricTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "RollbackToCreated"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); + flowsToExecute.add(ebb1); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); + flowsToExecute.add(ebb2); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); + flowsToExecute.add(ebb3); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); + flowsToExecute.add(ebb4); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 4); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(0, execution.getVariable("gCurrentSequence")); + assertEquals(2, ebbs.size()); + assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName()); + assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName()); + + } + + @Test public void rollbackExecutionRollbackToCreatedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToCreated"); @@ -429,18 +443,15 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -461,53 +472,43 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(buildingBlock4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity"); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - ebb5.setBuildingBlock(buildingBlock5); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5); flowsToExecute.add(ebb5); BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFLockActivity"); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - ebb6.setBuildingBlock(buildingBlock6); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6); flowsToExecute.add(ebb6); BuildingBlock buildingBlock7 = new BuildingBlock().setBpmnFlowName("VNFUpgradePreCheckActivity"); - ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock(); - ebb7.setBuildingBlock(buildingBlock7); + ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock7); flowsToExecute.add(ebb7); BuildingBlock buildingBlock8 = new BuildingBlock().setBpmnFlowName("VNFQuiesceTrafficActivity"); - ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock(); - ebb8.setBuildingBlock(buildingBlock8); + ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock8); flowsToExecute.add(ebb8); BuildingBlock buildingBlock9 = new BuildingBlock().setBpmnFlowName("VNFStopActivity"); - ExecuteBuildingBlock ebb9 = new ExecuteBuildingBlock(); - ebb9.setBuildingBlock(buildingBlock9); + ExecuteBuildingBlock ebb9 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock9); flowsToExecute.add(ebb9); BuildingBlock buildingBlock10 = new BuildingBlock().setBpmnFlowName("VNFSnapShotActivity"); - ExecuteBuildingBlock ebb10 = new ExecuteBuildingBlock(); - ebb10.setBuildingBlock(buildingBlock10); + ExecuteBuildingBlock ebb10 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock10); flowsToExecute.add(ebb10); execution.setVariable("flowsToExecute", flowsToExecute); @@ -532,33 +533,27 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(buildingBlock1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(buildingBlock2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(buildingBlock3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(buildingBlock4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity"); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - ebb5.setBuildingBlock(buildingBlock5); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5); flowsToExecute.add(ebb5); BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFHealthCheckActivity"); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - ebb6.setBuildingBlock(buildingBlock6); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6); flowsToExecute.add(ebb6); execution.setVariable("flowsToExecute", flowsToExecute); @@ -572,6 +567,55 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { assertEquals(2, ebbs.size()); } + @Test + public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException { + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + + WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds(); + resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id"); + resourceIdsActivateVfModule.setVnfId("test-vnf-id"); + resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id"); + resourceIdsActivateVfModule.setConfigurationId(""); + + RequestDetails requestDetails = new RequestDetails(); + + ebbActivateVfModule.setApiVersion("7"); + ebbActivateVfModule.setaLaCarte(true); + ebbActivateVfModule.setRequestAction("createInstance"); + ebbActivateVfModule.setVnfType("test-vnf-type"); + ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12"); + ebbActivateVfModule.setRequestDetails(requestDetails); + ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule); + + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb"); + configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76"); + configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c"); + configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001"); + + ExecuteBuildingBlock ebbAddFabricConfig = + workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule, + "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys); + + assertEquals("7", ebbAddFabricConfig.getApiVersion()); + assertTrue(ebbAddFabricConfig.isaLaCarte()); + assertEquals("createInstance", ebbAddFabricConfig.getRequestAction()); + assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType()); + assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId()); + assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails()); + assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4", + ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()); + assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId()); + assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId()); + assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId()); + + assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys); + assertThat(ebbAddFabricConfig.getWorkflowResourceIds()) + .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds()); + assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()) + .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId()); + } @Test public void checkRetryStatusTest() { @@ -634,7 +678,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void getConfigurationId() { + public void getConfigurationId() throws Exception { org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); vnfc.setModelInvariantId("modelInvariantId"); vnfc.setVnfcName("testVnfcName"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java index e064fb0b64..73aace7592 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java @@ -68,12 +68,10 @@ public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest { public void getUpdatedRequestTest() throws Exception { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); BuildingBlock bb1 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB"); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - ebb1.setBuildingBlock(bb1); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(bb1); flowsToExecute.add(ebb1); BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(bb2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2); flowsToExecute.add(ebb2); String requestId = "requestId"; execution.setVariable("mso-request-id", requestId); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index c762c16d92..407a844c4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -43,6 +43,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.net.MalformedURLException; @@ -116,6 +117,15 @@ import org.springframework.core.env.Environment; public class WorkflowActionTest extends BaseTaskTest { + private static final String MACRO_ACTIVATE_DELETE_UNASSIGN_JSON = "Macro/ServiceMacroActivateDeleteUnassign.json"; + private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json"; + private static final String MACRO_ASSIGN_NO_CLOUD_JSON = "Macro/ServiceMacroAssignNoCloud.json"; + private static final String VF_MODULE_CREATE_WITH_FABRIC_JSON = "VfModuleCreateWithFabric.json"; + private static final String VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON = + "VfModuleReplaceRebuildVolumeGroups.json"; + private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json"; + private static final String MACRO_VNF_MACRO_REPLACE_JSON = "Macro/VnfMacroReplace.json"; + @Mock protected Environment environment; @InjectMocks @@ -140,6 +150,11 @@ public class WorkflowActionTest extends BaseTaskTest { "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + private List<OrchestrationFlow> replaceVfModuleWithFabricOrchFlows = createFlowList("DeleteFabricConfigurationBB", + "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", + "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "AssignVfModuleBB", + "CreateVfModuleBB", "ActivateVfModuleBB", "AddFabricConfigurationBB", "CreateVolumeGroupBB", + "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); @Before public void before() throws Exception { @@ -158,13 +173,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteNetworkCreateTest() throws Exception { String gAction = "createInstance"; String resource = "Network"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/networks/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -183,13 +193,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "Network"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/networks/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -208,13 +213,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteServiceCreateTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/serviceInstances/123"); @@ -230,87 +230,11 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void selectExecutionListExceptionAlreadyBuiltTest() throws Exception { - DelegateExecution delegateExecution = new DelegateExecutionFake(); - String gAction = "deleteInstance"; - String resource = "VfModule"; - delegateExecution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - delegateExecution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - delegateExecution.setVariable("bpmnRequest", bpmnRequest); - delegateExecution.setVariable("aLaCarte", true); - delegateExecution.setVariable("apiVersion", "7"); - delegateExecution.setVariable("requestUri", - "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); - - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); - List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB"); - northBoundRequest.setOrchestrationFlowList(orchFlows); - - when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, - true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); - - doAnswer(invocation -> { - DelegateExecutionFake execution = invocation.getArgument(0); - execution.setVariable("WorkflowException", "exception"); - execution.setVariable("WorkflowExceptionErrorMessage", "errorMessage"); - throw new BpmnError("WorkflowException"); - }).when(exceptionUtil).buildAndThrowWorkflowException(delegateExecution, 7000, - "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations"); - - - org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); - vnf.setVnfId("vnf0"); - vnf.setModelCustomizationId("modelCustomizationId"); - when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); - - org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); - vfModule.setModelCustomizationId("modelCustomizationId"); - when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); - - List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); - org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); - vnfc.setModelInvariantId("modelInvariantId"); - vnfc.setVnfcName("testVnfcName"); - vnfcs.add(vnfc); - doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); - - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); - org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); - configuration.setConfigurationId("configurationId"); - configuration.setModelCustomizationId("modelCustimizationId"); - configuration.setConfigurationName("testConfigurationName"); - configurations.add(configuration); - org.onap.aai.domain.yang.Configuration configuration1 = new org.onap.aai.domain.yang.Configuration(); - configuration1.setConfigurationId("configurationId"); - configuration1.setModelCustomizationId("modelCustimizationId"); - configuration1.setConfigurationName("testConfigurationName"); - configurations.add(configuration1); - doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any()); - - doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(any()); - - thrown.expect(BpmnError.class); - SPY_workflowAction.selectExecutionList(delegateExecution); - assertEquals( - "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations", - delegateExecution.getVariable("WorkflowException")); - } - - @Test public void selectExecutionListDuplicateNameExceptionTest() throws Exception { String gAction = "createInstance"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/serviceInstances"); - execution.setVariable("requestAction", gAction); doThrow(new DuplicateNameException( "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique.")) @@ -329,16 +253,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroAssignTest() throws Exception { String gAction = "assignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB"); @@ -383,16 +301,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception { String gAction = "assignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_NO_CLOUD_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB"); @@ -438,16 +350,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroActivateTest() throws Exception { String gAction = "activateInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/si0"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", @@ -462,7 +368,6 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); vnf.setVnfId("vnf0"); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule(); @@ -492,23 +397,16 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals("testVfModuleId2", ebbs.get(5).getWorkflowResourceIds().getVfModuleId()); assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId()); assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId()); - } @Test public void selectExecutionListServiceMacroDeactivateTest() throws Exception { String gAction = "deactivateInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); @@ -524,16 +422,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -556,16 +448,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -592,16 +478,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -687,16 +567,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB", @@ -769,21 +643,16 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB", - "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", - "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB"); + "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", + "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", + "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", + "UnassignServiceInstanceBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); ServiceInstance serviceInstanceAAI = new ServiceInstance(); @@ -792,7 +661,10 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf(); vnf.setVnfId("vnfId123"); + pnf.setPnfId("pnfId123"); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); @@ -805,6 +677,7 @@ public class WorkflowActionTest extends BaseTaskTest { vnf.getVolumeGroups().add(volumeGroup); serviceInstanceMSO.getVnfs().add(vnf); + serviceInstanceMSO.getPnfs().add(pnf); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); @@ -814,24 +687,53 @@ public class WorkflowActionTest extends BaseTaskTest { List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", - "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", - "UnassignVnfBB", "UnassignServiceInstanceBB"); + "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", + "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB"); + } + + @Test + public void selectExecutionListServiceMacroDeleteWithPnfTest() throws Exception { + String gAction = "deleteInstance"; + String resource = "Service"; + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); + execution.setVariable("requestUri", "v6/serviceInstances/123"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", + "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", + "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", + "UnassignServiceInstanceBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + ServiceInstance serviceInstanceAAI = new ServiceInstance(); + serviceInstanceAAI.setServiceInstanceId("aaisi123"); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = + new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf(); + pnf.setPnfId("pnfId123"); + + serviceInstanceMSO.getPnfs().add(pnf); + + doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); + doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs, "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB"); } @Test public void selectExecutionListServiceMacroUnassignTest() throws Exception { String gAction = "unassignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB"); @@ -871,16 +773,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception { String gAction = "deleteInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB", @@ -920,13 +816,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListVnfMacroRecreateTest() throws Exception { String gAction = "recreateInstance"; String resource = "Vnf"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/recreate"); execution.setVariable("serviceInstanceId", "123"); execution.setVariable("vnfId", "1234"); @@ -974,13 +865,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListVnfMacroReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "Vnf"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace"); execution.setVariable("serviceInstanceId", "123"); execution.setVariable("vnfId", "1234"); @@ -1047,16 +933,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListNetworkCollectionMacroCreate() throws Exception { String gAction = "createInstance"; String resource = "NetworkCollection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB"); @@ -1084,13 +964,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListNetworkCollectionMacroDelete() throws Exception { String gAction = "deleteInstance"; String resource = "NetworkCollection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -1119,17 +994,11 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception { String gAction = "createInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB"); @@ -1146,13 +1015,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception { String gAction = "createInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1205,13 +1069,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); @@ -1231,13 +1090,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); @@ -1256,13 +1110,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1289,13 +1138,8 @@ public class WorkflowActionTest extends BaseTaskTest { throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1322,13 +1166,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1360,16 +1199,69 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void selectExecutionListALaCarteVfModuleWithFabricKeepVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModuleFromAAI = new org.onap.aai.domain.yang.VfModule(); + vfModuleFromAAI.setModelCustomizationId("modelCustomizationId"); + vfModuleFromAAI.setVfModuleId("1234"); + when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModuleFromAAI); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("modelInvariantId"); + vnfc.setVnfcName("testVnfcName"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setModelCustomizationId("modelCustimizationId"); + configuration.setConfigurationName("testConfigurationName"); + doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any()); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleWithFabricOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + SPY_workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeleteFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleATTBB", + "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", + "AddFabricConfigurationBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1403,13 +1295,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1440,13 +1327,8 @@ public class WorkflowActionTest extends BaseTaskTest { throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1476,13 +1358,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1518,13 +1395,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1561,13 +1433,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1596,18 +1463,13 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject()); - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); configuration.setConfigurationId("configurationId"); configuration.setModelCustomizationId("modelCustimizationId"); configuration.setConfigurationName("testConfigurationName"); - configurations.add(configuration); - doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), + doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject()); - doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject()); - SPY_workflowAction.selectExecutionList(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", @@ -1619,10 +1481,9 @@ public class WorkflowActionTest extends BaseTaskTest { String gAction = "deleteInstance"; ObjectMapper mapper = new ObjectMapper(); WorkflowType resourceType = WorkflowType.VFMODULE; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); execution.setVariable("bpmnRequest", bpmnRequest); execution.setVariable("vnfId", "1234"); execution.setVariable("vfModuleId", "vfModuleId1234"); @@ -1647,19 +1508,10 @@ public class WorkflowActionTest extends BaseTaskTest { List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB"); - ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject(); - dataObj.setsIRequest(sIRequest); - dataObj.setOrchFlows(orchFlows); - dataObj.setRequestId(requestId); - dataObj.setResourceKey(resourceKey); - dataObj.setApiVersion(apiVersion); - dataObj.setResourceId(resourceId); - dataObj.setRequestAction(requestAction); - dataObj.setaLaCarte(aLaCarte); - dataObj.setVnfType(vnfType); - dataObj.setWorkflowResourceIds(workflowResourceIds); - dataObj.setRequestDetails(requestDetails); - dataObj.setExecution(execution); + ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest) + .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution); org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); vnf.setVnfId("vnf0"); @@ -1674,22 +1526,92 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { + public void getConfigBuildingBlocksTest() throws Exception { String gAction = "deleteInstance"; - String resource = "VfModule"; + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); + + WorkflowType resourceType = WorkflowType.VFMODULE; execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); execution.setVariable("requestAction", gAction); String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + execution.setVariable("vnfId", "1234"); + execution.setVariable("vfModuleId", "vfModuleId1234"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + String requestAction = "deleteInstance"; + String requestId = "9c944122-d161-4280-8594-48c06a9d96d5"; + boolean aLaCarte = true; + String apiVersion = "7"; + String vnfType = "vnfType"; + String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0"; + String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e"; + Resource resourceKey = new Resource(resourceType, key, aLaCarte); + WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution); + + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "UnassignVfModuleBB", "DeleteFabricConfigurationBB"); + + ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest) + .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("vnf0"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setModelCustomizationId("modelCustomizationId"); + + org.onap.aai.domain.yang.Configuration config1 = new org.onap.aai.domain.yang.Configuration(); + config1.setConfigurationId("config1"); + org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration(); + config2.setConfigurationId("config2"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc(); + vnfc1.setVnfcName("zauk53avetd02svm001"); + org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc(); + vnfc2.setVnfcName("zauk53avetd02tvm001"); + vnfcs.add(vnfc1); + vnfcs.add(vnfc2); + + when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), + eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC)); + doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + + List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); + + assertFalse(results.isEmpty()); + assertEquals(2, results.size()); + assertEquals("config1", results.get(0).getWorkflowResourceIds().getConfigurationId()); + assertEquals("config2", results.get(1).getWorkflowResourceIds().getConfigurationId()); + assertEquals("zauk53avetd02svm001", results.get(0).getConfigurationResourceKeys().getVnfcName()); + assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName()); + } + + @Test + public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { + String gAction = "deleteInstance"; + String resource = "VfModule"; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB"); + "UnassignVfModuleBB", "DeleteFabricConfigurationBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, @@ -1705,21 +1627,10 @@ public class WorkflowActionTest extends BaseTaskTest { when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule); List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); - org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); - vnfc.setModelInvariantId("modelInvariantId"); - vnfc.setVnfcName("testVnfcName"); - vnfcs.add(vnfc); - doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), - anyObject()); - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); - org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); - doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject()); - doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject()); - SPY_workflowAction.selectExecutionList(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB"); @@ -1729,13 +1640,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListMacroResumeTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -1789,10 +1695,9 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(), anyObject()); - List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc( - vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); - assertEquals(1, configurationsList.size()); - assertEquals("testConfigurationId", configurationsList.get(0).getConfigurationId()); + org.onap.aai.domain.yang.Configuration configuration = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, + org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); + assertEquals("testConfigurationId", configuration.getConfigurationId()); } /** @@ -1816,33 +1721,27 @@ public class WorkflowActionTest extends BaseTaskTest { List<ExecuteBuildingBlock> executeFlows = new ArrayList<>(); BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("0"); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ebb.setBuildingBlock(bb); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb); executeFlows.add(ebb); BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("1"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(bb2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2); executeFlows.add(ebb2); BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("0"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(bb3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3); executeFlows.add(ebb3); BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("1"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(bb4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4); executeFlows.add(ebb4); BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("0"); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - ebb5.setBuildingBlock(bb5); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5); executeFlows.add(ebb5); BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("1"); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - ebb6.setBuildingBlock(bb6); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6); executeFlows.add(ebb6); List<ExecuteBuildingBlock> sorted = @@ -1856,33 +1755,27 @@ public class WorkflowActionTest extends BaseTaskTest { List<ExecuteBuildingBlock> executeFlows = new ArrayList<>(); BuildingBlock bb = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("0"); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ebb.setBuildingBlock(bb); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb); executeFlows.add(ebb); BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("1"); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - ebb2.setBuildingBlock(bb2); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2); executeFlows.add(ebb2); BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("0"); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - ebb3.setBuildingBlock(bb3); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3); executeFlows.add(ebb3); BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("1"); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - ebb4.setBuildingBlock(bb4); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4); executeFlows.add(ebb4); BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("0"); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - ebb5.setBuildingBlock(bb5); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5); executeFlows.add(ebb5); BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("1"); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - ebb6.setBuildingBlock(bb6); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6); executeFlows.add(ebb6); List<ExecuteBuildingBlock> sorted = @@ -2982,8 +2875,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a"); doReturn(collectionResourceCustomization).when(catalogDbClient) .getNetworkCollectionResourceCustomizationByID("123"); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); ObjectMapper mapper = new ObjectMapper(); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); List<Resource> resourceCounter = new ArrayList<>(); @@ -3070,7 +2962,7 @@ public class WorkflowActionTest extends BaseTaskTest { ExecuteBuildingBlock result = null; try { result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, - false, null, null, null, false, null, null, true); + false, null, null, null, false, null, null, true, null); } catch (NullPointerException e) { fail("NullPointerException should not be thrown when 'resource' is null"); } @@ -3159,4 +3051,16 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]); } } + + private void initExecution(String gAction, String bpmnRequest, boolean isAlaCarte) { + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", isAlaCarte); + execution.setVariable("apiVersion", "7"); + } + + private String readBpmnRequestFromFile(String fileName) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName))); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java index 1b4ddf71c2..9d208f41e8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java @@ -91,10 +91,8 @@ public class MultiStageSkipListenerTest { workflowResourceIds.setServiceInstanceId("serviceInstanceId"); workflowResourceIds.setVnfId(vnfId); BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ebb.setResourceId(vfModuleId); - ebb.setBuildingBlock(bb); - ebb.setWorkflowResourceIds(workflowResourceIds); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setResourceId(vfModuleId).setBuildingBlock(bb) + .setWorkflowResourceIds(workflowResourceIds); flowsToExecute.add(ebb); flowsToExecute.add(new ExecuteBuildingBlock()); flowsToExecute.add(new ExecuteBuildingBlock()); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java deleted file mode 100644 index 3ae0db627a..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Intel Corp. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.oof; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.oof.beans.LicenseInfo; -import org.onap.so.client.oof.beans.ModelInfo; -import org.onap.so.client.oof.beans.OofRequest; -import org.onap.so.client.oof.beans.OofRequestParameters; -import org.onap.so.client.oof.beans.PlacementDemand; -import org.onap.so.client.oof.beans.PlacementInfo; -import org.onap.so.client.oof.beans.RequestInfo; -import org.onap.so.client.oof.beans.ResourceModelInfo; -import org.onap.so.client.oof.beans.ServiceInfo; -import org.onap.so.client.oof.beans.SubscriberInfo; -import org.skyscreamer.jsonassert.JSONAssert; -import org.springframework.beans.factory.annotation.Autowired; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.util.ArrayList; -import java.util.List; - - -public class OofClientTestIT extends BaseIntegrationTest { - - @Autowired - private OofClient client; - - @Test - public void testPostDemands_success() throws BadResponseException, JsonProcessingException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}"; - - ModelInfo modelInfo = new ModelInfo(); - modelInfo.setModelCustomizationName("modelCustomizationName-Service"); - modelInfo.setModelInvariantId("modelInvariantId-Service"); - modelInfo.setModelName("modelName-Service"); - modelInfo.setModelType("modelType-Service"); - modelInfo.setModelVersion("modelVersion-Service"); - modelInfo.setModelVersionId("modelVersionId-Service"); - - ServiceInfo serviceInfo = new ServiceInfo(); - serviceInfo.setModelInfo(modelInfo); - serviceInfo.setServiceInstanceId("serviceInstanceId"); - serviceInfo.setServiceName("serviceName"); - - SubscriberInfo subscriberInfo = new SubscriberInfo(); - subscriberInfo.setGlobalSubscriberId("globalSubscriberId"); - subscriberInfo.setSubscriberCommonSiteId("subscriberCommonSiteId"); - subscriberInfo.setSubscriberName("subscriberName"); - - ResourceModelInfo resourceModelInfo = new ResourceModelInfo(); - resourceModelInfo.setModelType("modelType"); - resourceModelInfo.setModelCustomizationName("modelCustomizationName"); - resourceModelInfo.setModelInvariantId("invarianteId"); - resourceModelInfo.setModelName("modelName"); - resourceModelInfo.setModelVersion("version"); - resourceModelInfo.setModelVersionId("versionId"); - - PlacementDemand placementDemand = new PlacementDemand(); - placementDemand.setResourceModelInfo(resourceModelInfo); - placementDemand.setResourceModuleName("resourceModuleName"); - placementDemand.setServiceResourceId("serviceResourceId"); - placementDemand.setTenantId("tenantId"); - - OofRequestParameters oofRequestParameters = new OofRequestParameters(); - oofRequestParameters.setCustomerLatitude("customerLatitude"); - oofRequestParameters.setCustomerLongitude("customerLongitude"); - oofRequestParameters.setCustomerName("customerName"); - - ArrayList<PlacementDemand> placementDemands = new ArrayList<>(); - placementDemands.add(placementDemand); - - PlacementInfo placementInfo = new PlacementInfo(); - placementInfo.setPlacementDemands(placementDemands); - placementInfo.setRequestParameters(oofRequestParameters); - placementInfo.setSubscriberInfo(subscriberInfo); - - RequestInfo requestInfo = new RequestInfo(); - requestInfo.setTransactionId("transactionId"); - List<String> optimizer = new ArrayList<>(); - optimizer.add("optimizer1"); - optimizer.add("optimizer2"); - requestInfo.setOptimizers(optimizer); - requestInfo.setCallbackUrl("callBackUrl"); - requestInfo.setNumSolutions(1); - requestInfo.setRequestId("requestId"); - requestInfo.setSourceId("sourceId"); - requestInfo.setTimeout(30L); - requestInfo.setRequestType("requestType"); - - OofRequest oofRequest = new OofRequest(); - oofRequest.setRequestInformation(requestInfo); - oofRequest.setPlacementInformation(placementInfo); - oofRequest.setServiceInformation(serviceInfo); - oofRequest.setLicenseInformation(new LicenseInfo()); - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postDemands(oofRequest); - - String oofRequestOutput = oofRequest.toJsonString(); - JSONAssert.assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n" - + " \"requestId\" : \"requestId\",\n" + " \"callbackUrl\" : \"callBackUrl\",\n" - + " \"sourceId\" : \"sourceId\",\n" + " \"requestType\" : \"requestType\",\n" - + " \"numSolutions\" : 1,\n" + " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" - + " \"timeout\" : 30\n" + " },\n" + " \"serviceInfo\" : {\n" - + " \"serviceInstanceId\" : \"serviceInstanceId\",\n" + " \"serviceName\" : \"serviceName\",\n" - + " \"modelInfo\" : {\n" + " \"modelType\" : \"modelType-Service\",\n" - + " \"modelInvariantId\" : \"modelInvariantId-Service\",\n" - + " \"modelVersionId\" : \"modelVersionId-Service\",\n" - + " \"modelName\" : \"modelName-Service\",\n" - + " \"modelVersion\" : \"modelVersion-Service\",\n" - + " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" + " }\n" + " },\n" - + " \"placementInfo\" : {\n" + " \"requestParameters\" : {\n" - + " \"customerLatitude\" : \"customerLatitude\",\n" - + " \"customerLongitude\" : \"customerLongitude\",\n" - + " \"customerName\" : \"customerName\"\n" + " },\n" + " \"subscriberInfo\" : {\n" - + " \"globalSubscriberId\" : \"globalSubscriberId\",\n" - + " \"subscriberName\" : \"subscriberName\",\n" - + " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" + " },\n" - + " \"placementDemands\" : [ {\n" + " \"resourceModuleName\" : \"resourceModuleName\",\n" - + " \"serviceResourceId\" : \"serviceResourceId\",\n" + " \"tenantId\" : \"tenantId\",\n" - + " \"resourceModelInfo\" : {\n" + " \"modelType\" : \"modelType\",\n" - + " \"modelInvariantId\" : \"invarianteId\",\n" + " \"modelVersionId\" : \"versionId\",\n" - + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n" - + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n" - + " },\n" + " \"licenseInfo\" : { \n" + " \"licenseDemands\" : [ ]\n" + "}\n" + "}", - oofRequestOutput, false); - } - - @Test - public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postDemands(new OofRequest()); - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - - // TODO assertEquals("missing data", ); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException { - String mockResponse = "{ }"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java index 59cd53edd5..b8be045f97 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java @@ -48,13 +48,18 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @RunWith(MockitoJUnitRunner.Silent.class) public class AAIPnfResourcesTest extends TestDataSetup { + public static final String TEST_VERSION = "testVersion"; private static final String PNF_NAME = "pnfTest"; + public static final String TEST_CUSTOMIZATION_UUID = "testCustomizationUuid"; + public static final String TEST_INVARIANT_UUID = "testInvariantUuid"; + public static final String TEST_ROLE = "testRole"; private Pnf pnf; private ServiceInstance serviceInstance; @@ -110,42 +115,87 @@ public class AAIPnfResourcesTest extends TestDataSetup { @Test public void existingPnfInAaiWithInventoriedStatusCanBeUsed() throws Exception { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.INVENTORIED.toString()); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); + verify(aaiResourcesClientMock, times(1)).update(any(), any()); } @Test public void existingPnfInAaiWithNullStatusCanBeUsed() throws Exception { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null); + pnfTest.setRole("test"); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); + verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai)); + } + + @Test + public void existingPnfInAaiIsUpdated() throws Exception { + // given + org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null); + Pnf pnfTest = getPnfWithTestValues(); + when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + // when + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); + verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai)); + verifyPnfFromAai(pnfFromAai); + } + + private void verifyPnfFromAai(org.onap.aai.domain.yang.Pnf pnf) { + assertEquals(OrchestrationStatus.INVENTORIED.toString(), pnf.getOrchestrationStatus()); + assertEquals(TEST_ROLE, pnf.getNfRole()); + assertEquals(TEST_CUSTOMIZATION_UUID, pnf.getModelCustomizationId()); + assertEquals(TEST_INVARIANT_UUID, pnf.getModelInvariantId()); + assertEquals(TEST_VERSION, pnf.getModelVersionId()); + } + + private Pnf getPnfWithTestValues() { + Pnf pnfTest = createPnfWithDefaultName(); + ModelInfoPnf modelInfoPnf = getModelInfoPnf(); + pnfTest.setModelInfoPnf(modelInfoPnf); + pnfTest.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); + pnfTest.setRole(TEST_ROLE); + return pnfTest; + } + + private ModelInfoPnf getModelInfoPnf() { + ModelInfoPnf modelInfoPnf = new ModelInfoPnf(); + modelInfoPnf.setModelCustomizationUuid(TEST_CUSTOMIZATION_UUID); + modelInfoPnf.setModelInvariantUuid(TEST_INVARIANT_UUID); + modelInfoPnf.setModelUuid(TEST_VERSION); + return modelInfoPnf; } @Test public void existingPnfInAaiWithEmptyStatusCanBeUsed() throws Exception { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(Strings.EMPTY); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } @Test public void existingPnfInAaiCanNotBeUsed() { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.ACTIVE.toString()); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when try { - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } catch (Exception e) { // then assertThat(e.getMessage()).isEqualTo(String.format( @@ -153,6 +203,7 @@ public class AAIPnfResourcesTest extends TestDataSetup { + "if status is not set or set as Inventoried", PNF_NAME)); } + verify(aaiResourcesClientMock, times(0)).update(any(), any()); } @Test @@ -161,19 +212,21 @@ public class AAIPnfResourcesTest extends TestDataSetup { final String relatedTo = "service-instance"; final String serviceInstanceId = "service-instance-id"; final String path = "src/test/resources/__files/BuildingBlocks/aaiPnf.json"; + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when try { - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } catch (Exception e) { // then assertThat(e.getMessage()).isEqualTo(String.format( "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s", PNF_NAME, OrchestrationStatus.ACTIVE, relatedTo, serviceInstanceId)); } + verify(aaiResourcesClientMock, times(0)).update(any(), any()); } private org.onap.aai.domain.yang.Pnf createPnf(String orchestrationStatus) { @@ -182,4 +235,10 @@ public class AAIPnfResourcesTest extends TestDataSetup { pnfFromAai.setOrchestrationStatus(orchestrationStatus); return pnfFromAai; } + + private Pnf createPnfWithDefaultName() { + Pnf pnfTest = new Pnf(); + pnfTest.setPnfName(PNF_NAME); + return pnfTest; + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java index 9049fe1965..3429a16f0b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -45,7 +46,6 @@ 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.mapper.GCTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCConfigurationResourcesTest extends TestDataSetup { 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 327bae5749..f86a712e33 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 @@ -32,6 +32,7 @@ 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.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -42,7 +43,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.mapper.NetworkTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCNetworkResourcesTest extends TestDataSetup { 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 ad05ac0072..4282b0d158 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 @@ -35,6 +35,7 @@ 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.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCServiceInstanceResourcesTest extends TestDataSetup { 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 14e993281a..813c2f7cd4 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 @@ -33,6 +33,7 @@ import org.mockito.Mock; 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.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -43,8 +44,7 @@ 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.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation;; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVfModuleResourcesTest extends TestDataSetup { 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 0ccf056ddc..f9c380bc84 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 @@ -39,6 +39,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -49,7 +50,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.mapper.VnfTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVnfResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java deleted file mode 100644 index a8816e1b04..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import java.util.LinkedHashMap; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SdnCommonTasks; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; - - -public class SdnCommonTasksTest { - - - SdnCommonTasks sdnCommonTasks = new SdnCommonTasks(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void buildJsonRequestTest() throws MapperException { - String jsonStr = sdnCommonTasks.buildJsonRequest(""); - Assert.assertNotNull(jsonStr); - } - - @Test - public void buildJsonRequestTestException() throws MapperException { - expectedException.expect(MapperException.class); - sdnCommonTasks.buildJsonRequest(new Object()); - } - - @Test - public void getHttpHeadersTest() { - HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", true); - - assertEquals("auth", result.getFirst("Authorization")); - assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Content-Type")); - assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); - } - - @Test - public void getHttpHeadersGetRequestTest() { - HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", false); - - assertEquals("auth", result.getFirst("Authorization")); - assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); - assertFalse(result.containsKey("Content-Type")); - } - - @Test - public void validateSDNResponseTest() throws BadResponseException { - String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}"; - LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>(); - LinkedHashMap<String, Object> output = new LinkedHashMap<>(); - output.put("response-code", "0"); - output.put("response-message", "success"); - responseMap.put("output", output); - assertEquals(jsonResponse, sdnCommonTasks.validateSDNResponse(responseMap)); - } - - @Test - public void validateSDNResponseTestException() throws BadResponseException { - expectedException.expect(BadResponseException.class); - LinkedHashMap responseMap = new LinkedHashMap(); - Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap)); - } - - @Test - public void validateSDNResponseTestRespCodeNot200() throws BadResponseException { - expectedException.expect(BadResponseException.class); - LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>(); - LinkedHashMap<String, Object> output = new LinkedHashMap<>(); - output.put("response-code", "300"); - output.put("response-message", "Failed"); - responseMap.put("output", output); - sdnCommonTasks.validateSDNResponse(responseMap); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java deleted file mode 100644 index 0b338bde1d..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.skyscreamer.jsonassert.JSONAssert; - -public class SDNCClientIT extends BaseIntegrationTest { - private final static String JSON_FILE_LOCATION = "src/test/resources/__files/"; - - @Test - public void getTest() throws BadResponseException, MapperException, IOException { - String responseJson = - new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json"))); - String queryLink = "/topologyQuery"; - - wireMockServer.stubFor(get(urlEqualTo(queryLink)).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); - String response = SPY_sdncClient.get(queryLink); - JSONAssert.assertEquals(responseJson, response, false); - } - - @Test(expected = BadResponseException.class) - public void post404Test() throws BadResponseException, MapperException, IOException { - String responseJson = - new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json"))); - - String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; - - wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); - - SPY_sdncClient.post("", SDNCTopology.NETWORK); - } - - @Test - public void post200Test() throws BadResponseException, MapperException, IOException { - String responseJson = - new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json"))); - - String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; - - wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); - - String response = SPY_sdncClient.post("", SDNCTopology.NETWORK); - JSONAssert.assertEquals(responseJson, response, true); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java deleted file mode 100644 index 750e578558..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno; - -import static org.junit.Assert.assertEquals; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Optional; -import org.junit.Test; -import org.onap.so.client.sdno.beans.SDNO; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOHealthCheckClientTest { - - - - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/health-check/"; - private static final String userId = "test-user"; - private static final Optional<String> clliCode = Optional.of("test-clli"); - private static final String requestId = "test-request-id"; - private static final String configurationId = "test-configuration-id"; - private static final String interfaceId = "test-interface-id"; - - @Test - public void verfyLPortMirrorPreCheckRequest() throws IOException { - String content = this.getJson("custom-lport-mirror-pre-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = - client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - @Test - public void verfyLPortMirrorPostCheckRequest() throws IOException { - String content = this.getJson("custom-lport-mirror-post-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = - client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - @Test - public void verifyPortMirrorPostCheckRequest() throws IOException { - String content = this.getJson("custom-port-mirror-post-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - - } - - @Test - public void verifyPortMirrorPreCheckRequest() throws IOException { - String content = this.getJson("custom-port-mirror-pre-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java deleted file mode 100644 index b91f83c1b7..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.UUID; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.dmaap.Consumer; -import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; -import org.onap.so.client.exceptions.SDNOException; -import org.onap.so.client.sdno.beans.SDNO; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import com.fasterxml.jackson.databind.ObjectMapper; - - - -public class SDNOValidatorIT extends BaseIntegrationTest { - - - @Mock - private Consumer mrConsumer; - private SDNOHealthCheckDmaapConsumer dmaapConsumer; - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/"; - private final String uuid = "xyz123"; - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUpTests() { - MockitoAnnotations.initMocks(this); - - } - - @Test - public void success() throws IOException, Exception { - dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); - when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); - when(mrConsumer.fetch()) - .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-success.json")})); - - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - SDNOValidatorImpl spy = spy(validator); - when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); - doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); - boolean result = spy.pollForResponse("xyz123"); - assertEquals("result is true", result, true); - } - - @Test - public void failure() throws IOException, Exception { - dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); - - when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); - when(mrConsumer.fetch()) - .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-failure.json")})); - - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - SDNOValidatorImpl spy = spy(validator); - when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); - doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); - thrown.expect(SDNOException.class); - thrown.expectMessage(containsString("my error message")); - boolean result = spy.pollForResponse("xyz123"); - - } - - @Ignore - @Test - public void run() throws Exception { - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - UUID uuid = UUID.randomUUID(); - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("test"); - vnf.setIpv4OamAddress("1.2.3.4"); - vnf.setNfRole("VPE"); - SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(request); - validator.submitRequest(json); - thrown.expect(DMaaPConsumerFailure.class); - boolean result = validator.pollForResponse(uuid.toString()); - System.out.println(json); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java deleted file mode 100644 index c2278c26f9..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno; - -import static org.junit.Assert.assertEquals; -import java.util.UUID; -import org.junit.Test; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; -import org.onap.so.client.sdno.beans.SDNO; - -public class SDNOValidatorImplTest { - - @Test - public void buildRequestDiagnosticTest() throws Exception { - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - UUID uuid = UUID.randomUUID(); - GenericVnf vnf = new GenericVnf(); - vnf.setVnfName("VNFNAME"); - vnf.setVnfId("test"); - vnf.setIpv4OamAddress("1.2.3.4"); - vnf.setNfRole("VPE"); - SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); - assertEquals(request.getNodeType(), "VPE"); - assertEquals(request.getOperation(), "health-diagnostic"); - - RequestHealthDiagnostic innerRequest = request.getBody().getInput().getRequestHealthDiagnostic(); - assertEquals(innerRequest.getRequestClientName(), "MSO"); - assertEquals(innerRequest.getRequestNodeName(), "VNFNAME"); - assertEquals(innerRequest.getRequestNodeUuid(), "test"); - assertEquals(innerRequest.getRequestNodeType(), "VPE"); - assertEquals(innerRequest.getRequestNodeIp(), "1.2.3.4"); - assertEquals(innerRequest.getRequestUserId(), "mechid"); - assertEquals(innerRequest.getRequestId(), uuid.toString()); - assertEquals(innerRequest.getHealthDiagnosticCode(), "default"); - - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java deleted file mode 100644 index 56c52388f8..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sniro; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.sniro.beans.SniroConductorRequest; -import org.onap.so.client.sniro.beans.SniroManagerRequest; -import org.springframework.beans.factory.annotation.Autowired; -import com.fasterxml.jackson.core.JsonProcessingException; - - -public class SniroClientTestIT extends BaseIntegrationTest { - - @Autowired - private SniroClient client; - - - @Test(expected = Test.None.class) - public void testPostDemands_success() throws BadResponseException, JsonProcessingException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postDemands(new SniroManagerRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - - // TODO assertEquals("missing data", ); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException { - String mockResponse = "{ }"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - } - - @Test(expected = Test.None.class) - public void testPostRelease_success() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"success\", \"message\": \"corys cool\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_failed() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"failure\", \"message\": \"corys cool\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_noStatus() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"\", \"message\": \"corys cool\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_noMessage() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"failure\", \"message\": null}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_empty() throws BadResponseException, JsonProcessingException { - String mockResponse = "{ }"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json index 957c603dc9..191e0ac40e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "TEST-CONTROLLER-NAME", "action": "Lock", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json index 040c680d1c..724f096a4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "APPC", "action": "ConfigModify", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json new file mode 100644 index 0000000000..ac047a9638 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json @@ -0,0 +1,40 @@ +{ + "automated-assignment": false, + "heat-stack-id": "zauk53avetd02_base/5c7a8a55-edb8-458e-a7dc-2dbbc696682e", + "is-base-vf-module": true, + "model-customization-id": "521d5f9b-0b76-49d3-879e-fce8767f34eb", + "model-invariant-id": "f0ac6f78-543f-41ac-81c3-672a4d47001c", + "model-version-id": "215ea5bd-f0e0-4560-9f64-9a9716ff6178", + "module-index": 0, + "orchestration-status": "Active", + "relationship-list": { + "relationship": [ + { + "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02svm001", + "related-to": "vnfc", + "relationship-data": [ + { + "relationship-key": "vnfc.vnfc-name", + "relationship-value": "zauk53avetd02svm001" + } + ], + "relationship-label": "org.onap.relationships.inventory.Uses" + }, + { + "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02tvm001", + "related-to": "vnfc", + "relationship-data": [ + { + "relationship-key": "vnfc.vnfc-name", + "relationship-value": "zauk53avetd02tvm001" + } + ], + "relationship-label": "org.onap.relationships.inventory.Uses" + } + ] + }, + "resource-version": "1595304004908", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/16b9c65d-70c7-47f0-aa03-7cdb8dfb76be/service-data/vnfs/vnf/9cf22c37-4f39-4fa5-a942-b72efc8f6450/vnf-data/vf-modules/vf-module/2cf0ecd4-737c-4a46-9097-adc2f0088483/vf-module-data/vf-module-topology/", + "vf-module-id": "2cf0ecd4-737c-4a46-9097-adc2f0088483", + "vf-module-name": "zauk53avetd02_base" +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json deleted file mode 100644 index 2c46b5a8cb..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000004", - "operation-type": "lport_mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - }, - { - "key": "interface-id", - "value": "test-interface-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json deleted file mode 100644 index bf168b0028..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000003", - "operation-type": "lport_mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - }, - { - "key": "interface-id", - "value": "test-interface-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json deleted file mode 100644 index 89e505e7d0..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000004", - "operation-type": "mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json deleted file mode 100644 index 86897c8a1f..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000003", - "operation-type": "mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json deleted file mode 100644 index 8cf0a820cd..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "body": { - "output": { - "response-hd-custom": { - "response-status": "Failure", - "cached-data": "false", - "response-interface-type": "ansible", - "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", - "remote_end_time": "2017-10-13T14:51:53.490+0000", - "response-client-name": "MSO", - "user_id": "xxxxxx", - "remote_start_time": "2017-10-13T14:51:53.173+0000", - "error-message": "my error message", - "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" - } - } - }, - "result-info": { - "code": "200", - "status": "SUCCESS", - "request-id": "xyz123", - "client-name": "MSO", - "processing-host": "sdno-sdno-mtsnjv9sdno01" - } -}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json deleted file mode 100644 index a6794327d8..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "output": { - "response-healthdiagnostic": { - "response-node-ip": "192.20.127.76", - "response-id": "xyz123", - "response-node-name": "mtvnjv9aads11", - "response-status": "Success", - "response-interface-type": "ssh", - "response-details-json": "result", - "cached-data": "false" - } - } - }, - "result-info": { - "client-name": "MSO", - "code": "200", - "processing-host": "sdno1-host01", - "request-id": "xyz123", - "status": "SUCCESS" - } -}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json deleted file mode 100644 index 2355e86938..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - - "result-info": { - - "client-name": "MSO", - - "code": "202", - - "processing-host": "sdno1-host01", - - "request-id": "xyz123", - - "status": "ACCEPTED" - - } - -}
\ No newline at end of file |