Search in sources :

Example 16 with VfModule

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

the class AaiResourceIdValidatorTest method validateVfModuleResourceIdDifferentModelCustIdTest.

@Test
public void validateVfModuleResourceIdDifferentModelCustIdTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setVnfId("vnfId123");
    VfModules vfModules = new VfModules();
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleName("name123");
    vfModule.setModelCustomizationId("9999999");
    vfModules.getVfModule().add(vfModule);
    GenericVnf vnf = new GenericVnf();
    vnf.setVfModules(vfModules);
    when(bbInputSetupUtilsMock.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("vfModule with name (name123), same parent and different customization id (1234567) already exists. The name must be unique."));
    testedObject.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
}
Also used : VfModules(org.onap.aai.domain.yang.VfModules) GenericVnf(org.onap.aai.domain.yang.GenericVnf) VfModule(org.onap.aai.domain.yang.VfModule) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Example 17 with VfModule

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

the class AAIDataRetrievalTest method getVfModulesOfVnfTest.

@Test
public void getVfModulesOfVnfTest() {
    VfModules vfModules = getVfModules();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules());
    doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
    List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
    assertEquals("vfm1", vfModulesList.get(0).getVfModuleId());
    Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId");
    assertEquals(Optional.of("vfm1,vfm2"), vfModuleIds);
}
Also used : VfModules(org.onap.aai.domain.yang.VfModules) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) VfModule(org.onap.aai.domain.yang.VfModule) Test(org.junit.Test)

Example 18 with VfModule

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

the class BpmnRequestBuilderTest method test_buildVFModuleDeleteRequest.

@Test
public void test_buildVFModuleDeleteRequest() throws Exception {
    GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
    doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
    VfModule vfModule = provider.getMapper().readValue(new File(RESOURCE_PATH + "VfModule.json"), VfModule.class);
    doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModule("vfModuleId")));
    ServiceInstancesRequest expectedRequest = mapper.readValue(new File(RESOURCE_PATH + "ExpectedVfModuleRequest.json"), ServiceInstancesRequest.class);
    ServiceInstancesRequest actualRequest = reqBuilder.buildVFModuleDeleteRequest("vnfId", "vfModuleId", ModelType.vfModule);
    assertThat(actualRequest, sameBeanAs(expectedRequest));
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) File(java.io.File) VfModule(org.onap.aai.domain.yang.VfModule) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Example 19 with VfModule

use of org.onap.aai.domain.yang.VfModule 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 20 with VfModule

use of org.onap.aai.domain.yang.VfModule 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

VfModule (org.onap.aai.domain.yang.VfModule)46 Test (org.junit.Test)39 ArrayList (java.util.ArrayList)26 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)26 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)25 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)24 List (java.util.List)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 GenericVnf (org.onap.aai.domain.yang.GenericVnf)22 RelationshipList (org.onap.aai.domain.yang.RelationshipList)22 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)19 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)19 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)15 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)12 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)12 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)12 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)11 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)10 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)8