summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-11-16 20:37:57 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-11-17 01:46:26 -0500
commit898449a5d41b777ebe271bcae9c0ba511fecdb1f (patch)
tree3f6fcb64b39269b00ffa683b3d8b03281a6aca40 /mso-api-handlers/mso-api-handler-infra
parent1ad4536823e70b099947595ccfa6534055ddc9c4 (diff)
Bug Fixes November 16th
fix failing junit when heatID not available provide name if ID is not present on delete op removed logic to skip unassign sdnc in rollback flows Move default settings to CrVfModRequest pojo. Check for null backout and failIfExists params - 1810. Updated exception message and test Added tests for networkCustomization not found Added tests for delete and update network Separated networkResourceCustomization and networkResource lookups Removed version check as not necessary for setting boolean Change-Id: Ia4b409244dc5ebdbb163d4a178713115719366ca Issue-ID: SO-1231 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java20
-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.java50
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json3
4 files changed, 65 insertions, 10 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 8047893bb4..04a707c4ad 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -50,6 +50,7 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.beans.VfModule;
@@ -1530,14 +1531,19 @@ public class ServiceInstances {
Recipe recipe = null;
if(modelInfo.getModelCustomizationId()!=null){
- NetworkResource networkResource = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource();
- if(networkResource!=null){
- if(modelInfo.getModelVersionId() == null) {
- modelInfo.setModelVersionId(networkResource.getModelUUID());
+ NetworkResourceCustomization networkResourceCustomization = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId());
+ if(networkResourceCustomization != null){
+ NetworkResource networkResource = networkResourceCustomization.getNetworkResource();
+ if(networkResource!=null){
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(networkResource.getModelUUID());
+ }
+ recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString());
+ }else{
+ throw new ValidationException("no catalog entry found");
}
- recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString());
- }else{
- throw new ValidationException("no catalog entry found");
+ }else if(action != Action.deleteInstance){
+ throw new ValidationException("modelCustomizationId for networkResourceCustomization lookup", true);
}
}else{
//ok for version < 3 and action delete
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 f22294b33f..9af26af91c 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
@@ -128,7 +128,7 @@ public class RelatedInstancesValidation implements ValidationRule{
if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
isSourceVnfPresent = true;
} else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) &&
- (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) {
+ (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf)))) {
isDestinationVnfPresent = true;
}
}
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 01b5b38d4f..0ce31a23e3 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
@@ -1710,7 +1710,7 @@ public class ServiceInstancesTest extends BaseTest{
stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
+ .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
@@ -2431,4 +2431,52 @@ public class ServiceInstancesTest extends BaseTest{
ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
}
+ @Test
+ public void deleteNetworkInstanceNoCustomizationEntry() 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(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+
+ stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ "modelName=VNF-API-DEFAULT&action=deleteInstance"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
+ stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json
index a37fe050eb..6e5eb0f533 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json
@@ -1,7 +1,8 @@
{
"requestDetails":{
"modelInfo":{
- "modelType":"network"
+ "modelType":"network",
+ "modelCustomizationId": "3bdbb104-476c-483e-9f8b-c095b3d308ac"
},
"requestInfo":{
"source":"VID",