Source:
<code>public void testAttachmentAtBoot() { <START> if (volumeApi.isPresent()) { <END> String server_id = null; try { CreateServerOptions createServerOptions = CreateServerOptions.Builder.blockDeviceMapping( Collections.singletonList(new BlockDeviceMapping().deviceName("/dev/vdf").volumeId(testVolume.getId()))); final String serverId = server_id = createServerInZone(zone, createServerOptions).getId(); Set<? extends VolumeAttachment> attachments = volumeAttachmentApi.get().listAttachmentsOnServer(serverId).toSet(); assertNotNull(attachments); assertEquals(volumeApi.get().get(testVolume.getId()).getStatus(), Volume.Status.IN_USE); final int before = attachments.size(); boolean foundIt = false; for (VolumeAttachment att : attachments) { VolumeAttachment details = volumeAttachmentApi.get() .getAttachmentForVolumeOnServer(att.getVolumeId(), serverId); assertNotNull(details); assertNotNull(details.getId()); assertNotNull(details.getServerId()); assertNotNull(details.getVolumeId()); if (Objects.equal(details.getVolumeId(), testVolume.getId())) { foundIt = true; assertEquals(details.getDevice(), "/dev/vdf"); assertEquals(details.getServerId(), serverId); } } assertTrue(foundIt, "Failed to find the attachment we set in listAttachments() response"); volumeAttachmentApi.get().detachVolumeFromServer(testVolume.getId(), serverId); assertTrue(retry(new Predicate<VolumeAttachmentApi>() { public boolean apply(VolumeAttachmentApi volumeAttachmentApi) { return volumeAttachmentApi.listAttachmentsOnServer(serverId).size() == before - 1; } }, 60 * 1000L).apply(volumeAttachmentApi.get())); } finally { if (server_id != null) api.getServerApiForZone(zone).delete(server_id); } } }</code><technical_language>need this if? If volumeApi is _not_ present, testCreateVolume fail skipped</technical_language>

Target:
public void testAttachmentAtBoot() { if (volumeApi.isPresent()) { String server_id = null; BlockDeviceMapping blockDeviceMapping = BlockDeviceMapping.createOptions(testVolume.getId(), "/dev/vdf").build(); try { CreateServerOptions createServerOptions = CreateServerOptions.Builder.blockDeviceMapping(ImmutableSet.of(blockDeviceMapping)); final String serverId = server_id = createServerInRegion(region, createServerOptions).getId(); Set<? extends VolumeAttachment> attachments = volumeAttachmentApi.get() .listAttachmentsOnServer(serverId).toSet(); VolumeAttachment attachment = Iterables.getOnlyElement(attachments); VolumeAttachment details = volumeAttachmentApi.get() .getAttachmentForVolumeOnServer(attachment.getVolumeId(), serverId); assertNotNull(details.getId()); assertEquals(details.getVolumeId(), testVolume.getId()); assertEquals(details.getDevice(), "/dev/vdf"); assertEquals(details.getServerId(), serverId); assertEquals(volumeApi.get().get(testVolume.getId()).getStatus(), Volume.Status.IN_USE); assertTrue(volumeAttachmentApi.get().detachVolumeFromServer(testVolume.getId(), serverId), "Could not detach volume " + testVolume.getId() + " from server " + serverId); assertEquals(volumeAttachmentApi.get().listAttachmentsOnServer(serverId).size(), 0, "Number of volumes on server " + serverId + " was not zero."); } finally { if (server_id != null) { api.getServerApi(region).delete(server_id); } } } }