ClusterRestApi extends ApiBase implements ClusterApi { @Override public void getClusterAsync(final String clusterId, final FutureCallback<Cluster> responseCallback) throws IOException { final String path = String.format("%s/%s", getBasePath(), clusterId); getObjectByPathAsync(path, responseCallback, new TypeReference<Cluster>() { }); } ClusterRestApi(RestClient restClient); @Override String getBasePath(); @Override Cluster getCluster(String clusterId); @Override void getClusterAsync(final String clusterId, final FutureCallback<Cluster> responseCallback); @Override Task delete(String clusterId); @Override void deleteAsync(final String clusterId, final FutureCallback<Task> responseCallback); @Override Task resize(String clusterId, int size); @Override void resizeAsync(
      final String clusterId, final int size, final FutureCallback<Task> responseCallback); @Override ResourceList<Vm> getVmsInCluster(String clusterId); @Override void getVmsInClusterAsync(final String clusterId, final FutureCallback<ResourceList<Vm>> responseCallback);  }
@Test public void testGetClusterAsync() throws IOException, InterruptedException { final Cluster cluster = new Cluster(); cluster.setName("clusterName"); cluster.setState(ClusterState.READY); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(cluster); setupMocks(serializedTask, HttpStatus.SC_OK); ClusterApi clusterApi = new ClusterRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); clusterApi.getClusterAsync("foo", new FutureCallback<Cluster>() { @Override public void onSuccess(Cluster result) { assertEquals(result, cluster); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }