@Test public void testGetImage() throws IOException { Image image = new Image(); image.setId("image1"); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(image); setupMocks(serializedTask, HttpStatus.SC_OK); ImagesApi imagesApi = new ImagesRestApi(this.restClient); Image response = imagesApi.getImage("image1"); assertEquals(response, image); }
@Override public Image getImage(String imageId) throws IOException { String path = String.format("%s/%s", getBasePath(), imageId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Image>() { } ); }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public Image getImage(String imageId) throws IOException { String path = String.format("%s/%s", getBasePath(), imageId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Image>() { } ); } }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public Image getImage(String imageId) throws IOException { String path = String.format("%s/%s", getBasePath(), imageId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Image>() { } ); } ImagesRestApi(RestClient restClient); }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public Image getImage(String imageId) throws IOException { String path = String.format("%s/%s", getBasePath(), imageId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Image>() { } ); } ImagesRestApi(RestClient restClient); @Override String getBasePath(); @Override Task uploadImage(String inputFileName); @Override Task uploadImage(String inputFileName, String replicationType); @Override Task uploadImage(FileBody fileBody, String replicationType); @Override Image getImage(String imageId); @Override void getImageAsync(final String imageId, final FutureCallback<Image> responseCallback); @Override ResourceList<Image> getImages(); @Override void getImagesAsync(final FutureCallback<ResourceList<Image>> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String id, final FutureCallback<Task> responseCallback); }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public Image getImage(String imageId) throws IOException { String path = String.format("%s/%s", getBasePath(), imageId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Image>() { } ); } ImagesRestApi(RestClient restClient); @Override String getBasePath(); @Override Task uploadImage(String inputFileName); @Override Task uploadImage(String inputFileName, String replicationType); @Override Task uploadImage(FileBody fileBody, String replicationType); @Override Image getImage(String imageId); @Override void getImageAsync(final String imageId, final FutureCallback<Image> responseCallback); @Override ResourceList<Image> getImages(); @Override void getImagesAsync(final FutureCallback<ResourceList<Image>> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String id, final FutureCallback<Task> responseCallback);  }