summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java11
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java22
2 files changed, 15 insertions, 18 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
index 35008b6120..585e001f1a 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
@@ -24,9 +24,13 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.onap.aai.domain.yang.LInterface;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
@@ -53,11 +57,12 @@ public class AuditVServer extends AbstractAudit {
public Optional<AAIObjectAuditList> auditVserversThroughRelationships(String genericVnfId, String vfModuleName) {
AAIObjectAuditList auditList = new AAIObjectAuditList();
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, genericVnfId)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, genericVnfId)
.queryParam("vf-module-name", vfModuleName);
- if (getAaiClient().get(uri).getRelationships().isPresent()) {
+ Optional<AAIResultWrapper> wrapper = getAaiClient().getFirstWrapper(VfModules.class, VfModule.class, uri);
+ if (wrapper.isPresent() && wrapper.get().getRelationships().isPresent()) {
List<AAIResourceUri> relatedVservers =
- getAaiClient().get(uri).getRelationships().get().getRelatedUris(AAIObjectType.VSERVER);
+ wrapper.get().getRelationships().get().getRelatedUris(AAIObjectType.VSERVER);
if (!relatedVservers.isEmpty()) {
relatedVservers.forEach(vserverUri -> {
Optional<Vserver> vserver = getAaiClient().get(vserverUri).asBean(Vserver.class);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java
index 3d9a128318..8e71ec46b0 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java
@@ -22,17 +22,12 @@ package org.onap.so.adapters.audit;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashSet;
-import java.util.List;
import java.util.Optional;
import java.util.Set;
-import java.util.stream.Stream;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -43,9 +38,8 @@ import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.LInterface;
import org.onap.aai.domain.yang.LInterfaces;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
@@ -60,8 +54,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.woorea.openstack.heat.model.Resource;
-import com.woorea.openstack.heat.model.Resources;
@RunWith(MockitoJUnitRunner.Silent.class)
public class AuditVServerTest extends AuditVServer {
@@ -399,9 +391,9 @@ public class AuditVServerTest extends AuditVServer {
AAIResultWrapper wrapper = new AAIResultWrapper(vfModule);
- doReturn(wrapper).when(aaiResourcesMock)
- .get(AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "genericVnfId")
- .queryParam("vf-module-name", "vfModuleName"));
+ doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class,
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "genericVnfId").queryParam("vf-module-name",
+ "vfModuleName"));
Optional<AAIObjectAuditList> auditList =
auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName");
@@ -417,9 +409,9 @@ public class AuditVServerTest extends AuditVServer {
AAIResultWrapper wrapper = new AAIResultWrapper(vfModule);
AAIResultWrapper vserverWrapper = new AAIResultWrapper(new Vserver());
- doReturn(wrapper).when(aaiResourcesMock)
- .get(AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "genericVnfId")
- .queryParam("vf-module-name", "vfModuleName"));
+ doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class,
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "genericVnfId").queryParam("vf-module-name",
+ "vfModuleName"));
doReturn(vserverWrapper).when(aaiResourcesMock).get(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER,
"cloud-owner", "cloud-region-id", "tenant-id", "VUSCHGA1"));