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