From 93e96836387ee26cb5f2dbb70adef7db484c7d54 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 19 Oct 2018 09:32:18 -0400 Subject: bug fixes october 19th Fixed issue with resource version being added twice. added silent success to orch validation when unassign is not found Removed SNAPSHOT from dependency Fixed failing BBInputSetup tests Updated apih tests to use networkInstanceGroup Updated ModelType enum and fixed compilation issues Change the place where the data for multistage gets set Update treatment of PENDING_ACTIVATION VF_MODULE CREATE entries to SILENT_SUCCESS to support first stage of multistage. Implement second stage of multistage design VF Module Creation Implementation of the first stage of multistage design for VF Module creation. Change-Id: I6d76282d1f37c081355cee72797d8e13da4e3cb0 Issue-ID: SO-1149 Signed-off-by: Benjamin, Max (mb388a) Signed-off-by: Rob Daugherty --- .../validation/RelatedInstancesValidation.java | 2 +- .../so/apihandlerinfra/ServiceInstancesTest.java | 39 +++++++++++++++ .../validation/RelatedInstancesValidationTest.java | 4 +- .../v7CreateVnfNetworkCollection.json | 56 --------------------- .../v7CreateVnfNetworkInstanceGroup.json | 56 +++++++++++++++++++++ .../VnfwithNeteworkInstanceGroup.json | 57 ++++++++++++++++++++++ 6 files changed, 155 insertions(+), 59 deletions(-) delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfwithNeteworkInstanceGroup.json (limited to 'mso-api-handlers') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java index 1f4fbc974a..f22294b33f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java @@ -106,7 +106,7 @@ public class RelatedInstancesValidation implements ValidationRule{ if(!( relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) || relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) || relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) || - relatedInstanceModelInfo.getModelType().equals(ModelType.networkCollection))) { + relatedInstanceModelInfo.getModelType().equals(ModelType.networkInstanceGroup))) { if(empty (relatedInstanceModelInfo.getModelInvariantId ())) { throw new ValidationException ("modelInvariantId in relatedInstance"); 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 dfcf9ffc46..01b5b38d4f 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 @@ -2392,4 +2392,43 @@ public class ServiceInstancesTest extends BaseTest{ RequestError realResponse = mapper.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", realResponse.getServiceException().getText()); } + @Test + public void vnfUpdateWithNetworkInstanceGroup() throws IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" + + "[?]nfRole=GR-API-DEFAULT&action=updateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + HttpHeaders headers = new HttpHeaders(); + headers.set(MsoLogger.CLIENT_ID, "VID"); + //expect + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca"; + ResponseEntity response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //then + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java index 93542c0a76..02fd7a1aca 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java @@ -38,8 +38,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class RelatedInstancesValidationTest extends BaseTest{ @Test - public void testCreateVnfNetworkCollection() throws IOException, ValidationException { - String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json"))); + public void testCreateVnfNetworkInstanceGroup() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json"))); ObjectMapper mapper = new ObjectMapper(); ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); ValidationInformation info = new ValidationInformation(sir, new HashMap(), Action.createInstance, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json deleted file mode 100644 index 99ca7fcfb0..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "requestDetails": { - "modelInfo": { - "modelType": "vnf", - "modelInvariantId": "9a10143a-13e3-4f56-8661-6625e6bcc310", - "modelVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", - "modelName": "VF01032017", - "modelVersion": "1.0", - "modelCustomizationId": "d752b40b-3e1f-4aac-95d0-9f257c74f442" - }, - "cloudConfiguration": { - "lcpCloudRegionId": "mdt1", - "tenantId": "88a6ca3ee0394ade9403f075db23167e" - }, - "requestInfo": { - "instanceName": "MSOTEST103a", - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "source": "VID", - "suppressRollback": false, - "requestorId": "xxxxxx" - }, - "platform": { - "platformName": "platform" - }, - "lineOfBusiness": { - "lineOfBusinessName": "business" - }, - "relatedInstanceList": [ - { - "relatedInstance": { - "instanceId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b", - "modelInfo": { - "modelType": "service", - "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelVersionId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b", - "modelName": "Test", - "modelVersion": "1.0" - } - } - }, - { - "relatedInstance": { - "instanceId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b", - "modelInfo": { - "modelType": "networkCollection" - } - } - } - ], - "requestParameters": { - "autoBuildVfModules": false , - "aLaCarte": false, - "subscriptionServiceType": "test" - } - } -} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json new file mode 100644 index 0000000000..da202f657f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json @@ -0,0 +1,56 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vnf", + "modelInvariantId": "9a10143a-13e3-4f56-8661-6625e6bcc310", + "modelVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "VF01032017", + "modelVersion": "1.0", + "modelCustomizationId": "d752b40b-3e1f-4aac-95d0-9f257c74f442" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTEST103a", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "platform": { + "platformName": "platform" + }, + "lineOfBusiness": { + "lineOfBusinessName": "business" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b", + "modelName": "Test", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b", + "modelInfo": { + "modelType": "networkInstanceGroup" + } + } + } + ], + "requestParameters": { + "autoBuildVfModules": false , + "aLaCarte": false, + "subscriptionServiceType": "test" + } + } +} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfwithNeteworkInstanceGroup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfwithNeteworkInstanceGroup.json new file mode 100644 index 0000000000..fb6b9c25d3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfwithNeteworkInstanceGroup.json @@ -0,0 +1,57 @@ +{ + "requestDetails":{ + "requestInfo":{ + "productFamilyId":"e433710f-9217-458d-a79d-1c7aff376d87", + "source":"VID", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "lineOfBusiness":{ + "lineOfBusinessName":"line_of_business" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"DYH1A", + "tenantId":"7f3db563322146a688601ade1294a747" + }, + "platform":{ + + }, + "modelInfo":{ + "modelCustomizationId":"2ccae1b4-7d9e-46fa-a452-9180ce008d17", + "modelCustomizationName":"test_name", + "modelVersionId":"0f161f68-9cd8-41f3-872d-41e58d83d318", + "modelName":"modelName", + "modelInvariantId":"f501ce76-a9bc-4601-9837-74fd9f4d5ecb", + "modelType":"vnf", + "modelVersion":"7.0" + }, + "requestParameters":{ + "userParams":[ + + ], + "testApi":"GR_API" + }, + "relatedInstanceList":[ + { + "relatedInstance":{ + "instanceId":"e05864f0-ab35-47d0-8be4-56fd9619ba3c", + "modelInfo":{ + "modelVersionId":"ecd348d8-41f6-447a-93a6-4300db495688", + "modelName":"Subinterface_SVC_ym161d", + "modelInvariantId":"4c1147bd-de97-43d5-b05e-5faa9aba220d", + "modelType":"service", + "modelVersion":"5.0" + } + } + }, + { + "relatedInstance":{ + "instanceId":"1b53f649-8969-443f-8ca4-d70f2ec6de0b", + "modelInfo":{ + "modelType":"networkInstanceGroup" + } + } + } + ] + } +} \ No newline at end of file -- cgit 1.2.3-korg From 714f7312ef66123ae7cf5a01dbb1c57701733294 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Tue, 23 Oct 2018 09:43:26 -0400 Subject: default cloud owner now configurable default cloud owner can now be set via a property Change-Id: I9b900cb2a5c7176a78e889ad2ce31a4ed9d38585 Issue-ID: SO-1158 Signed-off-by: Benjamin, Max (mb388a) --- .../tenantIsolation/AaiClientPropertiesImpl.java | 1 + .../asdc/tenantIsolation/SpringContextHelper.java | 41 ------------------- .../src/test/java/org/onap/so/asdc/BaseTest.java | 2 +- .../onap/so/bpmn/common/SpringContextHelper.java | 41 ------------------- common/pom.xml | 37 ++++++++++++++++- .../main/java/org/onap/so/constants/Defaults.java | 30 ++++++++++---- .../org/onap/so/spring/SpringContextHelper.java | 40 +++++++++++++++++++ .../src/test/java/org/onap/so/NonSpringSuite.java | 35 ++++++++++++++++ common/src/test/java/org/onap/so/SpringSuite.java | 35 ++++++++++++++++ .../java/org/onap/so/constants/DefaultsTest.java | 46 ++++++++++++++++++++++ .../org/onap/so/test/categories/SpringAware.java | 25 ++++++++++++ common/src/test/resources/application-test.yaml | 4 ++ .../so/apihandlerinfra/SpringContextHelper.java | 42 -------------------- .../tenantisolation/AaiClientPropertiesImpl.java | 2 +- .../tenantisolation/GrmClientPropertiesImpl.java | 2 +- .../tenantisolation/dmaap/DmaapPropertiesImpl.java | 2 +- 16 files changed, 249 insertions(+), 136 deletions(-) delete mode 100644 asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/SpringContextHelper.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java create mode 100644 common/src/main/java/org/onap/so/spring/SpringContextHelper.java create mode 100644 common/src/test/java/org/onap/so/NonSpringSuite.java create mode 100644 common/src/test/java/org/onap/so/SpringSuite.java create mode 100644 common/src/test/java/org/onap/so/constants/DefaultsTest.java create mode 100644 common/src/test/java/org/onap/so/test/categories/SpringAware.java create mode 100644 common/src/test/resources/application-test.yaml delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java (limited to 'mso-api-handlers') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java index dcfeb10845..7b769bd532 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java @@ -25,6 +25,7 @@ import java.net.URL; import org.onap.so.client.aai.AAIProperties; import org.onap.so.client.aai.AAIVersion; +import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; public class AaiClientPropertiesImpl implements AAIProperties { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/SpringContextHelper.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/SpringContextHelper.java deleted file mode 100644 index 5f30edd8d9..0000000000 --- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/SpringContextHelper.java +++ /dev/null @@ -1,41 +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.asdc.tenantIsolation; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -@Component -public class SpringContextHelper implements ApplicationContextAware { - - private static ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - context = applicationContext; - } - - public static ApplicationContext getAppContext() { - return context; - } -} diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java index 9a7240c830..74f0d60596 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java @@ -27,8 +27,8 @@ import org.junit.runner.RunWith; import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.asdc.installer.VfResourceStructure; import org.onap.so.asdc.installer.heat.ToscaResourceInstaller; -import org.onap.so.asdc.tenantIsolation.SpringContextHelper; import org.onap.so.asdc.tenantIsolation.WatchdogDistribution; +import org.onap.so.spring.SpringContextHelper; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; import org.springframework.boot.test.context.SpringBootTest; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java deleted file mode 100644 index edc544d939..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java +++ /dev/null @@ -1,41 +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.bpmn.common; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -@Component -public class SpringContextHelper implements ApplicationContextAware { - - private static ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - context = applicationContext; - } - - public static ApplicationContext getAppContext() { - return context; - } -} diff --git a/common/pom.xml b/common/pom.xml index 8b0f19cfc4..4427b3755e 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -139,6 +139,11 @@ logging-slf4j 1.2.2 + + org.springframework.boot + spring-boot-starter-test + test + @@ -152,6 +157,36 @@ **/*.java - + + + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + **/NonSpringSuite.java + + + + + spring-tests + + test + + + + **/SpringSuite.java + + + + + + diff --git a/common/src/main/java/org/onap/so/constants/Defaults.java b/common/src/main/java/org/onap/so/constants/Defaults.java index 06c6fae467..621acfffaa 100644 --- a/common/src/main/java/org/onap/so/constants/Defaults.java +++ b/common/src/main/java/org/onap/so/constants/Defaults.java @@ -20,19 +20,35 @@ package org.onap.so.constants; +import java.util.Optional; + +import org.onap.so.spring.SpringContextHelper; +import org.springframework.context.ApplicationContext; + public enum Defaults { - CLOUD_OWNER("att-aic"); - - - private final String value; + CLOUD_OWNER("org.onap.so.cloud-owner", "att-aic"); - private Defaults(String value) { - this.value = value; + private final String propName; + private final String defaultValue; + + private Defaults(String propName, String defaultValue) { + this.defaultValue = defaultValue; + this.propName = propName; } @Override public String toString() { - return this.value; + Optional context = getAppContext(); + if (context.isPresent()) { + return context.get().getEnvironment().getProperty(this.propName, this.defaultValue); + } else { + return this.defaultValue; + } + + } + + protected Optional getAppContext() { + return Optional.ofNullable(SpringContextHelper.getAppContext()); } } diff --git a/common/src/main/java/org/onap/so/spring/SpringContextHelper.java b/common/src/main/java/org/onap/so/spring/SpringContextHelper.java new file mode 100644 index 0000000000..1fae5f3e23 --- /dev/null +++ b/common/src/main/java/org/onap/so/spring/SpringContextHelper.java @@ -0,0 +1,40 @@ +/*- + * ============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.spring; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +@Component +public class SpringContextHelper implements ApplicationContextAware { + + private static ApplicationContext context; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) { + context = applicationContext; + } + + public static ApplicationContext getAppContext() { + return context; + } +} diff --git a/common/src/test/java/org/onap/so/NonSpringSuite.java b/common/src/test/java/org/onap/so/NonSpringSuite.java new file mode 100644 index 0000000000..86bb421123 --- /dev/null +++ b/common/src/test/java/org/onap/so/NonSpringSuite.java @@ -0,0 +1,35 @@ +/*- + * ============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; + +import org.junit.runner.RunWith; +import org.onap.so.test.categories.SpringAware; + +import com.googlecode.junittoolbox.ExcludeCategories; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@ExcludeCategories({SpringAware.class}) +@SuiteClasses({"**/*Test.class"}) +public class NonSpringSuite { + +} diff --git a/common/src/test/java/org/onap/so/SpringSuite.java b/common/src/test/java/org/onap/so/SpringSuite.java new file mode 100644 index 0000000000..93d4d31f5c --- /dev/null +++ b/common/src/test/java/org/onap/so/SpringSuite.java @@ -0,0 +1,35 @@ +/*- + * ============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; + +import org.junit.runner.RunWith; +import org.onap.so.test.categories.SpringAware; + +import com.googlecode.junittoolbox.IncludeCategories; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@IncludeCategories({SpringAware.class}) +@SuiteClasses({"**/*Test.class"}) +public class SpringSuite { + +} diff --git a/common/src/test/java/org/onap/so/constants/DefaultsTest.java b/common/src/test/java/org/onap/so/constants/DefaultsTest.java new file mode 100644 index 0000000000..1bcee07118 --- /dev/null +++ b/common/src/test/java/org/onap/so/constants/DefaultsTest.java @@ -0,0 +1,46 @@ +/*- + * ============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.constants; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.onap.so.spring.SpringContextHelper; +import org.onap.so.test.categories.SpringAware; +import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class) +@ActiveProfiles("test") +@Category(SpringAware.class) +public class DefaultsTest { + + @Test + public void checkValue() { + + assertEquals("CloudOwner", Defaults.CLOUD_OWNER.toString()); + } +} diff --git a/common/src/test/java/org/onap/so/test/categories/SpringAware.java b/common/src/test/java/org/onap/so/test/categories/SpringAware.java new file mode 100644 index 0000000000..21035fcd4d --- /dev/null +++ b/common/src/test/java/org/onap/so/test/categories/SpringAware.java @@ -0,0 +1,25 @@ +/*- + * ============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.test.categories; + +public interface SpringAware { + /* category marker */ +} diff --git a/common/src/test/resources/application-test.yaml b/common/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..cf386cb6fc --- /dev/null +++ b/common/src/test/resources/application-test.yaml @@ -0,0 +1,4 @@ +org: + onap: + so: + cloud-owner: CloudOwner \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java deleted file mode 100644 index 6d61d3bb34..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.apihandlerinfra; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -@Component -public class SpringContextHelper implements ApplicationContextAware { - - private static ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) { - context = applicationContext; - } - - public static ApplicationContext getAppContext() { - return context; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java index 5675588f62..1ea77acf95 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java @@ -23,9 +23,9 @@ package org.onap.so.apihandlerinfra.tenantisolation; import java.net.MalformedURLException; import java.net.URL; -import org.onap.so.apihandlerinfra.SpringContextHelper; import org.onap.so.client.aai.AAIProperties; import org.onap.so.client.aai.AAIVersion; +import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; public class AaiClientPropertiesImpl implements AAIProperties { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java index 58a7cb2bff..f83e707258 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java @@ -25,8 +25,8 @@ import java.net.URL; import javax.ws.rs.core.MediaType; -import org.onap.so.apihandlerinfra.SpringContextHelper; import org.onap.so.client.grm.GRMProperties; +import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; public class GrmClientPropertiesImpl implements GRMProperties { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java index 0e26178e56..813299c370 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java @@ -23,8 +23,8 @@ package org.onap.so.apihandlerinfra.tenantisolation.dmaap; import java.util.HashMap; import java.util.Map; -import org.onap.so.apihandlerinfra.SpringContextHelper; import org.onap.so.client.dmaap.DmaapProperties; +import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; public class DmaapPropertiesImpl implements DmaapProperties { -- cgit 1.2.3-korg From 5aaf7f76c6632dcd4bea56b227648482ddde3a50 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Tue, 23 Oct 2018 12:02:27 -0400 Subject: Bug fixes October 23rd fixed the db status not being updated on delete SI added a default sequence flow to isAsync_Gateway Removed @Before and organized imports Added check to prevent db query with only requestStatus correct AAIObjectPlurals enum value name Correct rollbackData setting and protect against null Change-Id: Ic7c47dc968a29987c3d576da9aa50c7ddc8f28ee Issue-ID: SO-1162 Signed-off-by: Benjamin, Max (mb388a) --- .../DeleteGenericALaCarteServiceInstance.groovy | 6 +++-- .../scripts/DoCreateServiceInstance.groovy | 27 ++++++++++++++++------ .../InfraActiveRequestsRepositoryImpl.java | 20 ++++++++-------- .../InfraActiveRequestsRepositoryImplTest.java | 9 ++++++++ 4 files changed, 43 insertions(+), 19 deletions(-) (limited to 'mso-api-handlers') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy index b43a96bdb0..ec2fed50c3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy @@ -200,6 +200,7 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro try { String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") String source = execution.getVariable("source") String msoCompletionRequest = """DELETE ${MsoUtils.xmlEscape(source)} - Service Instance was deleted successfully. - DeleteGenericALaCarteServiceInstance + Service Instance was deleted successfully. + ${MsoUtils.xmlEscape(serviceInstanceId)} + DeleteGenericALaCarteServiceInstance """ // Format Response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index 38836c3650..6d41923bdf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -94,6 +94,12 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { try { String requestId = execution.getVariable("msoRequestId") execution.setVariable("prefix", Prefix) + + def rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + execution.setVariable("rollbackData", rollbackData) setBasicDBAuthHeader(execution, isDebugEnabled) //Inputs @@ -409,7 +415,10 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { throw e; } catch (Exception ex) { //start rollback set up - RollbackData rollbackData = new RollbackData() + def rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } def disableRollback = execution.getVariable("disableRollback") rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") @@ -506,11 +515,13 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { def sdncRequestId3 = UUID.randomUUID().toString() String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId2}<", ">${sdncRequestId3}<") def rollbackData = execution.getVariable("rollbackData") - rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate) - rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete) - execution.setVariable("rollbackData", rollbackData) + if (rollbackData != null) { + rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate) + rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete) + execution.setVariable("rollbackData", rollbackData) - msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + } } catch (BpmnError e) { throw e; @@ -541,8 +552,10 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { msoLogger.debug("Good response from SDNC Adapter for service-instance topology assign: \n" + response) def rollbackData = execution.getVariable("rollbackData") - rollbackData.put("SERVICEINSTANCE", "rollbackSDNC", "true") - execution.setVariable("rollbackData", rollbackData) + if (rollbackData != null) { + rollbackData.put("SERVICEINSTANCE", "rollbackSDNC", "true") + execution.setVariable("rollbackData", rollbackData) + } }else{ msoLogger.debug("Bad Response from SDNC Adapter for service-instance assign") diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java index d66e378146..951f02e5d8 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -172,6 +172,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery crit = cb.createQuery(InfraActiveRequests.class); final Root tableRoot = crit.from(InfraActiveRequests.class); + InfraActiveRequests infraActiveRequests = null; if (instanceName != null && !instanceName.equals("")) { @@ -229,18 +230,17 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep } } } - - predicates.add(tableRoot.get(REQUEST_STATUS) + if(!predicates.isEmpty()){ + predicates.add(tableRoot.get(REQUEST_STATUS) .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK"))); - final Order order = cb.desc(tableRoot.get(START_TIME)); - - final List dupList = executeInfraQuery(crit, predicates, order); - - InfraActiveRequests infraActiveRequests = null; - - if (dupList != null && !dupList.isEmpty()) { - infraActiveRequests = dupList.get(0); + final Order order = cb.desc(tableRoot.get(START_TIME)); + + final List dupList = executeInfraQuery(crit, predicates, order); + + if (dupList != null && !dupList.isEmpty()) { + infraActiveRequests = dupList.get(0); + } } return infraActiveRequests; diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java index b7eb7642a2..4097aee7d5 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java @@ -22,6 +22,7 @@ package org.onap.so.db.request.data.repository; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.ACTION; import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.REQUEST_ID; @@ -181,4 +182,12 @@ public class InfraActiveRequestsRepositoryImplTest { objUnderTest.getInfraActiveRequests(null, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, MAX_LIMIT); assertTrue(actualRequests.isEmpty()); } + + @Test + public void checkInstanceNameDuplicateNullInstanceNameTest(){ + Map instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", "e05864f0-ab35-47d0-8be4-56fd9619ba3b"); + InfraActiveRequests results = objUnderTest.checkInstanceNameDuplicate((HashMap)instanceIdMap, null, "vnf"); + assertNull(results); + } } -- cgit 1.2.3-korg