@Override protected IterableWithMarker<Key> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { return api.keyApi().list(options); } }
@Override protected IterableWithMarker<Key> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { return api.keyApi().list(options); } }
@Override protected IterableWithMarker<Key> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { return api.keyApi().list(options); } }
@Test(dependsOnMethods = "testCreateKey") public void testListKeys() { FluentIterable<Key> keys = api().list().concat(); assertTrue(keys.size() >= 2, "At least the two created keys must exist"); }
@Test(dependsOnMethods = "testCreateKey") public void testListKeysOnePAge() { FluentIterable<Key> keys = api().list(page(1)); assertTrue(keys.size() >= 2, "At least the two created keys must exist"); }
public void testListKeysReturns404() throws InterruptedException { server.enqueue(response404()); Iterable<Key> keys = api.keyApi().list().concat(); assertTrue(isEmpty(keys)); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys"); }
public void testListKeysWithOptionsReturns404() throws InterruptedException { server.enqueue(response404()); Iterable<Key> keys = api.keyApi().list(page(1).perPage(5)); assertTrue(isEmpty(keys)); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys?page=1&per_page=5"); }
public void testListKeysWithOptions() throws InterruptedException { server.enqueue(jsonResponse("/keys-first.json")); Iterable<Key> keys = api.keyApi().list(page(1).perPage(5)); assertEquals(size(keys), 5); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys?page=1&per_page=5"); }
public void testRateLimitExceptionIsThrown() throws InterruptedException { long reset = (System.currentTimeMillis() / 1000) + 3600; // Epoch for one // hour from now long millisToReset = millisUntilNextAvailableRequest(reset); server.enqueue(new MockResponse().setResponseCode(429).addHeader("RateLimit-Limit", "5000") .addHeader("RateLimit-Remaining", "1235").addHeader("RateLimit-Reset", String.valueOf(reset))); try { api.keyApi().list(); fail("Expected a DigitalOcean2RateLimitExceededException to be thrown"); } catch (DigitalOcean2RateLimitExceededException ex) { assertEquals(ex.totalRequestsPerHour().intValue(), 5000); assertEquals(ex.remainingRequests().intValue(), 1235); // Can't verify with millisecond precision. Use an interval to have a // consistent test. assertTrue(ex.timeToNextAvailableRequest() < millisToReset && ex.timeToNextAvailableRequest() > millisToReset - 1800000); } }
@AfterClass(alwaysRun = true) public void testDeleteKey() { if (dsa != null) { api().delete(dsa.id()); FluentIterable<Key> keys = api().list().concat(); assertFalse(keys.contains(dsa), "dsa key must not be present in list"); } if (ecdsa != null) { api().delete(ecdsa.fingerprint()); FluentIterable<Key> keys = api().list().concat(); assertFalse(keys.contains(ecdsa), "dsa key must not be present in list"); } }
public void testListKeys() throws InterruptedException { server.enqueue(jsonResponse("/keys-first.json")); server.enqueue(jsonResponse("/keys-last.json")); Iterable<Key> keys = api.keyApi().list().concat(); assertEquals(size(keys), 7); // Force the PagedIterable to advance assertEquals(server.getRequestCount(), 2); assertSent(server, "GET", "/account/keys"); assertSent(server, "GET", "/account/keys?page=2&per_page=5"); }
Optional<Key> key = do2api.keyApi().list().concat().firstMatch( new Predicate<Key>() { @Override