Search in sources :

Example 1 with DeleteVfModuleRequest

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);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest)

Example 2 with DeleteVfModuleRequest

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());
}
Also used : DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest) Test(org.junit.Test)

Example 3 with DeleteVfModuleRequest

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"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 4 with DeleteVfModuleRequest

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());
}
Also used : DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest) DeleteVfModuleResponse(org.onap.so.adapters.vnfrest.DeleteVfModuleResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 5 with DeleteVfModuleRequest

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"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) MsoRequest(org.onap.so.entity.MsoRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest) Test(org.junit.Test)

Aggregations

DeleteVfModuleRequest (org.onap.so.adapters.vnfrest.DeleteVfModuleRequest)11 Test (org.junit.Test)6 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)4 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)4 HashMap (java.util.HashMap)3 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)3 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)3 StringReader (java.io.StringReader)2 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)2 DeleteVfModuleResponse (org.onap.so.adapters.vnfrest.DeleteVfModuleResponse)2 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)2 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)2 MsoRequest (org.onap.so.entity.MsoRequest)2 Map (java.util.Map)1 Holder (javax.xml.ws.Holder)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1 Before (org.junit.Before)1 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)1