@Test public void deleteResourcesShouldNotThrowExceptionWhenVolumeDoesNotExistAtDeletion() { String encryptedVolumeId = "vol-12345678"; String encryptedSnapshotId = "snap-12345678"; 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()); String eMsg = String.format("An error occurred (%s) when calling the DeleteVolume operation: The volume '%s' does not exist.", VOLUME_NOT_FOUND_MSG_CODE, encryptedVolumeId); when(ec2Client.deleteVolume(any())).thenThrow(new AmazonServiceException(eMsg)); underTest.deleteResources(authenticatedContext, ec2Client, resources); verify(ec2Client, times(1)).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);  }