aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2019-04-29 10:16:49 +0000
committerMichaelMorris <michael.morris@est.tech>2019-04-29 10:16:49 +0000
commitf4f9c027afc2981d36d607612b6e67cd0a1e8d52 (patch)
treed6228b9ad4194c9b798409e248e118d5301cd2cf /adapters/mso-vnfm-adapter
parentd402a7d0e3bfdfbd2a3d6cfce2c9f170a30c4192 (diff)
Fixed issues found in delete integration testing
Issue-ID: SO-1827 Change-Id: I73fdcad3d466634cea850e4df10291a66ec2aa61 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java46
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java75
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java30
8 files changed, 131 insertions, 49 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
index 867b6522f5..1374e89a19 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
@@ -110,7 +111,7 @@ public class AaiHelper {
*/
public String getIdOfAssignedVnfm(final GenericVnf vnf) {
final Relationship relationship = getRelationship(vnf, "esr-vnfm");
- return getRelationshipKey(relationship, "esr-vnfm.vnfm-id");
+ return getRelationshipData(relationship, "esr-vnfm.vnfm-id");
}
/**
@@ -121,9 +122,9 @@ public class AaiHelper {
*/
public Tenant getAssignedTenant(final GenericVnf vnf) {
final Relationship relationship = getRelationship(vnf, "tenant");
- final String cloudOwner = getRelationshipKey(relationship, "cloud-region.cloud-owner");
- final String cloudRegion = getRelationshipKey(relationship, "cloud-region.cloud-region-id");
- final String tenantId = getRelationshipKey(relationship, "tenant.tenant-id");
+ final String cloudOwner = getRelationshipData(relationship, "cloud-region.cloud-owner");
+ final String cloudRegion = getRelationshipData(relationship, "cloud-region.cloud-region-id");
+ final String tenantId = getRelationshipData(relationship, "tenant.tenant-id");
if (cloudOwner == null || cloudRegion == null || tenantId == null) {
throw new TenantNotFoundException("No matching Tenant found in AAI. VNFID: " + vnf.getVnfId());
} else {
@@ -141,10 +142,17 @@ public class AaiHelper {
return null;
}
- private String getRelationshipKey(final Relationship relationship, final String relationshipKey) {
+ /**
+ * Get the value of the relationship data with the given key in the given relationship.
+ *
+ * @param relationship the relationship
+ * @param relationshipDataKey the key for the relationship data
+ * @return the value of the relationship data for the given key
+ */
+ public String getRelationshipData(final Relationship relationship, final String relationshipDataKey) {
if (relationship != null) {
for (final RelationshipData relationshipData : relationship.getRelationshipData()) {
- if (relationshipData.getRelationshipKey().equals(relationshipKey)) {
+ if (relationshipData.getRelationshipKey().equals(relationshipDataKey)) {
return relationshipData.getRelationshipValue();
}
}
@@ -153,6 +161,32 @@ public class AaiHelper {
}
/**
+ * Delete from the given VNF the relationship matching the given criteria.
+ *
+ * @param vnf the VNF
+ * @param relationshipRelatedToValue the related-to value for the relationship
+ * @param dataKey the relationship data key to match on
+ * @param dataValue the value the relationship data with the given key must match
+ * @return the deleted relationship or <code>null</code> if none found matching the given criteria
+ */
+ public Relationship deleteRelationshipWithDataValue(final GenericVnf vnf, final String relationshipRelatedToValue,
+ final String dataKey, final String dataValue) {
+ final Iterator<Relationship> relationships =
+ vnf.getRelationshipList() == null ? Collections.<Relationship>emptyList().iterator()
+ : vnf.getRelationshipList().getRelationship().iterator();
+
+ while (relationships.hasNext()) {
+ final Relationship relationship = relationships.next();
+ if (relationship.getRelatedTo().equals(relationshipRelatedToValue)
+ && dataValue.equals(getRelationshipData(relationship, dataKey))) {
+ relationships.remove();
+ return relationship;
+ }
+ }
+ return null;
+ }
+
+ /**
* Select a VNFM to use for the given generic VNF. Should only be used when no VNFM has already been assigned to the
* VNF.
*
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
index 645f37e72f..e66f86b66f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
@@ -133,7 +133,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
public void deleteVnf(final String vnfSelfLink) {
logger.debug("Sending delete request to : " + vnfSelfLink);
final ResponseEntity<Void> response = httpServiceProvider.deleteHttpRequest(vnfSelfLink, Void.class);
- if (response.getStatusCode() != HttpStatus.OK) {
+ if (response.getStatusCode() != HttpStatus.NO_CONTENT) {
throw new VnfmRequestFailureException(
"Delete request to " + vnfSelfLink + " return status code: " + response.getStatusCode());
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
index e61bf860b3..345ff5119a 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
@@ -20,8 +20,11 @@
package org.onap.so.adapters.vnfmadapter.jobmanagement;
+import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
+import java.util.Map;
+import java.util.UUID;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException;
@@ -32,9 +35,6 @@ import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Map;
-import java.util.UUID;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Manages jobs enabling the status of jobs to be queried. A job is associated with an operation on a VNFM.
@@ -123,12 +123,15 @@ public class JobManager {
public void notificationProcessedForOperation(final String operationId,
final boolean notificationProcessingWasSuccessful) {
+ logger.debug("Notification processed for operation ID {} success?: {}", operationId,
+ notificationProcessingWasSuccessful);
final java.util.Optional<VnfmOperation> relatedOperation = mapOfJobIdToVnfmOperation.values().stream()
.filter(operation -> operation.getOperationId().equals(operationId)).findFirst();
if (relatedOperation.isPresent()) {
relatedOperation.get().setNotificationProcessed(notificationProcessingWasSuccessful);
+ } else {
+ logger.debug("No operation found for operation ID " + operationId);
}
- logger.debug("No operation found for operation ID " + operationId);
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
index 3ed66ad713..7ce08df52f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
@@ -94,4 +94,11 @@ public class VnfmOperation {
NOTIFICATION_PROCESSING_FAILED;
}
+ @Override
+ public String toString() {
+ return "VnfmOperation [vnfmId=" + vnfmId + ", operationId=" + operationId + ", notificationStatus="
+ + notificationStatus + "]";
+ }
+
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index d39a2cb761..c09aa0cd48 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -27,6 +27,7 @@ import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
@@ -34,6 +35,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
@@ -100,8 +102,7 @@ public class NotificationHandler implements Runnable {
aaiServiceProvider.invokePutGenericVnf(genericVnf);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
+ addVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(), vnfInstance.getVimConnectionInfo());
logger.debug("Finished handling notification for vnfm: " + vnfInstance.getId());
}
@@ -114,16 +115,17 @@ public class NotificationHandler implements Runnable {
}
if (oamIpAddressSource.getType().equals(OamIpAddressType.LITERAL)) {
genericVnf.setIpv4OamAddress(oamIpAddressSource.getValue());
- }
- try {
- logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
- if (vnfInstance.getVnfConfigurableProperties() == null) {
- logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
+ } else {
+ try {
+ logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
+ if (vnfInstance.getVnfConfigurableProperties() == null) {
+ logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
+ }
+ final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
+ genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
+ } catch (final JSONException jsonException) {
+ logger.error("Error getting vnfIpAddress", jsonException);
}
- final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
- genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
- } catch (final JSONException jsonException) {
- logger.error("Error getting vnfIpAddress", jsonException);
}
}
@@ -143,30 +145,29 @@ public class NotificationHandler implements Runnable {
private void handleVnfTerminateFailed() {
final GenericVnf genericVnf = aaiServiceProvider
.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
- jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(), false);
+ deleteVservers(vnfLcmOperationOccurrenceNotification, genericVnf);
+ jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(), false);
}
private void handleVnfTerminateCompleted() {
final GenericVnf genericVnf = aaiServiceProvider
.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
+ deleteVservers(vnfLcmOperationOccurrenceNotification, genericVnf);
boolean deleteSuccessful = false;
try {
vnfmServiceProvider.deleteVnf(genericVnf.getSelflink());
deleteSuccessful = true;
} finally {
- jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(),
+ jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(),
deleteSuccessful);
genericVnf.setOrchestrationStatus("Assigned");
+ genericVnf.setSelflink("");
aaiServiceProvider.invokePutGenericVnf(genericVnf);
}
}
- private void updateVservers(final VnfLcmOperationOccurrenceNotification notification, final String vnfId,
+ private void addVservers(final VnfLcmOperationOccurrenceNotification notification, final String vnfId,
final List<InlineResponse201VimConnectionInfo> vnfInstancesVimConnectionInfo) {
final Map<String, InlineResponse201VimConnectionInfo> vimConnectionIdToVimConnectionInfo = new HashMap<>();
for (final InlineResponse201VimConnectionInfo vimConnectionInfo : vnfInstancesVimConnectionInfo) {
@@ -176,22 +177,28 @@ public class NotificationHandler implements Runnable {
for (final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc : notification.getAffectedVnfcs()) {
final InlineResponse201VimConnectionInfo vimConnectionInfo =
getVimConnectionInfo(vimConnectionIdToVimConnectionInfo, vnfc);
- switch (vnfc.getChangeType()) {
- case ADDED:
- final Vserver vserver = aaiHelper.createVserver(vnfc);
- aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
-
- aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo),
- getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo), vserver);
- break;
- case REMOVED:
- aaiServiceProvider.invokeDeleteVserver(getCloudOwner(vimConnectionInfo),
- getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo),
- vnfc.getComputeResource().getResourceId());
- break;
- case MODIFIED:
- case TEMPORARY:
- default:
+ if (ChangeTypeEnum.ADDED.equals(vnfc.getChangeType())) {
+ final Vserver vserver = aaiHelper.createVserver(vnfc);
+ aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
+
+ aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo), getCloudRegion(vimConnectionInfo),
+ getTenant(vimConnectionInfo), vserver);
+ }
+ }
+ }
+
+ private void deleteVservers(final VnfLcmOperationOccurrenceNotification notification, final GenericVnf vnf) {
+ for (final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc : notification.getAffectedVnfcs()) {
+ if (ChangeTypeEnum.REMOVED.equals(vnfc.getChangeType())) {
+
+ final Relationship relationshipToVserver = aaiHelper.deleteRelationshipWithDataValue(vnf, "vserver",
+ "vserver.vserver-id", vnfc.getComputeResource().getResourceId());
+
+ aaiServiceProvider.invokeDeleteVserver(
+ aaiHelper.getRelationshipData(relationshipToVserver, "cloud-region.cloud-owner"),
+ aaiHelper.getRelationshipData(relationshipToVserver, "cloud-region.cloud-region-id"),
+ aaiHelper.getRelationshipData(relationshipToVserver, "tenant.tenant-id"),
+ vnfc.getComputeResource().getResourceId());
}
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
index e241d0de7e..3ead98fce2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
@@ -97,7 +97,7 @@ public class Sol003GrantController {
if (grantRequest.getOperation().equals(GrantRequest.OperationEnum.INSTANTIATE)) {
grantResponse.addResources(getResources(grantRequest.getAddResources(), vimConnectionId));
} else if (grantRequest.getOperation().equals(GrantRequest.OperationEnum.TERMINATE)) {
- grantResponse.addResources(getResources(grantRequest.getRemoveResources(), vimConnectionId));
+ grantResponse.removeResources(getResources(grantRequest.getRemoveResources(), vimConnectionId));
}
return grantResponse;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
index 4af0da1485..69223d7922 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.vnfmadapter.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
@@ -102,6 +103,7 @@ public class Sol003GrantControllerTest {
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertEquals(1, response.getBody().getAddResources().size());
+ assertNull(response.getBody().getRemoveResources());
assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
@@ -128,8 +130,9 @@ public class Sol003GrantControllerTest {
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
- assertEquals(1, response.getBody().getAddResources().size());
- assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
+ assertNull(response.getBody().getAddResources());
+ assertEquals(1, response.getBody().getRemoveResources().size());
+ assertEquals(vimConnectionId, response.getBody().getRemoveResources().get(0).getVimConnectionId());
assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
assertEquals("123456", response.getBody().getVnfLcmOpOccId());
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
index 822201ea1c..aeb7cd3540 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
@@ -49,6 +49,8 @@ import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
@@ -221,7 +223,7 @@ public class Sol003LcnControllerTest {
.andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));
mockRestServer.expect(requestTo(new URI("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")))
- .andRespond(withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON));
+ .andRespond(withStatus(HttpStatus.NO_CONTENT).contentType(MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
@@ -229,6 +231,7 @@ public class Sol003LcnControllerTest {
listOfGenericVnfs.add(genericVnf);
final GenericVnfs genericVnfs = new GenericVnfs();
genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ addRelationshipFromGenericVnfToVserver(genericVnf, "myVnfc1");
doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
@@ -320,6 +323,31 @@ public class Sol003LcnControllerTest {
return genericVnf;
}
+ private void addRelationshipFromGenericVnfToVserver(final GenericVnf genericVnf, final String vserverId) {
+ final Relationship relationshipToVserver = new Relationship();
+ relationshipToVserver.setRelatedTo("vserver");
+ final RelationshipData relationshipData1 = new RelationshipData();
+ relationshipData1.setRelationshipKey("vserver.vserver-id");
+ relationshipData1.setRelationshipValue(vserverId);
+ relationshipToVserver.getRelationshipData().add(relationshipData1);
+ final RelationshipData relationshipData2 = new RelationshipData();
+ relationshipData2.setRelationshipKey("cloud-region.cloud-owner");
+ relationshipData2.setRelationshipValue(CLOUD_OWNER);
+ relationshipToVserver.getRelationshipData().add(relationshipData2);
+ final RelationshipData relationshipData3 = new RelationshipData();
+ relationshipData3.setRelationshipKey("cloud-region.cloud-region-id");
+ relationshipData3.setRelationshipValue(REGION);
+ relationshipToVserver.getRelationshipData().add(relationshipData3);
+ final RelationshipData relationshipData4 = new RelationshipData();
+ relationshipData4.setRelationshipKey("tenant.tenant-id");
+ relationshipData4.setRelationshipValue(TENANT_ID);
+ relationshipToVserver.getRelationshipData().add(relationshipData4);
+
+ final RelationshipList relationshipList = new RelationshipList();
+ relationshipList.getRelationship().add(relationshipToVserver);
+ genericVnf.setRelationshipList(relationshipList);
+ }
+
private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> {
final String uriAsString;