use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.
the class JsonSchemaHelperTest method testQuerySimpleNestedQuery.
@Test
public void testQuerySimpleNestedQuery() throws IOException {
JsonObject object = Json.object().add("inner", Json.object().add("a", 3).add("b", 5));
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(object.toString()));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
JsonPattern pattern = JsonSchemaHelper.createPattern(input, description, splitPath("inner.b"));
assertEquals(new JsonPattern(asList(0, 1)), pattern);
}
use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.
the class JsonSchemaHelperTest method testOneLevelObject.
@Test
public void testOneLevelObject() throws IOException {
JsonObject object = Json.object().add("a", true).add("b", false).add("c", Json.NULL).add("d", 4).add("e", "asd");
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(object.toString()));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
JsonPattern pattern = JsonSchemaHelper.createPattern(input, description, splitPath("b"));
assertEquals(new JsonPattern(asList(1)), pattern);
JsonValue found = JsonSchemaHelper.findValueWithPattern(input, description, pattern, splitPath("b"));
assertEquals(Json.FALSE, found);
}
use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.
the class AbstractJsonSchemaTest method validateJson.
protected void validateJson(String originalString, JsonValue jsonValue) throws IOException {
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(originalString));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
if (jsonValue.isObject()) {
validateJsonObject(originalString, new JsonPattern(), jsonValue.asObject(), description, input, null);
} else if (jsonValue.isArray()) {
validateJsonArray(originalString, new JsonPattern(), jsonValue.asArray(), description, input, null);
} else {
// shoult not reach here
fail();
}
}
use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.
the class JsonSchemaHelperNullTest method test_givenWrongPattern_returnNull.
private void test_givenWrongPattern_returnNull(String jsonString, String patternPath, String queryPath) throws IOException {
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(jsonString));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
JsonPattern pattern = JsonSchemaHelper.createPattern(input, description, splitPath(patternPath));
JsonValue found = JsonSchemaHelper.findValueWithPattern(input, description, pattern, splitPath(queryPath));
assertNull(found);
}
use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.
the class JsonSchemaHelperMultiValueTest method testAnyPattern.
@Test
public void testAnyPattern() throws IOException {
JsonObject object = Json.object().add("array", Json.array().add(1).add(2).add(3));
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(object.toString()));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
JsonPattern pattern = JsonSchemaHelper.createPattern(input, description, splitPath("array[any]"));
assertEquals(1, pattern.depth());
assertEquals(0, pattern.get(0));
assertTrue(pattern.hasAny());
}
Aggregations