Search in sources :

Example 1 with VfModules

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

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

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

Example 4 with VfModules

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

the class AAIDataRetrieval method getVfModulesOfVnf.

public List<VfModule> getVfModulesOfVnf(String vnfId) {
    List<VfModule> vfModuleList = new ArrayList<VfModule>();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModules());
    Optional<VfModules> vfModules = getAaiResourcesClient().get(VfModules.class, uri);
    if (!vfModules.isPresent() || vfModules.get().getVfModule().isEmpty()) {
        logger.debug("No VfModules attached to Vnf in AAI : {}", vnfId);
    } else {
        vfModuleList = vfModules.get().getVfModule();
    }
    return vfModuleList;
}
Also used : VfModules(org.onap.aai.domain.yang.VfModules) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) ArrayList(java.util.ArrayList) VfModule(org.onap.aai.domain.yang.VfModule)

Example 5 with VfModules

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

the class AaiResourceIdValidatorTest method validateResourceIdInAAIVfModuleTest.

@Test
public void validateResourceIdInAAIVfModuleTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setVnfId("id123");
    GenericVnf vnf = new GenericVnf();
    VfModules vfModules = new VfModules();
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("id123");
    vfModule.setVfModuleName("name123");
    vfModule.setModelCustomizationId("1234567");
    vfModules.getVfModule().add(vfModule);
    vnf.setVfModules(vfModules);
    when(bbInputSetupUtilsMock.getAAIGenericVnf("id123")).thenReturn(vnf);
    String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails, workflowResourceIds);
    assertEquals("id123", id);
    GenericVnf vnf1 = new GenericVnf();
    VfModules vfModules2 = new VfModules();
    VfModule vfModule2 = new VfModule();
    vfModule2.setVfModuleName("vFModName222");
    vfModule2.setModelCustomizationId("222");
    vfModules2.getVfModule().add(vfModule2);
    vnf1.setVfModules(vfModules2);
    workflowResourceIds.setVnfId("id111");
    when(bbInputSetupUtilsMock.getAAIGenericVnf("id111")).thenReturn(vnf1);
    String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails, workflowResourceIds);
    assertEquals("generatedId123", id2);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique."));
    testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails, workflowResourceIds);
}
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)7 VfModules (org.onap.aai.domain.yang.VfModules)7 Test (org.junit.Test)5 GenericVnf (org.onap.aai.domain.yang.GenericVnf)3 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)3 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)3 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ArrayList (java.util.ArrayList)1