Search in sources :

Example 1 with VfModule

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

the class BpmnRequestBuilder method buildVFModuleDeleteRequest.

public ServiceInstancesRequest buildVFModuleDeleteRequest(String vnfId, String vfModuleId, ModelType modelType) throws AAIEntityNotFound {
    GenericVnf vnf = aaiDataRet.getGenericVnf(vnfId);
    if (vnf == null) {
        throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId);
    }
    VfModule vfModule = aaiDataRet.getAAIVfModule(vnfId, vfModuleId);
    if (vfModule == null) {
        throw new AAIEntityNotFound(VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " vfModuleId: " + vfModuleId);
    }
    return createServiceInstancesRequest(vnf, vfModule, modelType);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) AAIEntityNotFound(org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound) VfModule(org.onap.aai.domain.yang.VfModule)

Example 2 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 3 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 4 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 5 with VfModule

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

the class AaiResourceIdValidatorTest method validateVfModuleResourceIdSameModelCustIdTest.

@Test
public void validateVfModuleResourceIdSameModelCustIdTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setVnfId("vnfId123");
    VfModules vfModules = new VfModules();
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("id123");
    vfModule.setVfModuleName("name123");
    vfModule.setModelCustomizationId("1234567");
    vfModules.getVfModule().add(vfModule);
    GenericVnf vnf = new GenericVnf();
    vnf.setVfModules(vfModules);
    when(bbInputSetupUtilsMock.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
    String id = testedObject.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
    assertEquals("id123", id);
}
Also used : VfModules(org.onap.aai.domain.yang.VfModules) GenericVnf(org.onap.aai.domain.yang.GenericVnf) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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)

Aggregations

VfModule (org.onap.aai.domain.yang.VfModule)40 Test (org.junit.Test)35 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 RelationshipList (org.onap.aai.domain.yang.RelationshipList)22 GenericVnf (org.onap.aai.domain.yang.GenericVnf)21 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