DisksRestApi extends ApiBase implements DisksApi { @Override public void getDiskAsync(final String diskId, final FutureCallback<PersistentDisk> responseCallback) throws IOException { String path = String.format("%s/%s", getBasePath(), diskId); getObjectByPathAsync(path, responseCallback, new TypeReference<PersistentDisk>() { }); } DisksRestApi(RestClient restClient); @Override String getBasePath(); @Override PersistentDisk getDisk(String diskId); @Override void getDiskAsync(final String diskId, final FutureCallback<PersistentDisk> responseCallback); @Override ResourceList<Task> getTasksForDisk(String diskId); @Override void getTasksForDiskAsync(final String diskId, final FutureCallback<ResourceList<Task>> responseCallback); @Override Task delete(String diskId); @Override void deleteAsync(final String diskId, final FutureCallback<Task> responseCallback);  }
@Test public void testGetDiskAsync() throws IOException, InterruptedException { final PersistentDisk persistentDisk = new PersistentDisk(); persistentDisk.setId("persistentDisk"); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(persistentDisk); setupMocks(serializedTask, HttpStatus.SC_OK); DisksApi disksApi = new DisksRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); disksApi.getDiskAsync("disk1", new FutureCallback<PersistentDisk>() { @Override public void onSuccess(@Nullable PersistentDisk result) { assertEquals(result, persistentDisk); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }