@Test public void testGetAllImagesForPagination() throws IOException { Image image1 = new Image(); image1.setId("image1"); Image image2 = new Image(); image2.setId("image2"); Image image3 = new Image(); image3.setId("image3"); String nextPageLink = "nextPageLink"; ResourceList<Image> imageResourceList = new ResourceList<>(Arrays.asList(image1, image2), nextPageLink, null); ResourceList<Image> imageResourceListNextPage = new ResourceList<>(Arrays.asList(image3)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(imageResourceList); String serializedTaskNextPage = mapper.writeValueAsString(imageResourceListNextPage); setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK); ImagesApi imagesApi = new ImagesRestApi(this.restClient); ResourceList<Image> response = imagesApi.getImages(); assertEquals(response.getItems().size(), imageResourceList.getItems().size() + imageResourceListNextPage .getItems().size()); assertTrue(response.getItems().containsAll(imageResourceList.getItems())); assertTrue(response.getItems().containsAll(imageResourceListNextPage.getItems())); }
@Override public ResourceList<Image> getImages() throws IOException { ResourceList<Image> imageResourceList = new ResourceList<>(); ResourceList<Image> resourceList = getImageResourceList(getBasePath()); imageResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getImageResourceList(resourceList.getNextPageLink()); imageResourceList.getItems().addAll(resourceList.getItems()); } return imageResourceList; }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public ResourceList<Image> getImages() throws IOException { ResourceList<Image> imageResourceList = new ResourceList<>(); ResourceList<Image> resourceList = getImageResourceList(getBasePath()); imageResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getImageResourceList(resourceList.getNextPageLink()); imageResourceList.getItems().addAll(resourceList.getItems()); } return imageResourceList; } }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public ResourceList<Image> getImages() throws IOException { ResourceList<Image> imageResourceList = new ResourceList<>(); ResourceList<Image> resourceList = getImageResourceList(getBasePath()); imageResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getImageResourceList(resourceList.getNextPageLink()); imageResourceList.getItems().addAll(resourceList.getItems()); } return imageResourceList; } ImagesRestApi(RestClient restClient); }
ImagesRestApi extends ApiBase implements ImagesApi { @Override public ResourceList<Image> getImages() throws IOException { ResourceList<Image> imageResourceList = new ResourceList<>(); ResourceList<Image> resourceList = getImageResourceList(getBasePath()); imageResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getImageResourceList(resourceList.getNextPageLink()); imageResourceList.getItems().addAll(resourceList.getItems()); } return imageResourceList; } 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 ResourceList<Image> getImages() throws IOException { ResourceList<Image> imageResourceList = new ResourceList<>(); ResourceList<Image> resourceList = getImageResourceList(getBasePath()); imageResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getImageResourceList(resourceList.getNextPageLink()); imageResourceList.getItems().addAll(resourceList.getItems()); } return imageResourceList; } 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);  }