@Test public void deleteResourcesShouldThrowExceptionWhenVolumeDeletionFails() { thrown.expect(CloudConnectorException.class); String encryptedVolumeId = "vol-12345678"; String encryptedVolumeId2 = "vol-123456789"; String encryptedSnapshotId = "snap-12345678"; String encryptedSnapshotId2 = "snap-12345679"; List<CloudResource> resources = List.of( new CloudResource.Builder() .name(encryptedVolumeId) .type(ResourceType.AWS_ENCRYPTED_VOLUME) .build(), new CloudResource.Builder() .name(encryptedSnapshotId) .type(ResourceType.AWS_SNAPSHOT) .build(), new CloudResource.Builder() .name(encryptedVolumeId2) .type(ResourceType.AWS_ENCRYPTED_VOLUME) .build(), new CloudResource.Builder() .name(encryptedSnapshotId2) .type(ResourceType.AWS_SNAPSHOT) .build()); when(ec2Client.deleteSnapshot(any())) .thenThrow(new AmazonServiceException("Something went wrong or your credentials has been expired")); underTest.deleteResources(authenticatedContext, ec2Client, resources); verify(ec2Client, times(2)).deleteSnapshot(any()); verify(ec2Client, times(1)).deleteVolume(any()); }
public void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources) { LOGGER.debug("Deleting attached EBS volume encryption related resources: {}", ac.getCloudContext().getId()); if (resources != null && !resources.isEmpty()) { deleteSnapshotResources(client, resources); deleteVolumeResources(client, resources); } }
EncryptedSnapshotService { public void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources) { LOGGER.debug("Deleting attached EBS volume encryption related resources: {}", ac.getCloudContext().getId()); if (resources != null && !resources.isEmpty()) { deleteSnapshotResources(client, resources); deleteVolumeResources(client, resources); } } }
EncryptedSnapshotService { public void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources) { LOGGER.debug("Deleting attached EBS volume encryption related resources: {}", ac.getCloudContext().getId()); if (resources != null && !resources.isEmpty()) { deleteSnapshotResources(client, resources); deleteVolumeResources(client, resources); } }  }
EncryptedSnapshotService { public void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources) { LOGGER.debug("Deleting attached EBS volume encryption related resources: {}", ac.getCloudContext().getId()); if (resources != null && !resources.isEmpty()) { deleteSnapshotResources(client, resources); deleteVolumeResources(client, resources); } }  boolean isEncryptedVolumeRequested(Group group); Optional<String> createSnapshotIfNeeded(AuthenticatedContext ac, CloudStack cloudStack, Group group, PersistenceNotifier resourceNotifier); void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources); }
EncryptedSnapshotService { public void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources) { LOGGER.debug("Deleting attached EBS volume encryption related resources: {}", ac.getCloudContext().getId()); if (resources != null && !resources.isEmpty()) { deleteSnapshotResources(client, resources); deleteVolumeResources(client, resources); } }  boolean isEncryptedVolumeRequested(Group group); Optional<String> createSnapshotIfNeeded(AuthenticatedContext ac, CloudStack cloudStack, Group group, PersistenceNotifier resourceNotifier); void deleteResources(AuthenticatedContext ac, AmazonEC2Client client, List<CloudResource> resources);  }