Package com.gistlabs.mechanize.document.json.hypermedia

Examples of com.gistlabs.mechanize.document.json.hypermedia.JsonLink


  public void testFindingOneHref() {
    JsonNode one = json.find("one");
    List<JsonLink> links = finder.findOn(one);
    assertEquals(1, links.size());
   
    JsonLink hrefLink = links.get(0);
    assertEquals(hrefLink.node(), one);
  }
View Full Code Here


  public void testLinkRelIsName() {
    JsonNode one = json.find("rel-is-name");
    List<JsonLink> links = finder.findOn(one);
    assertEquals(1, links.size());
   
    JsonLink hrefLink = links.get(0);
    assertEquals("rel-is-name", hrefLink.linkRel());
  }
View Full Code Here

  public void testLinkRelIsRel() {
    JsonNode one = json.find("rel-is-rel");
    List<JsonLink> links = finder.findOn(one);
    assertEquals(1, links.size());
   
    JsonLink hrefLink = links.get(0);
    assertEquals("self", hrefLink.linkRel());
  }
View Full Code Here

  public void testLinkRelIsPrefix() {
    JsonNode one = json.find("rel-is-prefix");
    List<JsonLink> links = finder.findOn(one);
    assertEquals(1, links.size());
   
    JsonLink hrefLink = links.get(0);
    assertEquals("prefix", hrefLink.linkRel());
  }
View Full Code Here

  public void testNestedLinksDepthOne() {
    JsonNode node = json.find("nested-links");
    List<JsonLink> links = finder.findOn(node);
    assertEquals(1, links.size());
   
    JsonLink hrefLink = links.get(0);
    assertEquals("self", hrefLink.linkRel());
  }
View Full Code Here

  public void testNestedLinksDepthChildren() {
    JsonNode node = json.find("nested-links");
    List<JsonLink> links = finder.findWithChildren(node);
    assertEquals(3, links.size());
   
    JsonLink next = links.get(1); // this index is dependent on ordering of children
    assertEquals("next", next.linkRel());
  }
View Full Code Here

    this.node = node;
  }
   
  @Test
  public void testLinkResolution() {
    JsonLink link = link(find(node));
    assertExpectedUri(link);
  }
View Full Code Here

  }
 
  static JsonLink link(JsonNode node) {
    String baseUrl = node.hasAttribute("baseUrl") ? node.getAttribute("baseUrl") : null; // optionally use data supplied for baseUrl
    String attrName = node.hasAttribute("use-attr") ? node.getAttribute("use-attr") : "href"; // optionally use data supplied to find link attribute
    JsonLink link = new JsonLink(baseUrl, node, attrName, null);
    return link;
  }
View Full Code Here

  }
 
  @Test
  public void testLinkNames() {
    JsonNode simple = json.find("simple");
    assertEquals("self", new JsonLink(simple).linkRel());
   
    JsonNode relative = json.find("relative");
    assertEquals("relative", new JsonLink(relative).linkRel());
  }
View Full Code Here

  }
 
  @Test
  public void setVariableProgramatically() {
    JsonNode node = json.find("trivial-template");
    JsonLink link = new JsonLink(node);
    link.set("a", "aaa");
    assertEquals("http://example.com/aaa", link.uri());
  }
View Full Code Here

TOP

Related Classes of com.gistlabs.mechanize.document.json.hypermedia.JsonLink

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.