From 9f6c9c74c5f10794cdbe6de2ed6d0539ce7d0d84 Mon Sep 17 00:00:00 2001 From: "BOSLET, CORY" Date: Mon, 8 Mar 2021 15:08:06 -0500 Subject: Added volume creation to heatbridge Added volume creation to heatbridge Issue-ID: SO-3577 Signed-off-by: AT&T Open Source Change-Id: I0f0844187efe880cccf4b663c8c4fadc346680c3 --- .../org/onap/so/heatbridge/HeatBridgeImplTest.java | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'adapters/mso-openstack-adapters/src/test/java') diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index fab7df5345..cf3e1c5ee1 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -106,6 +106,8 @@ import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; import org.openstack4j.model.network.Subnet; +import org.openstack4j.model.storage.block.Volume; +import org.openstack4j.model.storage.block.VolumeAttachment; import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; import org.slf4j.Logger; @@ -118,7 +120,6 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; - @RunWith(MockitoJUnitRunner.Silent.class) public class HeatBridgeImplTest { @@ -808,6 +809,28 @@ public class HeatBridgeImplTest { assertEquals(1, images.size()); } + @Test + public void testBuildAddVolumes() throws HeatBridgeException { + List stackResources = (List) extractTestStackResources(); + Volume volume = mock(Volume.class); + List attachments = new ArrayList<>(); + VolumeAttachment server = mock(VolumeAttachment.class); + attachments.add(server); + when(volume.getAttachments()).thenAnswer(x -> attachments); + when(server.getServerId()).thenReturn("vserverIdTest"); + + when(osClient.getVolumeById("5ad95036-8daf-4379-a59c-865f35976ca3")).thenReturn(volume); + + heatbridge.buildAddVolumes(stackResources); + + verify(transaction, times(1)).createIfNotExists( + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion("CloudOwner", "RegionOne").tenant("7320ec4a5b9d4589ba7c4412ccfd290f") + .vserver("vserverIdTest").volume("5ad95036-8daf-4379-a59c-865f35976ca3"))), + any(Optional.class)); + verify(osClient, times(1)).getVolumeById(eq("5ad95036-8daf-4379-a59c-865f35976ca3")); + } + private List extractTestStackResources() { List stackResources = null; try { @@ -838,4 +861,5 @@ public class HeatBridgeImplTest { } + } -- cgit 1.2.3-korg