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

Examples of com.gistlabs.mechanize.document.json.node.impl.ObjectNodeImpl


    assertEquals("maybe", element.getChild("b").getValue());
  }

  @Test
  public void confirmNullHandling() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"one\" : 2, \"b\" : null }"));

    assertNull(element.getAttribute("b"));
    assertTrue(element.hasAttribute("b"));

    element.setAttribute("one", null);
    assertNull(element.getAttribute("one"));
    assertTrue(element.hasAttribute("one"));
  }
View Full Code Here


    assertTrue(element.hasAttribute("one"));
  }

  @Test
  public void testStableChildren() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"one\" : 2, \"b\" : 2.2 }"));

    assertEquals(element.getChild("b"), element.getChild("b"));
  }
View Full Code Here


public class NodeSelectorTest {

  protected NodeSelector<JsonNode> build(final String json) throws JSONException {
    ObjectNodeImpl node = new ObjectNodeImpl(new JSONObject(json));
    return node.buildNodeSelector();
  }
View Full Code Here

public class ArrayElementsTest extends TestElementBaseClass {

  @Test
  public void testArrayObjects() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"one\" : 2, \"results\" : [ { \"a\" : 1 }, { \"b\" : 2 } ] }"));

    List<JsonNode> array = element.getChildren("results");
    assertNotNull(array);
    assertEquals("results", array.get(0).getName());
    assertEquals(element, array.get(0).getParent());
    assertEquals("1", array.get(0).getAttribute("a"));
    assertEquals("2", array.get(1).getAttribute("b"));
View Full Code Here

    assertEquals("2", array.get(1).getAttribute("b"));
  }

  @Test
  public void testArrayPrimitives() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"results\" : [ 1,2] }"));

    List<JsonNode> array = element.getChildren("results");
    assertNotNull(array);
    assertEquals(2, array.size());
    assertEquals("results", array.get(0).getName());
    assertEquals("1", array.get(0).getValue());
View Full Code Here

    assertEquals("4", array.get(0).getValue());
  }

  @Test
  public void testNestedArrays() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"results\" : [ [1,2], [3,4] ] }"));

    List<JsonNode> array = element.getChildren("results");
    assertNotNull(array);
    assertEquals(2, array.size());
    assertEquals("results", array.get(0).getName());

  }
View Full Code Here

  }

  @Test(expected=JsonException.class)
  public void testChildFails() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"one\" : 2, \"results\" : [ { \"a\" : 1 }, { \"b\" : 2 } ] }"));

    element.getChild("results");
  }
View Full Code Here


public class ElementQueryTest {

  protected JsonNode build(final String json) throws JSONException {
    return new ObjectNodeImpl(new JSONObject(json));
  }
View Full Code Here

    element.getChild("results");
  }

  @Test
  public void testGetChildrenStar() {
    ObjectNodeImpl element = new ObjectNodeImpl(parseJson("{ \"one\" : [2,3], \"results\" : [ { \"a\" : 1 }, { \"b\" : 2 },  ] }"));

    assertEquals(2, element.getChildren("results").size());
    assertEquals(4, element.getChildren("*").size());
  }
 
View Full Code Here


public class PseudoNodeSelectorTest {

  protected NodeSelector<JsonNode> build(final String json) throws JSONException {
    ObjectNodeImpl node = new ObjectNodeImpl(new JSONObject(json));
    return node.buildNodeSelector();
  }
View Full Code Here

TOP

Related Classes of com.gistlabs.mechanize.document.json.node.impl.ObjectNodeImpl

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.