@Test public void testGetCluster() throws IOException { 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); Cluster response = clusterApi.getCluster("foo"); assertEquals(response, cluster); }
@Override public Cluster getCluster(String clusterId) throws IOException { String path = String.format("%s/%s", getBasePath(), clusterId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Cluster>() { } ); }
ClusterRestApi extends ApiBase implements ClusterApi { @Override public Cluster getCluster(String clusterId) throws IOException { String path = String.format("%s/%s", getBasePath(), clusterId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Cluster>() { } ); } }
ClusterRestApi extends ApiBase implements ClusterApi { @Override public Cluster getCluster(String clusterId) throws IOException { String path = String.format("%s/%s", getBasePath(), clusterId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Cluster>() { } ); } ClusterRestApi(RestClient restClient); }
ClusterRestApi extends ApiBase implements ClusterApi { @Override public Cluster getCluster(String clusterId) throws IOException { String path = String.format("%s/%s", getBasePath(), clusterId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, 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); }
ClusterRestApi extends ApiBase implements ClusterApi { @Override public Cluster getCluster(String clusterId) throws IOException { String path = String.format("%s/%s", getBasePath(), clusterId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, 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);  }