@Test(dataProvider = "notDetachedStatuses") public void testWithDifferentStatus(Status attachmentStatus) { Attachment attachment = newAttachmentWithStatus(attachmentStatus); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertFalse(volumeDetached.apply(attachment)); verify(client); }
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return true; } Attachment lastAttachment = getLast(volume.getAttachments()); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.DETACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.DETACHED; }
VolumeDetached implements Predicate<Attachment> { public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return true; } Attachment lastAttachment = getLast(volume.getAttachments()); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.DETACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.DETACHED; } }
VolumeDetached implements Predicate<Attachment> { public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return true; } Attachment lastAttachment = getLast(volume.getAttachments()); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.DETACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.DETACHED; } @Inject  VolumeDetached(ElasticBlockStoreApi client); }
VolumeDetached implements Predicate<Attachment> { public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return true; } Attachment lastAttachment = getLast(volume.getAttachments()); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.DETACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.DETACHED; } @Inject  VolumeDetached(ElasticBlockStoreApi client); boolean apply(Attachment attachment); }
VolumeDetached implements Predicate<Attachment> { public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return true; } Attachment lastAttachment = getLast(volume.getAttachments()); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.DETACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.DETACHED; } @Inject  VolumeDetached(ElasticBlockStoreApi client); boolean apply(Attachment attachment);  }