Search in sources :

Example 21 with JsonPointer

use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.

the class JsonPointerTest method testNotFoundTracedQuery.

@Test
public void testNotFoundTracedQuery() {
    JsonObject child2 = new JsonObject().put("child5", 1);
    JsonArray child1 = new JsonArray().add(child2);
    JsonObject root = new JsonObject().put("child1", child1);
    JsonPointer pointer = JsonPointer.create().append("child1").append("0").append("child3");
    List<Object> traced = pointer.tracedQuery(root, JsonPointerIterator.JSON_ITERATOR);
    assertEquals(3, traced.size());
    assertSame(root, traced.get(0));
    assertSame(child1, traced.get(1));
    assertSame(child2, traced.get(2));
}
Also used : JsonArray(io.vertx.core.json.JsonArray) JsonObject(io.vertx.core.json.JsonObject) JsonObject(io.vertx.core.json.JsonObject) JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 22 with JsonPointer

use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.

the class JsonPointerTest method testEncodingParsing.

@Test
public void testEncodingParsing() {
    JsonPointer pointer = JsonPointer.create().append("hell/o").append("worl~d");
    assertEquals("/hell~1o/worl~0d", pointer.toString());
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 23 with JsonPointer

use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.

the class JsonPointerTest method testIsParentWithRootPointer.

@Test
public void testIsParentWithRootPointer() {
    JsonPointer parent = JsonPointer.fromURI(URI.create("yaml/valid/refs/Circular.yaml#"));
    JsonPointer child = JsonPointer.fromURI(URI.create("yaml/valid/refs/Circular.yaml#/properties/parent"));
    assertTrue(parent.isParent(child));
    assertFalse(child.isParent(parent));
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 24 with JsonPointer

use of io.vertx.core.json.pointer.JsonPointer in project vert.x by eclipse.

the class JsonPointerTest method testNullQuerying.

@Test
public void testNullQuerying() {
    JsonPointer pointer = JsonPointer.from("/hello/world");
    assertNull(pointer.queryJson(null));
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Aggregations

JsonPointer (io.vertx.core.json.pointer.JsonPointer)24 Test (org.junit.Test)23 JsonObject (io.vertx.core.json.JsonObject)8 JsonArray (io.vertx.core.json.JsonArray)5 ArrayList (java.util.ArrayList)1