use of org.onap.so.adapters.vnfrest.DeleteVfModuleRequest in project so by onap.
the class VnfAdapterDeleteTasks method deleteVfModule.
public void deleteVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
DeleteVfModuleRequest deleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, genericVnf, vfModule);
execution.setVariable(VNFREST_REQUEST, deleteVfModuleRequest.toXmlString());
execution.setVariable("deleteVfModuleRequest", "true");
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.adapters.vnfrest.DeleteVfModuleRequest in project so by onap.
the class VnfAdapterDeleteTasksTest method test_deleteVfModule.
@Test
public void test_deleteVfModule() throws Exception {
DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
deleteVfModuleRequest.setVfModuleId("vfModuleId");
doReturn(deleteVfModuleRequest).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
vnfAdapterDeleteTasks.deleteVfModule(execution);
verify(vnfAdapterVfModuleResources, times(1)).deleteVfModuleRequest(ArgumentMatchers.eq(requestContext), ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(genericVnf), ArgumentMatchers.eq(vfModule));
assertEquals(execution.getVariable("VNFREST_Request"), deleteVfModuleRequest.toXmlString());
}
use of org.onap.so.adapters.vnfrest.DeleteVfModuleRequest in project so by onap.
the class VnfAdapterVfModuleObjectMapperPayloadTest method DeleteVfModuleRequestMapperTest.
@Test
public void DeleteVfModuleRequestMapperTest() throws Exception {
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
modelInfoServiceInstance.setModelName("serviceModelName");
modelInfoServiceInstance.setModelUuid("serviceModelUuid");
modelInfoServiceInstance.setModelVersion("serviceModelVersion");
modelInfoServiceInstance.setEnvironmentContext("environmentContext");
modelInfoServiceInstance.setWorkloadContext("workloadContext");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<>();
userParams.put("key1", "value1");
requestContext.setMsoRequestId("requestId");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
vnf.setVnfType("vnfType");
vnf.setVnfName("vnfName");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
vfModule.setVfModuleName("vfModuleName");
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(false);
DeleteVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, vnf, vfModule);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterDeleteVfModuleRequest.json")));
DeleteVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, DeleteVfModuleRequest.class);
assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId"));
}
use of org.onap.so.adapters.vnfrest.DeleteVfModuleRequest in project so by onap.
the class VnfAdapterClientIT method deleteVfModuleTest.
@Test
public void deleteVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
DeleteVfModuleRequest request = new DeleteVfModuleRequest();
request.setCloudSiteId(TESTING_ID);
DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
mockResponse.setVfModuleDeleted(true);
wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
DeleteVfModuleResponse response = client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
assertEquals("Testing DeleteVfModule response", true, response.getVfModuleDeleted());
}
use of org.onap.so.adapters.vnfrest.DeleteVfModuleRequest in project so by onap.
the class VnfAdapterVfModuleObjectMapperTest method test_deleteVfModuleNoHeatIdRequestMapper.
@Test
public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception {
DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest();
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
cloudRegion.setTenantId("tenantId");
expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
GenericVnf genericVnf = new GenericVnf();
VfModule vfModule = new VfModule();
vfModule.setHeatStackId("heatStackId");
expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId");
expectedDeleteVfModuleRequest.setSkipAAI(true);
MsoRequest msoRequest = new MsoRequest();
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId("msoRequestId");
msoRequest.setRequestId(requestContext.getMsoRequestId());
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedDeleteVfModuleRequest.setMsoRequest(msoRequest);
String messageId = "messageId";
String endpoint = "endpoint";
doNothing().when(mapper).setIdAndUrl(any());
expectedDeleteVfModuleRequest.setMessageId(messageId);
expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
DeleteVfModuleRequest actualDeleteVfModuleRequest = mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
assertThat(actualDeleteVfModuleRequest, sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl"));
}
Aggregations