@Test
  public void addsPreviousLinkForLastPage() {

    PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, null);
    PagedResources<Resource<Person>> resources = assembler.toResource(createPage(2));

    assertThat(resources.getLink(Link.REL_PREVIOUS), is(notNullValue()));
    assertThat(resources.getLink(Link.REL_NEXT), is(nullValue()));
  }
  @Test
  public void usesCustomLinkProvided() {

    Link link = new Link("http://foo:9090", "rel");

    PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, null);
    PagedResources<Resource<Person>> resources = assembler.toResource(createPage(1), link);

    assertThat(resources.getLink(Link.REL_PREVIOUS).getHref(), startsWith(link.getHref()));
    assertThat(resources.getLink(Link.REL_NEXT).getHref(), startsWith(link.getHref()));
  }
  @Test
  public void usesBaseUriIfConfigured() {

    UriComponents baseUri = UriComponentsBuilder.fromUriString("http://foo:9090").build();

    PagedResourcesAssembler<Person> assembler =
        new PagedResourcesAssembler<Person>(resolver, baseUri);
    PagedResources<Resource<Person>> resources = assembler.toResource(createPage(1));

    assertThat(resources.getLink(Link.REL_PREVIOUS).getHref(), startsWith(baseUri.toUriString()));
    assertThat(resources.getLink(Link.REL_NEXT).getHref(), startsWith(baseUri.toUriString()));
  }