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