Search in sources :

Example 11 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class AaiConnectionTest method testRelationshipData.

@Test
public void testRelationshipData() {
    // given
    final Relationship relationship = new Relationship();
    final RelationshipData data = new RelationshipData();
    data.setRelationshipKey(KEY);
    data.setRelationshipValue(VALUE);
    relationship.getRelationshipData().add(data);
    // when
    final String value = AaiConnection.getRelationshipData(relationship, KEY);
    // then
    assertEquals(VALUE, value);
}
Also used : RelationshipData(org.onap.aai.domain.yang.RelationshipData) Relationship(org.onap.aai.domain.yang.Relationship) Test(org.junit.Test)

Example 12 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class ServiceEBBLoaderTest method traverseAAIServiceTest.

@Test
public void traverseAAIServiceTest() {
    List<Resource> resourceCounter = new ArrayList<>();
    String resourceId = "si0";
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    ServiceInstance serviceInstanceAAI = new ServiceInstance();
    serviceInstanceAAI.setServiceInstanceId(resourceId);
    org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance();
    GenericVnf genericVnf = setGenericVnf();
    setVfModule(true);
    setVolumeGroup();
    setL3Network();
    setCollection();
    setConfiguration();
    org.onap.aai.domain.yang.GenericVnf genericVnfAai = new org.onap.aai.domain.yang.GenericVnf();
    genericVnfAai.setModelCustomizationId(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid());
    Configuration config = new Configuration();
    config.setConfigurationId("testConfigurationId2");
    serviceInstance.getConfigurations().add(config);
    Relationship relationship1 = new Relationship();
    relationship1.setRelatedTo("vnfc");
    RelationshipList relationshipList1 = new RelationshipList();
    relationshipList1.getRelationship().add(relationship1);
    Relationship relationship2 = new Relationship();
    relationship2.setRelatedTo("vpn-binding");
    RelationshipList relationshipList2 = new RelationshipList();
    relationshipList2.getRelationship().add(relationship2);
    org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration();
    aaiConfiguration1.setConfigurationId("testConfigurationId");
    aaiConfiguration1.setRelationshipList(relationshipList1);
    org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration();
    aaiConfiguration2.setConfigurationId("testConfigurationId2");
    aaiConfiguration2.setRelationshipList(relationshipList1);
    org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
    aaiVfModule.setIsBaseVfModule(true);
    try {
        doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId());
        doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId);
        doReturn(serviceInstance).when(mockBbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
        doReturn(Optional.of(aaiConfiguration1)).when(mockAaiConfigurationResources).getConfiguration("testConfigurationId");
        doReturn(Optional.of(aaiConfiguration2)).when(mockAaiConfigurationResources).getConfiguration("testConfigurationId2");
        doReturn(aaiVfModule).when(mockBbInputSetupUtils).getAAIVfModule(any(), any());
        serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
        assertEquals(8, resourceCounter.size());
        assertTrue(resourceCounter.get(2).isBaseVfModule());
        assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds()));
    } catch (Exception e) {
        fail("Unexpected exception was thrown.");
    }
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) Mockito.anyString(org.mockito.Mockito.anyString) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) ExpectedException(org.junit.rules.ExpectedException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Relationship(org.onap.aai.domain.yang.Relationship) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 13 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class ServiceEBBLoaderTest method traverseVrfConfigurationTest.

@Test
public void traverseVrfConfigurationTest() throws VrfBondingServiceException, JsonProcessingException {
    List<Resource> resource = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    Service service = new Service();
    List<ConfigurationResourceCustomization> resourceCustomizations = new ArrayList<>();
    ConfigurationResourceCustomization configuration = new ConfigurationResourceCustomization();
    configuration.setModelCustomizationUUID("123");
    resourceCustomizations.add(configuration);
    service.setConfigurationCustomizations(resourceCustomizations);
    Relationship relationship = new Relationship();
    relationship.setRelatedTo("vpn-binding");
    RelationshipList relationshipList = new RelationshipList();
    relationshipList.getRelationship().add(relationship);
    org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
    aaiLocalNetwork.setNetworkId("localNetworkId");
    aaiLocalNetwork.setRelationshipList(relationshipList);
    RelatedInstance relatedVpnBinding = new RelatedInstance();
    relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
    RelatedInstance relatedLocalNetwork = new RelatedInstance();
    relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
    doReturn(aaiLocalNetwork).when(mockBbInputSetupUtils).getAAIL3Network("localNetworkInstanceId");
    Resource serviceResource = new Resource(WorkflowType.SERVICE, "1", false, null);
    serviceEBBLoader.traverseVrfConfiguration(aaiResourceIds, resource, serviceResource, service, relatedVpnBinding, relatedLocalNetwork);
    assertEquals(resource.size(), 1);
    assertEquals(aaiResourceIds.size(), 0);
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) Relationship(org.onap.aai.domain.yang.Relationship) Pair(org.javatuples.Pair) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 14 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class HeatBridgeImplTest method testUpdateVserversToAai.

@Test
@Ignore
public void testUpdateVserversToAai() throws HeatBridgeException, JsonProcessingException {
    AaiHelper helper = new AaiHelper();
    helper.setAAIResourcesClient(resourcesClient);
    heatbridge.setAAIHelper(helper);
    VfModule module = new VfModule();
    RelationshipList relationships = new RelationshipList();
    List<Relationship> listRelationships = relationships.getRelationship();
    Relationship vnfcRelationship = new Relationship();
    vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
    vnfcRelationship.setRelatedTo("vnfc");
    vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
    listRelationships.add(vnfcRelationship);
    module.setRelationshipList(relationships);
    AAIResultWrapper wrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
    when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id")))).thenReturn(wrapper);
    // Arrange
    Server server1 = mock(Server.class);
    when(server1.getId()).thenReturn("test-server1-id");
    when(server1.getHypervisorHostname()).thenReturn("test-hypervisor");
    when(server1.getName()).thenReturn("test-server1-name");
    when(server1.getStatus()).thenReturn(Status.ACTIVE);
    when(server1.getLinks()).thenReturn(new ArrayList<>());
    Server server2 = mock(Server.class);
    when(server2.getId()).thenReturn("test-server2-id");
    when(server2.getHypervisorHostname()).thenReturn("");
    when(server2.getName()).thenReturn("test-server2-name");
    when(server2.getStatus()).thenReturn(Status.ACTIVE);
    when(server2.getLinks()).thenReturn(new ArrayList<>());
    List<Server> servers = Arrays.asList(server1, server2);
    Image image = mock(Image.class);
    when(server1.getImage()).thenReturn(image);
    when(server2.getImage()).thenReturn(image);
    when(image.getId()).thenReturn("test-image-id");
    Flavor flavor = mock(Flavor.class);
    when(server1.getFlavor()).thenReturn(flavor);
    when(server2.getFlavor()).thenReturn(flavor);
    when(flavor.getId()).thenReturn("test-flavor-id");
    // Act
    heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers);
    // Assert
    ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
    verify(transaction, times(2)).create(captor.capture(), any());
    List<AAIResourceUri> uris = captor.getAllValues();
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server1.getId())), uris.get(0));
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server2.getId())), uris.get(1));
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) AaiHelper(org.onap.so.heatbridge.helpers.AaiHelper) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Image(org.openstack4j.model.compute.Image) VfModule(org.onap.aai.domain.yang.VfModule) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Flavor(org.openstack4j.model.compute.Flavor) Relationship(org.onap.aai.domain.yang.Relationship) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class HeatBridgeImplTest method testUpdateVserversToAaiNoHypervisorName.

@Test
@Ignore
public void testUpdateVserversToAaiNoHypervisorName() throws HeatBridgeException, JsonProcessingException {
    AaiHelper aaiHelper = new AaiHelper();
    VfModule module = new VfModule();
    RelationshipList relationships = new RelationshipList();
    List<Relationship> listRelationships = relationships.getRelationship();
    Relationship vnfcRelationship = new Relationship();
    vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
    vnfcRelationship.setRelatedTo("vnfc");
    vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
    listRelationships.add(vnfcRelationship);
    module.setRelationshipList(relationships);
    AAIResultWrapper wrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
    when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id")))).thenReturn(wrapper);
    aaiHelper.setAAIResourcesClient(aaiResourcesClient);
    heatbridge.setAAIHelper(aaiHelper);
    // Arrange
    Server server1 = mock(Server.class);
    when(server1.getId()).thenReturn("test-server1-id");
    when(server1.getHypervisorHostname()).thenReturn("");
    when(server1.getName()).thenReturn("test-server1-name");
    when(server1.getStatus()).thenReturn(Status.ACTIVE);
    when(server1.getLinks()).thenReturn(new ArrayList<>());
    Server server2 = mock(Server.class);
    when(server2.getId()).thenReturn("test-server2-id");
    when(server2.getName()).thenReturn("test-server2-name");
    when(server2.getStatus()).thenReturn(Status.ACTIVE);
    when(server2.getLinks()).thenReturn(new ArrayList<>());
    List<Server> servers = Arrays.asList(server1, server2);
    Image image = mock(Image.class);
    when(server1.getImage()).thenReturn(image);
    when(server2.getImage()).thenReturn(image);
    when(image.getId()).thenReturn("test-image-id");
    Flavor flavor = mock(Flavor.class);
    when(server1.getFlavor()).thenReturn(flavor);
    when(server2.getFlavor()).thenReturn(flavor);
    when(flavor.getId()).thenReturn("test-flavor-id");
    // Act
    heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers);
    // Assert
    ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
    verify(transaction, times(2)).create(captor.capture(), any());
    List<AAIResourceUri> uris = captor.getAllValues();
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server1.getId())), uris.get(0));
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server2.getId())), uris.get(1));
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) AaiHelper(org.onap.so.heatbridge.helpers.AaiHelper) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Image(org.openstack4j.model.compute.Image) VfModule(org.onap.aai.domain.yang.VfModule) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Flavor(org.openstack4j.model.compute.Flavor) Relationship(org.onap.aai.domain.yang.Relationship) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Relationship (org.onap.aai.domain.yang.Relationship)28 Test (org.junit.Test)11 RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)6 VfModule (org.onap.aai.domain.yang.VfModule)5 ArrayList (java.util.ArrayList)4 GenericVnf (org.onap.aai.domain.yang.GenericVnf)4 RelationshipData (org.onap.aai.domain.yang.RelationshipData)4 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)4 Server (org.openstack4j.model.compute.Server)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 IOException (java.io.IOException)2 List (java.util.List)2