Search in sources :

Example 16 with JsonPointer

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

the class JsonPointerTest method testBuilding.

@Test
public void testBuilding() {
    List<String> keys = new ArrayList<>();
    keys.add("hello");
    keys.add("world");
    JsonPointer pointer = new JsonPointerImpl(URI.create("#"), keys);
    assertEquals("/hello/world", pointer.toString());
}
Also used : ArrayList(java.util.ArrayList) JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 17 with JsonPointer

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

the class JsonPointerTest method testNullQueryingRootPointer.

@Test
public void testNullQueryingRootPointer() {
    JsonPointer pointer = JsonPointer.create();
    assertNull(pointer.queryJson(null));
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 18 with JsonPointer

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

the class JsonPointerTest method testURIJsonPointerEncodedParsing.

@Test
public void testURIJsonPointerEncodedParsing() {
    JsonPointer pointer = JsonPointer.fromURI(URI.create("http://www.example.org#/hell~1o/worl~0d"));
    assertEquals("/hell~1o/worl~0d", pointer.toString());
    assertEquals(URI.create("http://www.example.org#/hell~1o/worl~0d"), pointer.toURI());
}
Also used : JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 19 with JsonPointer

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

the class JsonPointerTest method testRootPointer.

@Test
public void testRootPointer() {
    JsonPointer pointer = JsonPointer.create();
    JsonArray array = new JsonArray();
    JsonObject obj = new JsonObject().put("hello", new JsonObject().put("world", 2).put("worl", "wrong")).put("helo", new JsonObject().put("world", "wrong").put("worl", "wrong"));
    array.add(obj);
    array.add(new JsonObject().put("hello", new JsonObject().put("world", 1).put("worl", "wrong")).put("helo", new JsonObject().put("world", "wrong").put("worl", "wrong")));
    assertEquals(array, pointer.queryJson(array));
    assertEquals(obj, pointer.queryJson(obj));
    assertEquals("hello", pointer.queryJson("hello"));
}
Also used : JsonArray(io.vertx.core.json.JsonArray) JsonObject(io.vertx.core.json.JsonObject) JsonPointer(io.vertx.core.json.pointer.JsonPointer) Test(org.junit.Test)

Example 20 with JsonPointer

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

the class JsonPointerTest method testURIEncodedParsing.

@Test
public void testURIEncodedParsing() {
    JsonPointer pointer = JsonPointer.fromURI(URI.create("http://www.example.org#/hello/world/%5Ea"));
    assertEquals("/hello/world/^a", pointer.toString());
    assertEquals(URI.create("http://www.example.org#/hello/world/%5Ea"), pointer.toURI());
}
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