public void testGetImageBySlug() { Optional<Image> first = api().list().concat().firstMatch(new Predicate<Image>() { @Override public boolean apply(Image input) { return !isNullOrEmpty(input.slug()); } }); assertTrue(first.isPresent(), "At least one image with the 'slug' field set was expected to exist"); assertNotNull(api().get(first.get().slug())); }
public void testListImages() { final AtomicInteger found = new AtomicInteger(0); // DigitalOcean return 25 records per page by default. Inspect at most 2 pages assertTrue(api().list().concat().limit(50).allMatch(new Predicate<Image>() { @Override public boolean apply(Image input) { found.incrementAndGet(); return !isNullOrEmpty(input.name()); } }), "All images must have the 'name' field populated"); assertTrue(found.get() > 0, "Expected some images to be returned"); }
public void testListImagesOnePage() { final AtomicInteger found = new AtomicInteger(0); assertTrue(api().list(page(1).perPage(5)).allMatch(new Predicate<Image>() { @Override public boolean apply(Image input) { found.incrementAndGet(); return !isNullOrEmpty(input.name()); } }), "All images must have the 'name' field populated"); assertTrue(found.get() > 0, "Expected some images to be returned"); }
public void testListImagesByType() { final AtomicInteger found = new AtomicInteger(0); assertTrue(api().list(type("distribution").perPage(5)).allMatch(new Predicate<Image>() { @Override public boolean apply(Image input) { found.incrementAndGet(); return !isNullOrEmpty(input.distribution()); } }), "All images must have the 'distribution' field populated"); assertTrue(found.get() > 0, "Expected some images to be returned"); }