@Test(dataProvider = "pageSizes") public void testGetResourceTicketTasks( Optional<Integer> pageSize, List<Task> expectedTasks, List<String> expectedTaskRoutes) throws Exception { task1.setId(taskId1); task2.setId(taskId2); when(client.getResourceTicketTasks( ticketId, Optional.<String>absent(), Optional.of(PaginationConfig.DEFAULT_DEFAULT_PAGE_SIZE))) .thenReturn(new ResourceList<>(ImmutableList.of(task1, task2), null, null)); when(client.getResourceTicketTasks(ticketId, Optional.<String>absent(), Optional.of(1))) .thenReturn( new ResourceList<>(ImmutableList.of(task1), UUID.randomUUID().toString(), null)); when(client.getResourceTicketTasks(ticketId, Optional.<String>absent(), Optional.of(2))) .thenReturn(new ResourceList<>(ImmutableList.of(task1, task2), null, null)); when(client.getResourceTicketTasks(ticketId, Optional.<String>absent(), Optional.of(3))) .thenReturn(new ResourceList<>(Collections.emptyList(), null, null)); Response response = getTasks(pageSize); assertThat(response.getStatus(), is(200)); ResourceList<Task> tasks = response.readEntity(new GenericType<ResourceList<Task>>() {}); assertThat(tasks.getItems().size(), is(expectedTasks.size())); for (int i = 0; i < tasks.getItems().size(); i++) { assertThat(tasks.getItems().get(i), is(expectedTasks.get(i))); assertThat( new URI(tasks.getItems().get(i).getSelfLink()).isAbsolute(), CoreMatchers.is(true)); assertThat( tasks.getItems().get(i).getSelfLink().endsWith(expectedTaskRoutes.get(i)), CoreMatchers.is(true)); } verifyPageLinks(tasks); }