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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations