diff options
33 files changed, 696 insertions, 104 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java new file mode 100644 index 0000000000..86be9ec3d8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java @@ -0,0 +1,36 @@ +package org.onap.so.openstack.beans; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CreateStackRequest { + + @JsonProperty("parameters") + private Map<String, Object> parameters; + + @JsonProperty("environment") + private String environment; + + public Map<String, Object> getParameters() { + return parameters; + } + + public void setParameters(Map<String, Object> parameters) { + this.parameters = parameters; + } + + public String getEnvironment() { + return environment; + } + + public void setEnvironment(String environment) { + this.environment = environment; + } + + @Override + public String toString() { + return "CreateStackRequest [parameters=" + parameters + ", environment=" + environment + "]"; + } + + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 28d4f3f9b4..1d75892138 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -55,6 +55,7 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; +import org.onap.so.openstack.beans.CreateStackRequest; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; @@ -354,7 +355,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { try { ObjectMapper mapper = new ObjectMapper(); InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId); - String stackRequest = mapper.writeValueAsString(request.getParameters()); + CreateStackRequest createStackRequest = new CreateStackRequest(); + createStackRequest.setEnvironment(request.getEnvironment()); + createStackRequest.setParameters(request.getParameters()); + String stackRequest = mapper.writeValueAsString(createStackRequest); CloudApiRequests cloudReq = new CloudApiRequests(); cloudReq.setCloudIdentifier(stackName); cloudReq.setRequestBody(stackRequest); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 687b7d8d2f..e840d5affd 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -48,10 +48,12 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.db.request.beans.CloudApiRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.openstack.beans.CreateStackRequest; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoOpenstackException; import org.onap.so.openstack.exceptions.MsoStackAlreadyExists; import org.springframework.core.env.Environment; +import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.base.client.OpenStackResponseException; import com.woorea.openstack.heat.Heat; import com.woorea.openstack.heat.StackResource; @@ -415,11 +417,22 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { @Test public final void saveStack_Test() throws MsoException, IOException, NovaClientException { + CreateStackParam createStackParam = new CreateStackParam(); createStackParam.setStackName("stackName"); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("test", "value"); + String environment = + "parameters:\n mmn_volume_name_1: \"data-mn-v-vdb\"\n mmn_volume_name_2: \"arch-mn-v-vdc\"\n"; createStackParam.setParameters(parameters); + createStackParam.setEnvironment(environment); + + CreateStackRequest createStackRequest = new CreateStackRequest(); + createStackRequest.setEnvironment(environment); + createStackRequest.setParameters(parameters); + ObjectMapper mapper = new ObjectMapper(); + String stackRequest = mapper.writeValueAsString(createStackRequest); + InfraActiveRequests request = new InfraActiveRequests(); request.setRequestId("requestId"); doReturn(request).when(requestDbClient).getInfraActiveRequestbyRequestId("requestId"); @@ -427,7 +440,8 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { heatUtils.saveStackRequest(createStackParam, "requestId", "stackName"); Mockito.verify(requestDbClient, times(1)).updateInfraActiveRequests(request); assertNotNull(request.getCloudApiRequests().get(0)); - assertEquals(request.getCloudApiRequests().get(0).getRequestId(), "requestId"); + assertEquals("requestId", request.getCloudApiRequests().get(0).getRequestId()); + assertEquals(stackRequest, request.getCloudApiRequests().get(0).getRequestBody()); } @Test diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml index bcf5429789..1487cb21b2 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml +++ b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml @@ -41,6 +41,8 @@ spring: jackson: serialization: fail-on-empty-beans: false + main: + allow-bean-definition-overriding: true #Actuator management: diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java index 34177ff5a3..3c073af6ba 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java @@ -48,10 +48,10 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; -import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import org.onap.so.client.RestTemplateConfig; +import javax.inject.Provider; @Component public class ValetClient { @@ -75,6 +75,9 @@ public class ValetClient { private static final String BODY = ", body="; @Autowired private ObjectMapper mapper; + @Autowired + private Provider<RestTemplate> templateProvider; + protected String baseUrl; protected String basePath; @@ -123,10 +126,7 @@ public class ValetClient { } private RestTemplate getRestTemplate() { - RestTemplate restTemplate = new RestTemplate(); - restTemplate - .setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); - return restTemplate; + return templateProvider.get(); } /* diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index 1c4de2daa1..ba31daaeaf 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -33,6 +33,8 @@ spring: ddl-auto: none naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy enable-lazy-load-no-trans: true + main: + allow-bean-definition-overriding: true org: onap: so: diff --git a/adapters/mso-requests-db-adapter/src/main/resources/application.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application.yaml index 7234733b95..17b014b993 100644 --- a/adapters/mso-requests-db-adapter/src/main/resources/application.yaml +++ b/adapters/mso-requests-db-adapter/src/main/resources/application.yaml @@ -47,6 +47,8 @@ spring: username: mso_admin password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' role: ACTUATOR + main: + allow-bean-definition-overriding: true #Actuator management: diff --git a/adapters/mso-sdnc-adapter/src/main/resources/application.yaml b/adapters/mso-sdnc-adapter/src/main/resources/application.yaml index 9be0a257c9..2ef721fca5 100644 --- a/adapters/mso-sdnc-adapter/src/main/resources/application.yaml +++ b/adapters/mso-sdnc-adapter/src/main/resources/application.yaml @@ -11,6 +11,10 @@ mso: max-pool-size: 50 queue-capacity: 500 +spring: + main: + allow-bean-definition-overriding: true + #Actuator management: endpoints: diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java index 3342e0d054..ab631837db 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -63,9 +63,9 @@ public class VnfmServiceProviderConfiguration { private static final Logger logger = LoggerFactory.getLogger(VnfmServiceProviderConfiguration.class); - @Value("${http.client.ssl.trust-store}") + @Value("${http.client.ssl.trust-store:#{null}}") private Resource keyStore; - @Value("${http.client.ssl.trust-store-password}") + @Value("${http.client.ssl.trust-store-password:#{null}}") private String keyStorePassword; @Bean(name = "vnfmServiceProvider") @@ -77,7 +77,9 @@ public class VnfmServiceProviderConfiguration { private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate, final HttpHeadersProvider httpHeadersProvider) { setGsonMessageConverter(restTemplate); - setTrustStore(restTemplate); + if (keyStore != null) { + setTrustStore(restTemplate); + } removeSpringClientFilter(restTemplate); return new HttpRestServiceProviderImpl(restTemplate, httpHeadersProvider); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml index 0bd63dffa9..4434d2edd9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml @@ -34,6 +34,11 @@ server: port: 9092 tomcat: max-threads: 50 + ssl: + key-alias: so@so.onap.org + key--store-password: 'ywsqCy:EEo#j}HJHM7z^Rk[L' + key-store: classpath:so-vnfm-adapter.p12 + key-store-type: PKCS12 mso: key: 07a7159d3bf51a0e53be7a8f89699be7 @@ -50,7 +55,7 @@ sdc: endpoint: http://sdc.onap/1234A vnfmadapter: - endpoint: http://so-vnfm-adapter.onap:9092 + endpoint: https://so-vnfm-adapter.onap:9092 #Actuator management: diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/so-vnfm-adapter.p12 b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/so-vnfm-adapter.p12 Binary files differnew file mode 100644 index 0000000000..ae4fddc684 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/so-vnfm-adapter.p12 diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml index 3afc542a1b..8cf8b51b9f 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml @@ -38,3 +38,17 @@ sdc: vnfmadapter: endpoint: https://so-vnfm-adapter.onap:30406 + +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use. diff --git a/asdc-controller/src/main/resources/application.yaml b/asdc-controller/src/main/resources/application.yaml index beb40e5e65..2de5b6914f 100644 --- a/asdc-controller/src/main/resources/application.yaml +++ b/asdc-controller/src/main/resources/application.yaml @@ -18,6 +18,8 @@ spring: ddl-auto: validate naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy enable-lazy-load-no-trans: true + main: + allow-bean-definition-overriding: true request: datasource: diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index f8d5402260..dcb9e08d0b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Configuration; +import org.onap.aai.domain.yang.Configurations; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.InstanceGroup; @@ -50,6 +51,7 @@ import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFou import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; @@ -575,4 +577,53 @@ public class BBInputSetupUtils { } return Optional.empty(); } + + public ServiceInstances getAAIServiceInstancesGloballyByName(String serviceInstanceName) { + + return injectionHelper.getAaiClient() + .get(ServiceInstances.class, AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + .queryParam("service-instance-name", serviceInstanceName)) + .orElseGet(() -> { + logger.debug("No Service Instance matched by name"); + return null; + }); + } + + public boolean existsAAINetworksGloballyByName(String networkName) { + + AAIResourceUri l3networkUri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); + return aaiRC.exists(l3networkUri); + } + + public GenericVnfs getAAIVnfsGloballyByName(String vnfName) { + + return injectionHelper.getAaiClient() + .get(GenericVnfs.class, + AAIUriFactory.createNodesUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)) + .orElseGet(() -> { + logger.debug("No GenericVnfs matched by name"); + return null; + }); + } + + public Optional<Configuration> getRelatedConfigurationByNameFromServiceInstance(String serviceInstanceId, + String configurationName) throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + uri.relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName); + Optional<Configurations> configurations = injectionHelper.getAaiClient().get(Configurations.class, uri); + Configuration configuration = null; + if (!configurations.isPresent()) { + logger.debug("No Configurations matched by name"); + return Optional.empty(); + } else { + if (configurations.get().getConfiguration().size() > 1) { + throw new Exception("Multiple Configurations Returned"); + } else { + configuration = configurations.get().getConfiguration().get(0); + } + return Optional.of(configuration); + } + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index 189947595a..7780837714 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -47,6 +47,7 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Configuration; +import org.onap.aai.domain.yang.Configurations; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.L3Network; @@ -865,4 +866,16 @@ public class BBInputSetupUtilsTest { assertEquals(expectedFlowsToExecute.size(), flowsToExecute.size()); } + @Test + public void getRelatedConfigurationByNameFromServiceInstanceTest() throws Exception { + Optional<Configurations> expected = Optional.of(new Configurations()); + Configuration configuration = new Configuration(); + configuration.setConfigurationId("id123"); + expected.get().getConfiguration().add(configuration); + doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(Configurations.class), any(AAIResourceUri.class)); + Optional<Configuration> actual = + this.bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123"); + assertEquals(actual.get().getConfigurationId(), expected.get().getConfiguration().get(0).getConfigurationId()); + } + } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml index 185db168fe..1ad95b3ab9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml @@ -19,6 +19,8 @@ spring: enabled: false jersey: application-path: /sobpmnengine + main: + allow-bean-definition-overriding: true camunda: bpm: application: diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn index fb9704d294..884ec209aa 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn @@ -22,11 +22,11 @@ </bpmn2:userTask> <bpmn2:sequenceFlow id="SequenceFlow_0b84ki5" sourceRef="UpdateDbStatusToPendingManualTask" targetRef="CreateExternalTicket" /> <bpmn2:sequenceFlow id="SequenceFlow_14cyk9v" sourceRef="UpdateDbStatusToInProgress" targetRef="PauseForManualTaskActivity_End" /> - <bpmn2:serviceTask id="UpdateDbStatusToPendingManualTask" name="Update Infra DB Status to PENDING_MANUAL_TASK" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(execution,"PENDING_MANUAL_TASK")}"> + <bpmn2:serviceTask id="UpdateDbStatusToPendingManualTask" name="Update Infra DB Status to PENDING_MANUAL_TASK" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"PENDING_MANUAL_TASK")}"> <bpmn2:incoming>SequenceFlow_0jav6cu</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0b84ki5</bpmn2:outgoing> </bpmn2:serviceTask> - <bpmn2:serviceTask id="UpdateDbStatusToInProgress" name="Update Infra DB Status to IN_PROGRESS" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(execution, "IN_PROGRESS")}"> + <bpmn2:serviceTask id="UpdateDbStatusToInProgress" name="Update Infra DB Status to IN_PROGRESS" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), "IN_PROGRESS")}"> <bpmn2:incoming>SequenceFlow_192yimz</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_14cyk9v</bpmn2:outgoing> </bpmn2:serviceTask> @@ -37,12 +37,12 @@ <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression"><![CDATA[${execution.getVariable("taskTimeout")}]]></bpmn2:timeDuration> </bpmn2:timerEventDefinition> </bpmn2:boundaryEvent> - <bpmn2:serviceTask id="CreateExternalTicket" name="Create ExternalTicket" camunda:expression="${ManualHandlingTasks.createExternalTicket(execution)}"> + <bpmn2:serviceTask id="CreateExternalTicket" name="Create ExternalTicket" camunda:expression="${ManualHandlingTasks.createExternalTicket(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn2:incoming>SequenceFlow_0b84ki5</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0igra4l</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="SequenceFlow_01k6zgt" sourceRef="ManualTaskTimer" targetRef="UpdateDBStatusToTimeout" /> - <bpmn2:serviceTask id="UpdateDBStatusToTimeout" name="Update Infra DB Status To TIMEOUT" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(execution, "TIMEOUT")}"> + <bpmn2:serviceTask id="UpdateDBStatusToTimeout" name="Update Infra DB Status To TIMEOUT" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), "TIMEOUT")}"> <bpmn2:incoming>SequenceFlow_01k6zgt</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_16bjdgj</bpmn2:outgoing> </bpmn2:serviceTask> @@ -147,4 +147,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn2:definitions> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java index 484f9b8506..c0b0094f20 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java @@ -35,6 +35,7 @@ import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.onap.so.bpmn.BaseBPMNTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; public class PauseForManualTaskActivityTest extends BaseBPMNTest { @@ -85,7 +86,7 @@ public class PauseForManualTaskActivityTest extends BaseBPMNTest { @Test public void rainyDayPauseForManualTask_Test() throws Exception { doThrow(new BpmnError("7000", "TESTING ERRORS")).when(manualHandlingTasks) - .createExternalTicket((any(DelegateExecution.class))); + .createExternalTicket((any(BuildingBlockExecution.class))); ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskActivity", variables); assertThat(pi).isNotNull().isStarted() .hasPassedInOrder("PauseForManualTaskActivity_Start", "UpdateDbStatusToPendingManualTask", diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 95be6ba7fc..1516f289fe 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -89,6 +89,14 @@ public class ServicePluginFactory { private static ServicePluginFactory instance; + private static final String CUSTOM_RESOURCE_TP = "custom-resource-tp"; + private static final String VS_MONITORED = "VS_assured"; + private static final String VS_UNMONITORED = "VS_besteffort"; + private static final String TS_MONITORED = "TS1"; + private static final String TS_UNMONITORED = "TS2"; + private static final String CUSTOM_TP_LIST[] = + new String[] {VS_MONITORED, VS_UNMONITORED, TS_MONITORED, TS_UNMONITORED}; + static { try (InputStream is = ClassLoader.class.getResourceAsStream("/application.properties")) { Properties prop = new Properties(); @@ -351,13 +359,6 @@ public class ServicePluginFactory { return false; } - public static String CUSTOM_RESOURCE_TP = "custom-resource-tp"; - public static String VS_MONITORED = "VS_assured"; - public static String VS_UNMONITORED = "VS_besteffort"; - public static String TS_MONITORED = "TS1"; - public static String TS_UNMONITORED = "TS2"; - public static String CUSTOM_TP_LIST[] = new String[] {VS_MONITORED, VS_UNMONITORED, TS_MONITORED, TS_UNMONITORED}; - private void customizeTP(Map<String, Object> crossTps, String svcName, DelegateExecution execution) { Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst(); if (customType.isPresent()) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 775e3213d4..638ecefa49 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.activity; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -99,6 +100,12 @@ public class ExecuteActivity implements JavaDelegate { variables.put("retryCount", 1); variables.put("aLaCarte", true); + execution.getVariables().forEach((key, value) -> { + if (value instanceof Serializable) { + variables.put(key, (Serializable) value); + } + }); + ProcessInstanceWithVariables buildingBlockResult = runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables) .executeWithVariablesInReturn(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java index 4cf5131747..c112d200e3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java @@ -45,7 +45,7 @@ public class Constants { public static final String UNDERSCORE = "_"; public static final String SPACE = "\\s+"; - public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/"; + public static final String VNFM_ADAPTER_DEFAULT_URL = "https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/"; public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk"; public static final String FORWARD_SLASH = "/"; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java index 17089be571..7e45c3b640 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java @@ -27,6 +27,7 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateTask; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.ticket.ExternalTicket; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -46,7 +47,7 @@ public class ManualHandlingTasks { private static final String TASK_TYPE_FALLOUT = "fallout"; public static final String VNF_TYPE = "vnfType"; public static final String SERVICE_TYPE = "serviceType"; - public static final String MSO_REQUEST_ID = "msoRequestId"; + public static final String MSO_REQUEST_ID = "mso-request-id"; public static final String REQUESTOR_ID = "requestorId"; public static final String ERROR_CODE = "errorCode"; public static final String VALID_RESPONSES = "validResponses"; @@ -120,7 +121,7 @@ public class ManualHandlingTasks { String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID); String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID); String description = (String) execution.getVariable(DESCRIPTION); - String timeout = (String) execution.getVariable("taskTimeout"); + String timeout = ""; String errorSource = ""; String errorCode = ""; String errorMessage = ""; @@ -188,7 +189,7 @@ public class ManualHandlingTasks { } - public void createExternalTicket(DelegateExecution execution) { + public void createExternalTicket(BuildingBlockExecution execution) { try { ExternalTicket ticket = new ExternalTicket(); @@ -218,7 +219,7 @@ public class ManualHandlingTasks { } - public void updateRequestDbStatus(DelegateExecution execution, String status) { + public void updateRequestDbStatus(BuildingBlockExecution execution, String status) { try { String requestId = (String) execution.getVariable(MSO_REQUEST_ID); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 89030d52dc..78cb533c9e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -36,9 +36,11 @@ import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; @@ -51,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -112,6 +115,14 @@ public class WorkflowAction { private static final String SERVICE_TYPE_BONDING = "BONDING"; private static final String CLOUD_OWNER = "DEFAULT"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); + private static final String NAME_EXISTS_WITH_DIFF_VERSION_ID = "(%s) and different version id (%s)"; + private static final String NAME_EXISTS_MULTIPLE = + "(%s) and multiple combination of model-version-id + service-type + global-customer-id"; + private static final String NAME_EXISTS_WITH_DIFF_COMBINATION = + "(%s) and global-customer-id (%s), service-type (%s), model-version-id (%s)"; + private static final String NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID = + "(%s), same parent and different customization id (%s)"; + private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship"; @Autowired protected BBInputSetup bbInputSetup; @@ -149,6 +160,7 @@ public class WorkflowAction { String uri = (String) execution.getVariable(BBConstants.G_URI); final String vnfType = (String) execution.getVariable(VNF_TYPE); String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); + final String createInstanceAction = "createInstance"; final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); @@ -189,7 +201,8 @@ public class WorkflowAction { WorkflowType resourceType = resource.getResourceType(); execution.setVariable("resourceName", resourceType.toString()); String resourceId = ""; - if (resource.isGenerated()) { + if (resource.isGenerated() && requestAction.equalsIgnoreCase(createInstanceAction) + && sIRequest.getRequestDetails().getRequestInfo().getInstanceName() != null) { resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType, sIRequest.getRequestDetails().getRequestInfo().getInstanceName(), sIRequest.getRequestDetails(), workflowResourceIds); @@ -1134,55 +1147,146 @@ public class WorkflowAction { RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception { try { if ("SERVICE".equalsIgnoreCase(type.toString())) { + // Service name verification based upon name + model-version-id + // + service-type + global-customer-id per requirements String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId(); String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType(); if (instanceName != null) { Optional<ServiceInstance> serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName); if (serviceInstanceAAI.isPresent()) { - return serviceInstanceAAI.get().getServiceInstanceId(); + if (serviceInstanceAAI.get().getModelVersionId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) { + return serviceInstanceAAI.get().getServiceInstanceId(); + } else { + throw new DuplicateNameException("serviceInstance", + String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID, instanceName, + reqDetails.getModelInfo().getModelVersionId())); + } + } else { + ServiceInstances aaiServiceInstances = + bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName); + if (aaiServiceInstances != null) { + if (aaiServiceInstances.getServiceInstance() != null + && !aaiServiceInstances.getServiceInstance().isEmpty()) { + if (aaiServiceInstances.getServiceInstance().size() > 1) { + throw new DuplicateNameException("serviceInstance", + String.format(NAME_EXISTS_MULTIPLE, instanceName)); + } else { + ServiceInstance si = + aaiServiceInstances.getServiceInstance().stream().findFirst().get(); + Map<String, String> keys = + bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId()); + + throw new DuplicateNameException("serviceInstance", + String.format(NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, + keys.get("global-customer-id"), keys.get("service-type"), + si.getModelVersionId())); + } + } + } } } } else if ("NETWORK".equalsIgnoreCase(type.toString())) { Optional<L3Network> network = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance( workflowResourceIds.getServiceInstanceId(), instanceName); if (network.isPresent()) { - return network.get().getNetworkId(); + if (network.get().getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return network.get().getNetworkId(); + } else { + throw new DuplicateNameException("l3Network", + String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, + network.get().getModelCustomizationId())); + } + } + + if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) { + throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, + instanceName, workflowResourceIds.getServiceInstanceId())); } + } else if ("VNF".equalsIgnoreCase(type.toString())) { Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance( workflowResourceIds.getServiceInstanceId(), instanceName); if (vnf.isPresent()) { - return vnf.get().getVnfId(); + if (vnf.get().getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return vnf.get().getVnfId(); + } else { + throw new DuplicateNameException("generic-vnf", + String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, + vnf.get().getModelCustomizationId())); + } + } + GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName); + if (vnfs != null) { + throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_PARENT, + instanceName, vnfs.getGenericVnf().get(0).getVnfId())); } } else if ("VFMODULE".equalsIgnoreCase(type.toString())) { GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId()); if (vnf != null && vnf.getVfModules() != null) { for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) { if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) { - return vfModule.getVfModuleId(); + if (vfModule.getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return vfModule.getVfModuleId(); + } else { + throw new DuplicateNameException("vfModule", + String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, + reqDetails.getModelInfo().getModelCustomizationId())); + } } } } } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) { + GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId()); Optional<VolumeGroup> volumeGroup = bbInputSetupUtils .getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName); if (volumeGroup.isPresent()) { - return volumeGroup.get().getVolumeGroupId(); + if (vnf.getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return volumeGroup.get().getVolumeGroupId(); + } else { + throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName()); + } } - GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId()); if (vnf != null && vnf.getVfModules() != null) { for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) { Optional<VolumeGroup> volumeGroupFromVfModule = bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnf.getVnfId(), vfModule.getVfModuleId(), instanceName); if (volumeGroupFromVfModule.isPresent()) { - return volumeGroupFromVfModule.get().getVolumeGroupId(); + if (vnf.getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return volumeGroupFromVfModule.get().getVolumeGroupId(); + } else { + throw new DuplicateNameException("volumeGroup", + String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, + volumeGroupFromVfModule.get().getModelCustomizationId())); + } } } } + } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) { + Optional<org.onap.aai.domain.yang.Configuration> configuration = + bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance( + workflowResourceIds.getServiceInstanceId(), instanceName); + if (configuration.isPresent()) { + if (configuration.get().getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return configuration.get().getConfigurationId(); + } else { + throw new DuplicateNameException("configuration", + String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, + configuration.get().getConfigurationId())); + } + } } return generatedResourceId; + } catch (DuplicateNameException dne) { + throw dne; } catch (Exception ex) { logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex); throw new IllegalStateException( diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java index 376a27e830..4cde9c1fc8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; import java.util.Collections; import java.util.List; +import java.util.Optional; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener; @@ -55,7 +56,7 @@ public class MultiStageSkipListener implements FlowManipulator, PostCompletionRe @Override public boolean shouldRunFor(BuildingBlockExecution execution) { - return (boolean) execution.getVariable(G_MULTI_STAGE_DESIGN); + return (boolean) Optional.ofNullable(execution.getVariable(G_MULTI_STAGE_DESIGN)).orElse(false); } @Override diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java index 9677f8e8f3..b40195c07b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java @@ -38,6 +38,8 @@ import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.db.request.beans.InfraActiveRequests; public class ManualHandlingTasksTest extends BaseTaskTest { @@ -56,11 +58,13 @@ public class ManualHandlingTasksTest extends BaseTaskTest { @Mock private DelegateTask task; - private DelegateExecution delegateExecution; + @Mock + private BuildingBlockExecution buildingBlockExecution; @Before public void before() throws Exception { delegateExecution = new DelegateExecutionFake(); + buildingBlockExecution = new DelegateExecutionImpl(delegateExecution); } @Test @@ -99,18 +103,18 @@ public class ManualHandlingTasksTest extends BaseTaskTest { @Test public void updateRequestDbStatus_Test() throws Exception { InfraActiveRequests mockedRequest = new InfraActiveRequests(); - delegateExecution.setVariable("msoRequestId", "testMsoRequestId"); + buildingBlockExecution.setVariable("mso-request-id", "msoRequestId"); when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); - manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS"); + manualHandlingTasks.updateRequestDbStatus(buildingBlockExecution, "IN_PROGRESS"); verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS"); } @Test public void createExternalTicket_Test() throws Exception { - delegateExecution.setVariable("msoRequestId", ("testMsoRequestId")); - delegateExecution.setVariable("vnfType", "testVnfType"); - manualHandlingTasks.createExternalTicket(delegateExecution); + buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId")); + buildingBlockExecution.setVariable("vnfType", "testVnfType"); + manualHandlingTasks.createExternalTicket(buildingBlockExecution); } } 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 918a474b8a..eea885288e 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 @@ -44,8 +44,10 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -62,10 +64,13 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.L3Networks; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.VolumeGroup; @@ -76,6 +81,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; @@ -99,6 +105,7 @@ import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; +import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -114,7 +121,6 @@ public class WorkflowActionTest extends BaseTaskTest { protected WorkflowAction workflowAction; private DelegateExecution execution; - @InjectMocks @Spy protected WorkflowAction SPY_workflowAction; @@ -1494,104 +1500,368 @@ public class WorkflowActionTest extends BaseTaskTest { assertNull(x.getVolumeGroupId()); } - @Test - public void validateResourceIdInAAITest() throws Exception { - // SI + private RequestDetails setupRequestDetails(String globalSubscriberId, String subscriptionServiceType, + String modelCustomizationId) { RequestDetails reqDetails = new RequestDetails(); SubscriberInfo subInfo = new SubscriberInfo(); - subInfo.setGlobalSubscriberId("id123"); + subInfo.setGlobalSubscriberId(globalSubscriberId); reqDetails.setSubscriberInfo(subInfo); RequestParameters reqParams = new RequestParameters(); - reqParams.setSubscriptionServiceType("subServiceType123"); + reqParams.setSubscriptionServiceType(subscriptionServiceType); reqDetails.setRequestParameters(reqParams); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(modelCustomizationId); + reqDetails.setModelInfo(modelInfo); + return reqDetails; + } + + @Test + public void validateVnfResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); - ServiceInstance si = new ServiceInstance(); - si.setServiceInstanceId("siId123"); - Optional<ServiceInstance> siOp = Optional.of(si); - when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp); - when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111")) - .thenReturn(Optional.empty()); - String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", - reqDetails, workflowResourceIds); - assertEquals("siId123", id); - String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111", - reqDetails, workflowResourceIds); + workflowResourceIds.setServiceInstanceId("siId123"); + // Vnf + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + vnf.setModelCustomizationId("1234567"); + Optional<GenericVnf> opVnf = Optional.of(vnf); + GenericVnf vnf2 = new GenericVnf(); + vnf2.setVnfId("id123"); + vnf2.setVnfName("vnfName222"); + vnf2.setModelCustomizationId("222"); + Optional<GenericVnf> opVnf2 = Optional.of(vnf2); + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf); + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName222")).thenReturn(opVnf2); + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty()); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName123", reqDetails, + workflowResourceIds); + assertEquals("id123", id); + String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails, + workflowResourceIds); assertEquals("generatedId123", id2); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "generic-vnf with name (vnfName222), same parent and different customization id (222) already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName222", reqDetails, + workflowResourceIds); + } + + @Test + public void validateVnfResourceNameInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + // Vnf + GenericVnfs genericVnfs = new GenericVnfs(); + GenericVnf vnf3 = new GenericVnf(); + vnf3.setVnfId("id123"); + vnf3.setVnfName("vnfName333"); + genericVnfs.getGenericVnf().add(vnf3); + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName333")).thenReturn(Optional.empty()); + when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName333")).thenReturn(genericVnfs); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "generic-vnf with name (vnfName333) id (id123) and different parent relationship already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName333", reqDetails, + workflowResourceIds); + } + + @Test + public void validateNetworkResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + // Network L3Network network = new L3Network(); network.setNetworkId("id123"); network.setNetworkName("name123"); + network.setModelCustomizationId("1234567"); workflowResourceIds.setServiceInstanceId("siId123"); Optional<L3Network> opNetwork = Optional.of(network); + L3Network network2 = new L3Network(); + network2.setNetworkId("id123"); + network2.setNetworkName("networkName222"); + network2.setModelCustomizationId("222"); + Optional<L3Network> opNetwork2 = Optional.of(network2); when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork); + when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222")) + .thenReturn(opNetwork2); when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty()); - id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails, - workflowResourceIds); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", + reqDetails, workflowResourceIds); assertEquals("id123", id); - id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails, - workflowResourceIds); + String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", + reqDetails, workflowResourceIds); assertEquals("generatedId123", id2); - // Vnf + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails, + workflowResourceIds); + } + + @Test + public void validateNetworkResourceNameExistsInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + // Network + L3Network network = new L3Network(); + network.setNetworkId("id123"); + network.setNetworkName("name123"); + network.setModelCustomizationId("1234567"); + workflowResourceIds.setServiceInstanceId("siId123"); + + when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("networkName333", "111111")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAINetworksGloballyByName("networkName333")).thenReturn(true); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "l3Network with name (networkName333) id (siId123) and different parent relationship already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName333", reqDetails, + workflowResourceIds); + } + + @Test + public void validateVfModuleResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + GenericVnf vnf = new GenericVnf(); vnf.setVnfId("id123"); vnf.setVnfName("vnfName123"); - Optional<GenericVnf> opVnf = Optional.of(vnf); - when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "name123")).thenReturn(opVnf); - when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty()); - id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "name123", reqDetails, - workflowResourceIds); - assertEquals("id123", id); - id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails, - workflowResourceIds); - assertEquals("generatedId123", id2); + vnf.setModelCustomizationId("222"); // VfModule VfModules vfModules = new VfModules(); VfModule vfModule = new VfModule(); vfModule.setVfModuleId("id123"); vfModule.setVfModuleName("name123"); + vfModule.setModelCustomizationId("1234567"); vfModules.getVfModule().add(vfModule); vnf.setVfModules(vfModules); workflowResourceIds.setVnfId("id123"); when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf); - id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails, - workflowResourceIds); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", + reqDetails, workflowResourceIds); assertEquals("id123", id); - GenericVnf vnf2 = new GenericVnf(); + GenericVnf vnf1 = new GenericVnf(); VfModules vfModules2 = new VfModules(); VfModule vfModule2 = new VfModule(); vfModule2.setVfModuleId("id123"); - vfModule2.setVfModuleName("name123"); + vfModule2.setVfModuleName("vFModName222"); + vfModule2.setModelCustomizationId("222"); vfModules2.getVfModule().add(vfModule2); - vnf2.setVfModules(vfModules2); + vnf1.setVfModules(vfModules2); workflowResourceIds.setVnfId("id111"); - when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf2); - id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails, - workflowResourceIds); + when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1); + String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", + reqDetails, workflowResourceIds); assertEquals("generatedId123", id2); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails, + workflowResourceIds); + + } + + @Test + public void validateVolumeGroupResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + vnf.setModelCustomizationId("1234567"); + + GenericVnf vnf2 = new GenericVnf(); + vnf2.setVnfId("id123"); + vnf2.setVnfName("vnfName123"); + vnf2.setModelCustomizationId("222"); + // VolumeGroup VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("id123"); volumeGroup.setVolumeGroupName("name123"); workflowResourceIds.setVnfId("id123"); Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup); + + workflowResourceIds.setVnfId("id123"); + + when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf); when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup); - id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails, - workflowResourceIds); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", + reqDetails, workflowResourceIds); assertEquals("id123", id); - workflowResourceIds.setVnfId("id444"); - when(bbSetupUtils.getAAIGenericVnf("id444")).thenReturn(vnf); + when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf2); when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "111111")) .thenReturn(opVolumeGroup); - when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id444", "111111")).thenReturn(Optional.empty()); - id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", reqDetails, + + when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "111111")).thenReturn(Optional.empty()); + String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", + reqDetails, workflowResourceIds); + assertEquals("generatedId123", id2); + } + + @Test + public void validateConfigurationResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + // Configuration + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("id123"); + configuration.setConfigurationName("name123"); + configuration.setModelCustomizationId("1234567"); + Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration); + + org.onap.aai.domain.yang.Configuration configuration2 = new org.onap.aai.domain.yang.Configuration(); + configuration2.setConfigurationId("id123"); + configuration2.setConfigurationName("name123"); + configuration2.setModelCustomizationId("222"); + Optional<org.onap.aai.domain.yang.Configuration> opConfiguration2 = Optional.of(configuration2); + + workflowResourceIds.setVnfId("id123"); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123")) + .thenReturn(opConfiguration); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name123", + reqDetails, workflowResourceIds); + assertEquals("id123", id); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "111111")) + .thenReturn(Optional.empty()); + String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "111111", + reqDetails, workflowResourceIds); + assertEquals("generatedId123", id2); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name222")) + .thenReturn(opConfiguration2); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "configuration with name (name222), same parent and different customization id (id123) already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name222", reqDetails, + workflowResourceIds); + } + + @Test + public void validateServiceInstanceResourceIdInAAITest() throws Exception { + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("1234567"); + ServiceInstances serviceInstances = new ServiceInstances(); + serviceInstances.getServiceInstance().add(si); + Optional<ServiceInstance> siOp = Optional.of(si); + ServiceInstance si2 = new ServiceInstance(); + si2.setServiceInstanceId("siId222"); + si2.setModelVersionId("22222"); + si2.setServiceInstanceName("siName222"); + Optional<ServiceInstance> siOp2 = Optional.of(si2); + ServiceInstances serviceInstances2 = new ServiceInstances(); + serviceInstances2.getServiceInstance().add(si2); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp); + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName222")).thenReturn(siOp2); + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111")) + .thenReturn(Optional.empty()); + + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", + reqDetails, workflowResourceIds); + assertEquals("siId123", id); + String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111", + reqDetails, workflowResourceIds); + assertEquals("generatedId123", id2); + + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName222")).thenReturn(serviceInstances2); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "serviceInstance with name (siName222) and different version id (1234567) already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName222", reqDetails, + workflowResourceIds); + } + + @Test + public void validateServiceInstanceResourceIdInAAIMultipleTest() throws Exception { + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("1234567"); + ServiceInstances serviceInstances = new ServiceInstances(); + serviceInstances.getServiceInstance().add(si); + + ServiceInstance si2 = new ServiceInstance(); + si2.setServiceInstanceId("siId222"); + si2.setModelVersionId("22222"); + si2.setServiceInstanceName("siName222"); + serviceInstances.getServiceInstance().add(si2); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123")) + .thenReturn(Optional.empty()); + + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "serviceInstance with name (siName123) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails, + workflowResourceIds); + } + + @Test + public void validateServiceInstanceResourceIdInAAIExistsTest() throws Exception { + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("1234567"); + ServiceInstances serviceInstances = new ServiceInstances(); + serviceInstances.getServiceInstance().add(si); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123")) + .thenReturn(Optional.empty()); + + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances); + + Map<String, String> uriKeys = new HashMap<>(); + uriKeys.put("global-customer-id", "globalCustomerId"); + uriKeys.put("service-type", "serviceType"); + + when(bbSetupUtils.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "serviceInstance with name (siName123) and global-customer-id (globalCustomerId), service-type (serviceType), model-version-id (1234567) already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails, workflowResourceIds); - assertEquals("id123", id2); } @Test 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 9e2eac416c..82d610fa97 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 @@ -77,6 +77,8 @@ public class MultiStageSkipListenerTest { execution.setVariable("multiStageDesign", false); assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution)); + execution.setVariable("multiStageDesign", null); + assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution)); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml index 93a4ae9489..babefd9478 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml @@ -49,6 +49,8 @@ spring: enable-lazy-load-no-trans: true jersey: type: filter + main: + allow-bean-definition-overriding: true request: datasource: diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 4b2644bc00..e28e36d307 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -2398,7 +2398,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals( - "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", + "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error", realResponse.getServiceException().getText()); } @@ -2443,7 +2443,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals( - "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error", + "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error", realResponse.getServiceException().getText()); } @@ -2460,7 +2460,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals( - "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", + "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error", realResponse.getServiceException().getText()); } @@ -2492,7 +2492,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals( - "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", + "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error", realResponse.getServiceException().getText()); } @@ -2512,7 +2512,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals( - "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", + "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error", realResponse.getServiceException().getText()); } @@ -2529,7 +2529,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals( - "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", + "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error", realResponse.getServiceException().getText()); } @@ -66,7 +66,7 @@ <siteNexusPath>content/sites/site/org/onap/so/${project.version}/</siteNexusPath> <cxf.version>3.2.6</cxf.version> <jax.ws.rs>2.1</jax.ws.rs> - <springboot.version>2.0.5.RELEASE</springboot.version> + <springboot.version>2.1.5.RELEASE</springboot.version> <camunda.springboot.version>3.2.0</camunda.springboot.version> <format.skipValidate>false</format.skipValidate> <format.skipExecute>true</format.skipExecute> @@ -847,18 +847,13 @@ <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> - <version>5.1.4</version> + <version>5.2.4</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20140107</version> </dependency> - <dependency> - <groupId>org.yaml</groupId> - <artifactId>snakeyaml</artifactId> - <version>1.19</version> - </dependency> </dependencies> </dependencyManagement> <profiles> diff --git a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml index 347845e422..417febebf6 100644 --- a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml +++ b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml @@ -17,6 +17,8 @@ mso: auth: Basic YnBlbDpwYXNzd29yZDEk spring: + main: + allow-bean-definition-overriding: true security: usercredentials: - diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java index 218cc2de03..83f079c376 100644 --- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java +++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java @@ -1,5 +1,7 @@ package org.onap.svnfm.simulator.services; +import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -34,10 +36,13 @@ import org.onap.svnfm.simulator.model.Vnfds; import org.onap.svnfm.simulator.repository.VnfOperationRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; public abstract class OperationProgressor implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(OperationProgressor.class); + private static final String CERTIFICATE_TO_TRUST = "so-vnfm-adapter.crt.pem"; + protected final VnfOperation operation; protected final SvnfmService svnfmService; private final VnfOperationRepository vnfOperationRepository; @@ -61,14 +66,25 @@ public abstract class OperationProgressor implements Runnable { String callBackUrl = subscriptionService.getSubscriptions().iterator().next().getCallbackUri(); callBackUrl = callBackUrl.substring(0, callBackUrl.indexOf("/lcn/")); apiClient.setBasePath(callBackUrl); + apiClient.setSslCaCert(getCertificateToTrust()); notificationClient = new DefaultApi(apiClient); final org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiClient grantApiClient = new org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiClient(); grantApiClient.setBasePath(callBackUrl); + grantApiClient.setSslCaCert(getCertificateToTrust()); grantClient = new org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api.DefaultApi(grantApiClient); } + private InputStream getCertificateToTrust() { + try { + return new ClassPathResource(CERTIFICATE_TO_TRUST).getInputStream(); + } catch (final IOException exception) { + LOGGER.error("Error reading certificate to trust, https calls to VNFM adapter will fail", exception); + return null; + } + } + @Override public void run() { try { @@ -176,6 +192,9 @@ public abstract class OperationProgressor implements Runnable { MediaType.APPLICATION_JSON, authHeader); } catch (final ApiException exception) { LOGGER.error("Error sending notification: " + notification, exception); + LOGGER.error("Response code: {}, body: {}, basePath: {}", exception.getCode(), exception.getResponseBody(), + notificationClient.getApiClient().getBasePath()); + } } diff --git a/vnfm-simulator/vnfm-service/src/main/resources/so-vnfm-adapter.crt.pem b/vnfm-simulator/vnfm-service/src/main/resources/so-vnfm-adapter.crt.pem new file mode 100644 index 0000000000..3c899e3bf5 --- /dev/null +++ b/vnfm-simulator/vnfm-service/src/main/resources/so-vnfm-adapter.crt.pem @@ -0,0 +1,30 @@ +Bag Attributes + friendlyName: so@so.onap.org + localKeyID: 54 69 6D 65 20 31 35 36 33 34 36 33 36 32 39 35 38 33 +subject=/CN=so-vnfm-adapter/emailAddress=/OU=so@so.onap.org/OU=OSAAF/O=ONAP/C=US +issuer=/C=US/O=ONAP/OU=OSAAF/CN=intermediateCA_9 +-----BEGIN CERTIFICATE----- +MIIEITCCAwmgAwIBAgIILuAnLLineoYwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE +BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp +bnRlcm1lZGlhdGVDQV85MB4XDTE5MDcxODE1MjcwOVoXDTIwMDcxODE1MjcwOVow +cDEYMBYGA1UEAwwPc28tdm5mbS1hZGFwdGVyMQ8wDQYJKoZIhvcNAQkBFgAxFzAV +BgNVBAsMDnNvQHNvLm9uYXAub3JnMQ4wDAYDVQQLDAVPU0FBRjENMAsGA1UECgwE +T05BUDELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCu2NbWjFiZ5Tz5P7daCD6mqJqSWV3f+gkM2VC/UYM/43hd/2ILJbbtsv4uzS/P +GXl3UIKBjb7zRiDCvLNMFsHCZ9/gIonG1z737S42LCrdVKq/KQ59yIOPrxYmLyiQ +Xy81ChX77b2KvKPPeF+K/wnh5fLwlcJ18geeCoWGaMK0C/i6J/uUb9z+Ef0Nmtau +NdXAuUnERCKMra+3kFxZwaRC/gSCy+/s6EQdeaGNiijg03AmrUx9XjrJjHbYMDVo +OKSxtv0E4fxbfmTpHaKCuN4eg+0nEXw/eiIEuSHJuh3KKv7wRoP/hG/Tdog7x60M +SD+hdNjCbFP6yAyMPfoxVnjHAgMBAAGjgecwgeQwCQYDVR0TBAIwADAOBgNVHQ8B +Af8EBAMCBeAwIAYDVR0lAQH/BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMFQGA1Ud +IwRNMEuAFIH3mVsQuciM3vNSXupOaaBDPqzdoTCkLjAsMQ4wDAYDVQQLDAVPU0FB +RjENMAsGA1UECgwET05BUDELMAkGA1UEBhMCVVOCAQcwHQYDVR0OBBYEFFLrO3T4 +QybeDQ28mHgC/xT5f03qMDAGA1UdEQQpMCeCD3NvLXZuZm0tYWRhcHRlcoIUc28t +dm5mbS1hZGFwdGVyLm9uYXAwDQYJKoZIhvcNAQELBQADggEBACe+JaVIjTku/QNp +XoQCNN+sllSZmEHTLmYfpSzY5BY2AeJsgTYqFtAhtp6uQf8Jr993CyEyeJ4if2Z9 +J5NWoJKmY1+a63UphB1mg4sNSCuDxvbxPjtrFkOx/DiB1XEUdoifS9IQSDIIuhaD +YP6sih1TBOh/2ityCe51Mu1J9/wgb24rlYouVtEyQeIai4dqngFHeQHeNXOnGN0z +osEcKSYa0C+ZOAomBMT58C2aDz9vyI8YPuzwVSDKndmXUgvrkkVnxk3qJRtghDQc +RV+4SeZg8s4+5DxKL4AL15IAaAPMJHi+MRtfm7qNzqCEl5sAEzO7S4oVHeWLNFV8 +a9PHErg= +-----END CERTIFICATE----- |