use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class GcpNetworkConnectorTest method testDeleteNetworkWithSubnetsWhenDeletionGoesFine.
@Test
public void testDeleteNetworkWithSubnetsWhenDeletionGoesFine() throws Exception {
NetworkDeletionRequest networkDeletionRequest = new NetworkDeletionRequest.Builder().withAccountId("account-id").withEnvName("super-env").withRegion("us-west-1").withSubnetIds(Set.of("subnet-1")).build();
GcpContext gcpContext = mock(GcpContext.class);
PollTask pollTask = mock(PollTask.class);
CloudResource cloudResource = mock(CloudResource.class);
when(contextBuilders.contextInit(any(CloudContext.class), any(AuthenticatedContext.class), any(Network.class), any(), anyBoolean())).thenReturn(gcpContext);
when(statusCheckFactory.newPollResourceTask(any(ResourceChecker.class), any(AuthenticatedContext.class), anyList(), any(ResourceBuilderContext.class), anyBoolean())).thenReturn(pollTask);
when(syncPollingScheduler.schedule(any(PollTask.class))).thenReturn(new ArrayList());
when(gcpSubnetResourceBuilder.delete(any(GcpContext.class), any(AuthenticatedContext.class), any(CloudResource.class), any(Network.class))).thenReturn(cloudResource);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(gcpSubnetResourceBuilder, times(1)).delete(any(GcpContext.class), any(AuthenticatedContext.class), any(CloudResource.class), any(Network.class));
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AzureNetworkConnectorTest method testDeleteNetworkWithSubnetsShouldThrowAnExceptionWhenTheStackDeletionFailed.
@Test(expected = CloudConnectorException.class)
public void testDeleteNetworkWithSubnetsShouldThrowAnExceptionWhenTheStackDeletionFailed() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest(false, false);
when(azureClient.getResourceGroup(networkDeletionRequest.getResourceGroup())).thenReturn(mock(ResourceGroup.class));
when(azureClientService.getClient(networkDeletionRequest.getCloudCredential())).thenReturn(azureClient);
when(azureUtils.convertToCloudConnectorException(any(CloudException.class), anyString())).thenReturn(new CloudConnectorException(""));
doThrow(createCloudException()).when(azureClient).deleteTemplateDeployment(RESOURCE_GROUP, STACK);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AzureNetworkConnectorTest method testDeleteNetworkWithSubnetsShouldDeleteNothingWhenExistingNetwork.
@Test
public void testDeleteNetworkWithSubnetsShouldDeleteNothingWhenExistingNetwork() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest(true, false);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(azureClient, never()).deleteTemplateDeployment(RESOURCE_GROUP, STACK);
verify(azureClient, never()).deleteResourceGroup(RESOURCE_GROUP);
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AzureNetworkConnectorTest method testDeleteNetworkWithSubnetsShouldCancelDeploymentIfTransientWhenSingleResourceGroup.
@Test
public void testDeleteNetworkWithSubnetsShouldCancelDeploymentIfTransientWhenSingleResourceGroup() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest(false, true);
when(azureClientService.getClient(networkDeletionRequest.getCloudCredential())).thenReturn(azureClient);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(azureClient).deleteNetworkInResourceGroup(RESOURCE_GROUP, NETWORK_ID);
verify(azureClient, never()).deleteResourceGroup(RESOURCE_GROUP);
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AzureNetworkConnectorTest method testDeleteNetworkWithSubnetsShouldDeleteTheStackAndTheResourceGroupWhenNotExistingNetwork.
@Test
public void testDeleteNetworkWithSubnetsShouldDeleteTheStackAndTheResourceGroupWhenNotExistingNetwork() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest(false, false);
when(azureClient.getResourceGroup(networkDeletionRequest.getResourceGroup())).thenReturn(mock(ResourceGroup.class));
when(azureClientService.getClient(networkDeletionRequest.getCloudCredential())).thenReturn(azureClient);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(azureClient).deleteTemplateDeployment(RESOURCE_GROUP, STACK);
verify(azureClient).deleteResourceGroup(RESOURCE_GROUP);
}
Aggregations