summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-10-23 14:08:57 -0400
committerRob Daugherty <rd472p@att.com>2018-10-23 16:18:55 -0400
commit6cf9ff1f1f2360a406f68f3147d86fd864d31910 (patch)
tree0df346a4222f84511ba47ac090e81d37a2c675d4 /mso-api-handlers
parent60f8f5342f1fba49373699c1466e6ca06d1adc34 (diff)
parent0116cbfe7836b05381fe5632e0e536a625789b31 (diff)
8/23: merge casablanca to master
Change-Id: I0a73fbedf8c6f22e0a37cd8f0505ddcf83250341 Issue-ID: SO-1160 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java42
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java39
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkInstanceGroup.json (renamed from mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfwithNeteworkInstanceGroup.json57
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java20
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java9
11 files changed, 122 insertions, 59 deletions
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 {
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<String> 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<String, String>(), 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/v7CreateVnfNetworkInstanceGroup.json
index 99ca7fcfb0..da202f657f 100644
--- 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/v7CreateVnfNetworkInstanceGroup.json
@@ -42,7 +42,7 @@
"relatedInstance": {
"instanceId": "0fd90c0c-0e3a-46e2-abb5-4c4820d5985b",
"modelInfo": {
- "modelType": "networkCollection"
+ "modelType": "networkInstanceGroup"
}
}
}
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
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<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
final Root<InfraActiveRequests> 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<InfraActiveRequests> 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<InfraActiveRequests> 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<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", "e05864f0-ab35-47d0-8be4-56fd9619ba3b");
+ InfraActiveRequests results = objUnderTest.checkInstanceNameDuplicate((HashMap<String, String>)instanceIdMap, null, "vnf");
+ assertNull(results);
+ }
}