DigitalOceanApi api = api(server.getUrl("/"));
ImageApi imageApi = api.getImageApi();
try {
Image image = imageApi.get(1);
assertRequestHasCommonFields(server.takeRequest(), "/images/1");
assertNotNull(image);
assertEquals(image.getId(), 1);
assertEquals(image.getOs().getDistribution(), Distribution.ARCHLINUX);
assertEquals(image.getOs().getVersion(), "2013.05");
assertEquals(image.getOs().getArch(), "x32");
assertEquals(image.getName(), "Arch Linux 2013.05 x32");
assertTrue(image.isPublicImage());
assertEquals(image.getSlug(), "arch-linux-x32");
image = imageApi.get(2);
assertRequestHasCommonFields(server.takeRequest(), "/images/2");
assertNotNull(image);
assertEquals(image.getId(), 2);
assertEquals(image.getOs().getDistribution(), Distribution.FEDORA);
assertEquals(image.getOs().getVersion(), "17");
assertEquals(image.getOs().getArch(), "x64");
assertEquals(image.getName(), "Fedora 17 x64 Desktop");
assertTrue(image.isPublicImage());
assertEquals(image.getSlug(), "fedora-17-x64");
image = imageApi.get(3);
assertRequestHasCommonFields(server.takeRequest(), "/images/3");
assertNotNull(image);
assertNull(image.getSlug());
assertEquals(image.getId(), 3);
assertEquals(image.getOs().getDistribution(), Distribution.UBUNTU);
assertEquals(image.getOs().getVersion(), "13.04");
assertEquals(image.getOs().getArch(), "");
assertEquals(image.getName(), "Dokku on Ubuntu 13.04 0.2.0rc3");
assertTrue(image.isPublicImage());
assertNull(image.getSlug());
image = imageApi.get("fedora-17-x64");
assertRequestHasCommonFields(server.takeRequest(), "/images/fedora-17-x64");
assertNotNull(image);
assertEquals(image.getId(), 2);
assertEquals(image.getOs().getDistribution(), Distribution.FEDORA);
assertEquals(image.getOs().getVersion(), "17");
assertEquals(image.getOs().getArch(), "x64");
assertEquals(image.getName(), "Fedora 17 x64 Desktop");
assertTrue(image.isPublicImage());
assertEquals(image.getSlug(), "fedora-17-x64");
} finally {
api.close();
server.shutdown();
}
}