Package com.gistlabs.mechanize.document.json.node

Examples of com.gistlabs.mechanize.document.json.node.JsonNode


    assertEquals("rel-is-name", hrefLink.linkRel());
  }
 
  @Test
  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


    assertEquals("self", hrefLink.linkRel());
  }
 
  @Test
  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

    assertEquals("prefix", hrefLink.linkRel());
  }
 
  @Test
  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

    assertEquals("self", hrefLink.linkRel());
  }
 
  @Test
  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

    assertEquals("next", next.linkRel());
  }
 
  @Test
  public void testNestedLinksRecursive() {
    JsonNode node = json.find("nested-links");
    List<JsonLink> links = finder.findRecursive(node);
    assertEquals(5, links.size());
  }
View Full Code Here

  @Test
  public void testNestedElement() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"one\" : 2, \"b\" : { \"a\" : \"x\", \"c\" : 4 } }"));

    JsonNode nested = element.getChild("b");
    assertNotNull(nested);
    assertTrue(nested instanceof ObjectNodeImpl);
    assertEquals("b", nested.getName());
    assertEquals(element, nested.getParent());
    assertEquals("x", nested.getAttribute("a"));
  }
View Full Code Here

    json = from(jsonString);
  }
 
  @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

    assertEquals("relative", new JsonLink(relative).linkRel());
  }
 
  @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

    assertEquals("http://example.com/aaa", link.uri());
  }
 
  @Test
  public void setAllVariableProgramatically() {
    JsonNode node = json.find("template-path-segments");
    JsonLink link = new JsonLink(node);
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("a", "aaa");
    variables.put("b", "bbb");
    link.setAll(variables);
View Full Code Here

    return new ObjectNodeImpl(new JSONObject(json));
  }

  @Test
  public void testAttributeTilda() throws Exception {
    JsonNode node = build("{ \"a\" : 2, \"b\" : { \"x\" : \"y foo bar\" }, \"results\" : [ { \"a\" : 1 }, { \"b\" : 2 } ] }");

    assertNotNull(node.find("b[x~=\"y\"]"));
    assertEquals(1, node.findAll("b[x~=\"foo\"]").size());
    assertEquals(1, node.findAll("b[x~=\"bar\"]").size());

    assertEquals(0, node.findAll("b[x~=\"baz\"]").size());
  }
View Full Code Here

TOP

Related Classes of com.gistlabs.mechanize.document.json.node.JsonNode

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.