@Test
  public void testGetResourceTicketTasksPage() throws Exception {
    ResourceList<Task> expectedTasksPage =
        new ResourceList<Task>(
            ImmutableList.of(task1, task2),
            UUID.randomUUID().toString(),
            UUID.randomUUID().toString());
    when(client.getPage(anyString())).thenReturn(expectedTasksPage);

    List<String> expectedSelfLinks = ImmutableList.of(taskRoutePath1, taskRoutePath2);

    Response response = getTasks(UUID.randomUUID().toString());
    assertThat(response.getStatus(), is(200));

    ResourceList<Task> tasks = response.readEntity(new GenericType<ResourceList<Task>>() {});

    assertThat(tasks.getItems().size(), is(expectedTasksPage.getItems().size()));

    for (int i = 0; i < tasks.getItems().size(); i++) {
      assertThat(new URI(tasks.getItems().get(i).getSelfLink()).isAbsolute(), is(true));
      assertThat(tasks.getItems().get(i), is(expectedTasksPage.getItems().get(i)));
      assertThat(
          tasks.getItems().get(i).getSelfLink().endsWith(expectedSelfLinks.get(i)), is(true));
    }

    verifyPageLinks(tasks);
  }
  @GET
  @ApiOperation(
      value =
          "Find tasks associated with AvailabilityZone. If pageLink is provided, "
              + "then get the tasks on that specific page",
      response = Task.class,
      responseContainer = ResourceList.CLASS_NAME)
  @ApiResponses(
      value = {@ApiResponse(code = 200, message = "List of tasks for an availabilityZone")})
  public Response get(
      @Context Request request,
      @PathParam("id") String id,
      @QueryParam("state") Optional<String> state,
      @QueryParam("pageSize") Optional<Integer> pageSize,
      @QueryParam("pageLink") Optional<String> pageLink)
      throws ExternalException {

    ResourceList<Task> resourceList;
    if (pageLink.isPresent()) {
      resourceList = taskFeClient.getPage(pageLink.get());
    } else {
      Optional<Integer> adjustedPageSize =
          PaginationUtils.determinePageSize(paginationConfig, pageSize);
      resourceList = taskFeClient.getAvailabilityZoneTasks(id, state, adjustedPageSize);
    }

    return generateResourceListResponse(
        Response.Status.OK,
        PaginationUtils.formalizePageLinks(resourceList, TaskResourceRoutes.API),
        (ContainerRequest) request,
        TaskResourceRoutes.TASK_PATH);
  }