Search in sources :

Example 6 with Resource

use of org.openstack4j.model.heat.Resource in project so by onap.

the class HeatBridgeImplTest method testBuildAddVserverLInterfacesToAaiAction_PortProfileNull.

@Test
public void testBuildAddVserverLInterfacesToAaiAction_PortProfileNull() throws HeatBridgeException, JsonParseException, JsonMappingException, IOException {
    // Arrange
    List<Resource> stackResources = (List<Resource>) extractTestStackResources();
    Port port = mock(Port.class);
    when(port.getId()).thenReturn("test-port-id");
    when(port.getName()).thenReturn("test-port-name");
    when(port.getvNicType()).thenReturn(HeatBridgeConstants.OS_SRIOV_PORT_TYPE);
    when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78");
    when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a");
    when(port.getDeviceId()).thenReturn("test-device-id");
    String pfPciId = "0000:08:00.0";
    Network network = mock(Network.class);
    when(network.getId()).thenReturn("test-network-id");
    when(network.getNetworkType()).thenReturn(NetworkType.VLAN);
    when(network.getProviderSegID()).thenReturn("2345");
    when(osClient.getPortById("212a203a-9764-4f42-84ea-731536a8f13a")).thenReturn(port);
    when(osClient.getPortById("387e3904-8948-43d1-8635-b6c2042b54da")).thenReturn(port);
    when(osClient.getPortById("70a09dfd-f1c5-4bc8-bd8f-dc539b8d662a")).thenReturn(port);
    when(osClient.getPortById("12f88b4d-c8a4-4fbd-bcb4-7e36af02430b")).thenReturn(port);
    when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port);
    when(osClient.getNetworkById(anyString())).thenReturn(network);
    PInterface pIf = mock(PInterface.class);
    when(pIf.getInterfaceName()).thenReturn("test-port-id");
    doNothing().when(heatbridge).updateSriovPfToSriovVF(any(), any());
    // Act
    heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner");
    // Assert
    ArgumentCaptor<Optional> argument = ArgumentCaptor.forClass(Optional.class);
    verify(transaction, times(5)).createIfNotExists(any(AAIResourceUri.class), argument.capture());
    assertEquals(false, ((LInterface) argument.getValue().get()).isL2Multicasting());
    verify(osClient, times(5)).getPortById(anyString());
    verify(osClient, times(5)).getNetworkById(anyString());
}
Also used : PInterface(org.onap.aai.domain.yang.PInterface) Optional(java.util.Optional) Port(org.openstack4j.model.network.Port) Network(org.openstack4j.model.network.Network) Resource(org.openstack4j.model.heat.Resource) HeatResource(org.openstack4j.openstack.heat.domain.HeatResource) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) List(java.util.List) L3InterfaceIpv6AddressList(org.onap.aai.domain.yang.L3InterfaceIpv6AddressList) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 7 with Resource

use of org.openstack4j.model.heat.Resource in project so by onap.

the class HeatBridgeImplTest method testBuildAddVolumes.

@Test
public void testBuildAddVolumes() throws HeatBridgeException {
    List<Resource> stackResources = (List<Resource>) extractTestStackResources();
    Volume volume = mock(Volume.class);
    List<VolumeAttachment> 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"));
}
Also used : VolumeAttachment(org.openstack4j.model.storage.block.VolumeAttachment) Optional(java.util.Optional) Volume(org.openstack4j.model.storage.block.Volume) Resource(org.openstack4j.model.heat.Resource) HeatResource(org.openstack4j.openstack.heat.domain.HeatResource) ArrayList(java.util.ArrayList) List(java.util.List) L3InterfaceIpv6AddressList(org.onap.aai.domain.yang.L3InterfaceIpv6AddressList) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)7 Resource (org.openstack4j.model.heat.Resource)7 List (java.util.List)6 Optional (java.util.Optional)6 Test (org.junit.Test)6 L3InterfaceIpv6AddressList (org.onap.aai.domain.yang.L3InterfaceIpv6AddressList)6 RelationshipList (org.onap.aai.domain.yang.RelationshipList)6 Network (org.openstack4j.model.network.Network)6 HeatResource (org.openstack4j.openstack.heat.domain.HeatResource)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)5 Port (org.openstack4j.model.network.Port)5 PInterface (org.onap.aai.domain.yang.PInterface)4 HashSet (java.util.HashSet)2 SriovPf (org.onap.aai.domain.yang.SriovPf)2 IP (org.openstack4j.model.network.IP)2 Subnet (org.openstack4j.model.network.Subnet)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 LInterface (org.onap.aai.domain.yang.LInterface)1 Results (org.onap.aaiclient.client.aai.entities.Results)1