### Question:
InstallationManagementEndpoint { static LinkHeader getLinkHeader(Integer page, long totalPages, UriInfo uri) { LinkHeader header = new LinkHeader(); if (page != 0) { header.addLink(buildLink("prev", page - 1, uri)); header.addLink(buildLink("first", 0, uri)); } if (page < totalPages) { header.addLink(buildLink("next", page + 1, uri)); header.addLink(buildLink("last", totalPages, uri)); } return header; }  @GET @Produces(MediaType.APPLICATION_JSON) Response findInstallations(@PathParam("variantID") String variantId,
                                      @QueryParam("page") Integer page,
                                      @QueryParam("per_page") Integer pageSize,
                                      @QueryParam("search") String search,
                                      @Context UriInfo uri); @GET @Path("/{installationID}") @Produces(MediaType.APPLICATION_JSON) Response findInstallation(@PathParam("variantID") String variantId, @PathParam("installationID") String installationId); @PUT @Path("/{installationID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateInstallation(Installation entity, @PathParam("variantID") String variantId, @PathParam("installationID") String installationId); @DELETE @Path("/{installationID}") @Produces(MediaType.APPLICATION_JSON) Response removeInstallation(@PathParam("variantID") String variantId, @PathParam("installationID") String installationId);  }### Answer:
@Test public void shouldGenerateHeaderLinksFirstPage() throws URISyntaxException { final ResteasyUriInfo uriInfo = getUriInfo(); final LinkHeader linkHeader = endpoint.getLinkHeader(0, 3, uriInfo); assertThat(findLinkByRel(linkHeader, "prev")).isNull(); final Link next = findLinkByRel(linkHeader, "next"); assertThat(next).isNotNull(); assertThat(next.getHref()).isEqualTo("/?page=1"); assertThat(findLinkByRel(linkHeader, "first")).isNull(); }
@Test public void shouldGenerateHeaderLinksNormalPage() throws URISyntaxException { final ResteasyUriInfo uriInfo = getUriInfo(); final LinkHeader linkHeader = endpoint.getLinkHeader(2, 3, uriInfo); final Link prev = findLinkByRel(linkHeader, "prev"); assertThat(prev).isNotNull(); assertThat(prev.getHref()).isEqualTo("/?page=1"); final Link next = findLinkByRel(linkHeader, "next"); assertThat(next).isNotNull(); assertThat(next.getHref()).isEqualTo("/?page=3"); }
@Test public void shouldGenerateHeaderLinksLastPage() throws URISyntaxException { final ResteasyUriInfo uriInfo = getUriInfo(); final LinkHeader linkHeader = endpoint.getLinkHeader(3, 3, uriInfo); final Link prev = findLinkByRel(linkHeader, "prev"); assertThat(prev).isNotNull(); assertThat(prev.getHref()).isEqualTo("/?page=2"); final Link first = findLinkByRel(linkHeader, "first"); assertThat(first).isNotNull(); assertThat(first.getHref()).isEqualTo("/?page=0"); assertThat(findLinkByRel(linkHeader, "last")).isNull(); }