@Test public void testGetResourceTicketTasksForPagination() throws IOException { Task task1 = new Task(); task1.setId("task1"); Task task2 = new Task(); task2.setId("task2"); Task task3 = new Task(); task3.setId("task3"); String nextPageLink = "nextPageLink"; ResourceList<Task> taskResourceList = new ResourceList<>(Arrays.asList(task1, task2), nextPageLink, null); ResourceList<Task> taskResourceListNextPage = new ResourceList<>(Arrays.asList(task3)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(taskResourceList); String serializedTaskNextPage = mapper.writeValueAsString(taskResourceListNextPage); setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK); ResourceTicketApi resourceTicketApi = new ResourceTicketRestApi(restClient); ResourceList<Task> response = resourceTicketApi.getTasksForResourceTicket("foo"); assertEquals(response.getItems().size(), taskResourceList.getItems().size() + taskResourceListNextPage.getItems() .size()); assertTrue(response.getItems().containsAll(taskResourceList.getItems())); assertTrue(response.getItems().containsAll(taskResourceListNextPage.getItems())); }
@Override public ResourceList<Task> getTasksForResourceTicket(String resourceTicketId) throws IOException { String path = String.format("%s/%s/tasks", getBasePath(), resourceTicketId); ResourceList<Task> taskResourceList = new ResourceList<>(); ResourceList<Task> resourceList = getTaskResourceList(path); taskResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getTaskResourceList(resourceList.getNextPageLink()); taskResourceList.getItems().addAll(resourceList.getItems()); } return taskResourceList; }
ResourceTicketRestApi extends ApiBase implements ResourceTicketApi { @Override public ResourceList<Task> getTasksForResourceTicket(String resourceTicketId) throws IOException { String path = String.format("%s/%s/tasks", getBasePath(), resourceTicketId); ResourceList<Task> taskResourceList = new ResourceList<>(); ResourceList<Task> resourceList = getTaskResourceList(path); taskResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getTaskResourceList(resourceList.getNextPageLink()); taskResourceList.getItems().addAll(resourceList.getItems()); } return taskResourceList; } }
ResourceTicketRestApi extends ApiBase implements ResourceTicketApi { @Override public ResourceList<Task> getTasksForResourceTicket(String resourceTicketId) throws IOException { String path = String.format("%s/%s/tasks", getBasePath(), resourceTicketId); ResourceList<Task> taskResourceList = new ResourceList<>(); ResourceList<Task> resourceList = getTaskResourceList(path); taskResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getTaskResourceList(resourceList.getNextPageLink()); taskResourceList.getItems().addAll(resourceList.getItems()); } return taskResourceList; } ResourceTicketRestApi(RestClient restClient); }
ResourceTicketRestApi extends ApiBase implements ResourceTicketApi { @Override public ResourceList<Task> getTasksForResourceTicket(String resourceTicketId) throws IOException { String path = String.format("%s/%s/tasks", getBasePath(), resourceTicketId); ResourceList<Task> taskResourceList = new ResourceList<>(); ResourceList<Task> resourceList = getTaskResourceList(path); taskResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getTaskResourceList(resourceList.getNextPageLink()); taskResourceList.getItems().addAll(resourceList.getItems()); } return taskResourceList; } ResourceTicketRestApi(RestClient restClient); @Override String getBasePath(); @Override ResourceTicket getResourceTicket(String resourceTicketId); @Override void getResourceTicketAsync(final String resourceTicketId, final FutureCallback<ResourceTicket>
      responseCallback); @Override ResourceList<Task> getTasksForResourceTicket(String resourceTicketId); @Override void getTasksForResourceTicketAsync(final String resourceTicketId, final FutureCallback<ResourceList<Task>>
      responseCallback); }
ResourceTicketRestApi extends ApiBase implements ResourceTicketApi { @Override public ResourceList<Task> getTasksForResourceTicket(String resourceTicketId) throws IOException { String path = String.format("%s/%s/tasks", getBasePath(), resourceTicketId); ResourceList<Task> taskResourceList = new ResourceList<>(); ResourceList<Task> resourceList = getTaskResourceList(path); taskResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getTaskResourceList(resourceList.getNextPageLink()); taskResourceList.getItems().addAll(resourceList.getItems()); } return taskResourceList; } ResourceTicketRestApi(RestClient restClient); @Override String getBasePath(); @Override ResourceTicket getResourceTicket(String resourceTicketId); @Override void getResourceTicketAsync(final String resourceTicketId, final FutureCallback<ResourceTicket>
      responseCallback); @Override ResourceList<Task> getTasksForResourceTicket(String resourceTicketId); @Override void getTasksForResourceTicketAsync(final String resourceTicketId, final FutureCallback<ResourceList<Task>>
      responseCallback);  }