Package org.jboss.resteasy.links

Examples of org.jboss.resteasy.links.RESTServiceDiscovery


  private void checkBookLinks1(String url, Book book) {
    Assert.assertNotNull(book);
    Assert.assertEquals("foo", book.getTitle());
    Assert.assertEquals("bar", book.getAuthor());
    RESTServiceDiscovery links = book.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(1, links.size());
    // self
    AtomLink atomLink = links.getLinkForRel("self");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
  }
View Full Code Here


    checkBook(book, "/jpa-id/book/foo");
  }

  private void checkBook(IdBook book, String relativeUrl) {
    Assert.assertNotNull(book);
    RESTServiceDiscovery links = book.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(1, links.size());
    AtomLink link = links.get(0);
    Assert.assertEquals("self", link.getRel());
    Assert.assertEquals(url + relativeUrl, link.getHref());
  }
View Full Code Here

  private void checkBookLinks1(String url, Book book, String... expectedLinks) {
    Assert.assertNotNull(book);
    Assert.assertEquals("foo", book.getTitle());
    Assert.assertEquals("bar", book.getAuthor());
    RESTServiceDiscovery links = book.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(expectedLinks.length, links.size());
    for (String expectedLink : expectedLinks) {
      Assert.assertNotNull(links.getLinkForRel(expectedLink));
    }
  }
View Full Code Here

    // find the field to inject first
    Field injectionField = findInjectionField(entity);
    if(injectionField == null)
      return entity;
    List<Method> methods = getServiceMethods(registry);
    RESTServiceDiscovery ret = new RESTServiceDiscovery();
    for(Method m : methods){
      processLinkResources(m, entity, uriInfo, ret);
    }
    // do not inject an empty service
    if(ret.isEmpty())
      return entity;
    // now inject
    injectionField.setAccessible(true);
    try {
      injectionField.set(entity, ret);
View Full Code Here

    checkCommentsLinks(url, comments);
  }

  private void checkCommentsLinks(String url, ScrollableCollection comments) {
    Assert.assertNotNull(comments);
    RESTServiceDiscovery links = comments.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(3, links.size());
    // list
    AtomLink atomLink = links.getLinkForRel("list");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // add
    atomLink = links.getLinkForRel("add");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // comment collection
    atomLink = links.getLinkForRel("collection");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment-collection", atomLink.getHref());
  }
View Full Code Here

  }

  private void checkCommentLinks(String url, Comment comment) {
    Assert.assertNotNull(comment);
    Assert.assertEquals(0, comment.getId());
    RESTServiceDiscovery links = comment.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(6, links.size());
    // self
    AtomLink atomLink = links.getLinkForRel("self");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment/0", atomLink.getHref());
    // update
    atomLink = links.getLinkForRel("update");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment/0", atomLink.getHref());
    // remove
    atomLink = links.getLinkForRel("remove");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment/0", atomLink.getHref());
    // list
    atomLink = links.getLinkForRel("list");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // add
    atomLink = links.getLinkForRel("add");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // collection
    atomLink = links.getLinkForRel("collection");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment-collection", atomLink.getHref());
  }
View Full Code Here

  private void checkBookLinks1(String url, Book book) {
    Assert.assertNotNull(book);
    Assert.assertEquals("foo", book.getTitle());
    Assert.assertEquals("bar", book.getAuthor());
    RESTServiceDiscovery links = book.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(7, links.size());
    // self
    AtomLink atomLink = links.getLinkForRel("self");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
    // update
    atomLink = links.getLinkForRel("update");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
    // remove
    atomLink = links.getLinkForRel("remove");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
    // list
    atomLink = links.getLinkForRel("list");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/books", atomLink.getHref());
    // add
    atomLink = links.getLinkForRel("add");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/books", atomLink.getHref());
    // comments
    atomLink = links.getLinkForRel("comments");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // comment collection
    atomLink = links.getLinkForRel("comment-collection");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment-collection", atomLink.getHref());
  }
View Full Code Here

  }

  private void checkCommentLinks(String url, Comment comment) {
    Assert.assertNotNull(comment);
    Assert.assertEquals(0, comment.getId());
    RESTServiceDiscovery links = comment.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(6, links.size());
    // self
    AtomLink atomLink = links.getLinkForRel("self");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment/0", atomLink.getHref());
    // update
    atomLink = links.getLinkForRel("update");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment/0", atomLink.getHref());
    // remove
    atomLink = links.getLinkForRel("remove");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment/0", atomLink.getHref());
    // list
    atomLink = links.getLinkForRel("list");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // add
    atomLink = links.getLinkForRel("add");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // collection
    atomLink = links.getLinkForRel("collection");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment-collection", atomLink.getHref());
  }
View Full Code Here

  private void checkBookLinks1(String url, Book book, String... expectedLinks) {
    Assert.assertNotNull(book);
    Assert.assertEquals("foo", book.getTitle());
    Assert.assertEquals("bar", book.getAuthor());
    RESTServiceDiscovery links = book.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(expectedLinks.length, links.size());
    for (String expectedLink : expectedLinks) {
      Assert.assertNotNull(links.getLinkForRel(expectedLink));
    }
  }
View Full Code Here

  private void checkBookLinks1(String url, Book book) {
    Assert.assertNotNull(book);
    Assert.assertEquals("foo", book.getTitle());
    Assert.assertEquals("bar", book.getAuthor());
    RESTServiceDiscovery links = book.getRest();
    Assert.assertNotNull(links);
    Assert.assertEquals(7, links.size());
    // self
    AtomLink atomLink = links.getLinkForRel("self");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
    // update
    atomLink = links.getLinkForRel("update");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
    // remove
    atomLink = links.getLinkForRel("remove");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo", atomLink.getHref());
    // list
    atomLink = links.getLinkForRel("list");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/books", atomLink.getHref());
    // add
    atomLink = links.getLinkForRel("add");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/books", atomLink.getHref());
    // comments
    atomLink = links.getLinkForRel("comments");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comments", atomLink.getHref());
    // comment collection
    atomLink = links.getLinkForRel("comment-collection");
    Assert.assertNotNull(atomLink);
    Assert.assertEquals(url+"/book/foo/comment-collection", atomLink.getHref());
  }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.links.RESTServiceDiscovery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.