Search in sources :

Example 6 with DeleteNetworkRequest

use of org.onap.so.adapters.nwrest.DeleteNetworkRequest in project so by onap.

the class NetworkAdapterDeleteTasks method deleteNetwork.

public void deleteNetwork(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network);
        execution.setVariable("networkAdapterRequest", deleteNetworkRequest.toXmlString());
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 7 with DeleteNetworkRequest

use of org.onap.so.adapters.nwrest.DeleteNetworkRequest in project so by onap.

the class NetworkAdapterObjectMapperTest method deleteNetworkRequestMapperTest.

@Test
public void deleteNetworkRequestMapperTest() throws Exception {
    DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
    String messageId = "messageId";
    expectedDeleteNetworkRequest.setMessageId(messageId);
    doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    l3Network.setModelInfoNetwork(modelInfoNetwork);
    modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
    expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setRequestId(requestContext.getMsoRequestId());
    msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
    expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
    expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
    l3Network.setHeatStackId("heatStackId");
    expectedDeleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
    expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
    expectedDeleteNetworkRequest.setSkipAAI(true);
    expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
    expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
    expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
    doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
    doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
    DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
    assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
}
Also used : DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) MsoRequest(org.onap.so.entity.MsoRequest) Test(org.junit.Test)

Example 8 with DeleteNetworkRequest

use of org.onap.so.adapters.nwrest.DeleteNetworkRequest in project so by onap.

the class NetworkAdapterClientIT method deleteNetworkTestThrowException.

@Test(expected = NetworkAdapterClientException.class)
public void deleteNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
    DeleteNetworkRequest request = new DeleteNetworkRequest();
    request.setCloudSiteId(TESTING_ID);
    DeleteNetworkError mockResponse = new DeleteNetworkError();
    mockResponse.setMessage("Error in delete network");
    wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
    client.deleteNetwork(AAI_NETWORK_ID, request);
}
Also used : DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) DeleteNetworkError(org.onap.so.adapters.nwrest.DeleteNetworkError) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 9 with DeleteNetworkRequest

use of org.onap.so.adapters.nwrest.DeleteNetworkRequest in project so by onap.

the class NetworkAdapterResourcesTest method deleteNetwork_DeleteAction_Test.

@Test
public void deleteNetwork_DeleteAction_Test() throws UnsupportedEncodingException, NetworkAdapterClientException {
    DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
    doReturn(deleteNetworkRequest).when(MOCK_networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
    DeleteNetworkResponse expectedDeleteNetworkResponse = new DeleteNetworkResponse();
    doReturn(expectedDeleteNetworkResponse).when(MOCK_networkAdapterClient).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
    Optional<DeleteNetworkResponse> actualODeleteNetworkResponse = networkAdapterResources.deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
    DeleteNetworkResponse actualDeleteNetworkResponse = actualODeleteNetworkResponse.get();
    verify(MOCK_networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
    verify(MOCK_networkAdapterClient, times(1)).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
    assertThat(expectedDeleteNetworkResponse, Matchers.sameBeanAs(actualDeleteNetworkResponse));
}
Also used : DeleteNetworkResponse(org.onap.so.adapters.nwrest.DeleteNetworkResponse) DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) Test(org.junit.Test)

Example 10 with DeleteNetworkRequest

use of org.onap.so.adapters.nwrest.DeleteNetworkRequest in project so by onap.

the class NetworkAdapterDeleteTasksTest method test_deleteNetwork.

@Test
public void test_deleteNetwork() {
    DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
    doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
    networkAdapterDeleteTasks.deleteNetwork(execution);
    verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
}
Also used : DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) Test(org.junit.Test)

Aggregations

DeleteNetworkRequest (org.onap.so.adapters.nwrest.DeleteNetworkRequest)10 Test (org.junit.Test)6 DeleteNetworkResponse (org.onap.so.adapters.nwrest.DeleteNetworkResponse)3 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)3 StringReader (java.io.StringReader)2 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 MsoRequest (org.onap.so.entity.MsoRequest)2 HashMap (java.util.HashMap)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)1 DeleteNetworkError (org.onap.so.adapters.nwrest.DeleteNetworkError)1 RollbackNetworkRequest (org.onap.so.adapters.nwrest.RollbackNetworkRequest)1 UpdateNetworkRequest (org.onap.so.adapters.nwrest.UpdateNetworkRequest)1 UpdateNetworkResponse (org.onap.so.adapters.nwrest.UpdateNetworkResponse)1 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)1 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)1 DeleteVfModuleRequest (org.onap.so.adapters.vnfrest.DeleteVfModuleRequest)1 DeleteVfModuleResponse (org.onap.so.adapters.vnfrest.DeleteVfModuleResponse)1 DeleteVolumeGroupRequest (org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest)1 DeleteVolumeGroupResponse (org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse)1