Search in sources :

Example 1 with NavigableJsonInputAdapter

use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.

the class JsonSchemaHelperNullTest method test_givenInvalidPattern_createNullPattern.

private void test_givenInvalidPattern_createNullPattern(String jsonString, String path) throws IOException {
    NavigableJsonInputAdapter inputAdapter = toAdapter(new HazelcastJsonValue(jsonString));
    JsonSchemaNode schemaNode = JsonSchemaHelper.createSchema(createParserFromInput(inputAdapter));
    JsonPattern pattern = JsonSchemaHelper.createPattern(inputAdapter, schemaNode, splitPath(path));
    assertNull(pattern);
}
Also used : NavigableJsonInputAdapter(com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue)

Example 2 with NavigableJsonInputAdapter

use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.

the class JsonSchemaHelperMultiValueTest method testAnyPattern_whenNotArrayOrObject_returnsNull.

@Test
public void testAnyPattern_whenNotArrayOrObject_returnsNull() throws IOException {
    JsonObject object = Json.object().add("scalarValue", 4);
    NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(object.toString()));
    JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
    JsonPattern pattern = JsonSchemaHelper.createPattern(input, description, splitPath("scalarValue[any]"));
    assertNull(pattern);
}
Also used : NavigableJsonInputAdapter(com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with NavigableJsonInputAdapter

use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.

the class JsonSchemaHelperMultiValueTest method testAnyPattern_partsAfterAnyIsOmitted.

@Test
public void testAnyPattern_partsAfterAnyIsOmitted() 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].a"));
    assertEquals(1, pattern.depth());
    assertEquals(0, pattern.get(0));
    assertTrue(pattern.hasAny());
}
Also used : NavigableJsonInputAdapter(com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with NavigableJsonInputAdapter

use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.

the class JsonSchemaHelperMultiValueTest method testAnyPattern__whenFirstItem_partsAfterAnyIsOmitted.

@Test
public void testAnyPattern__whenFirstItem_partsAfterAnyIsOmitted() throws IOException {
    JsonArray object = 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("[any].abc.de"));
    assertEquals(0, pattern.depth());
    assertTrue(pattern.hasAny());
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) NavigableJsonInputAdapter(com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with NavigableJsonInputAdapter

use of com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter in project hazelcast by hazelcast.

the class JsonSchemaHelperMultiValueTest method testAnyPattern_whenFirstItem.

@Test
public void testAnyPattern_whenFirstItem() throws IOException {
    JsonArray object = 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("[any]"));
    assertEquals(0, pattern.depth());
    assertTrue(pattern.hasAny());
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) NavigableJsonInputAdapter(com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastJsonValue (com.hazelcast.core.HazelcastJsonValue)12 NavigableJsonInputAdapter (com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 JsonObject (com.hazelcast.internal.json.JsonObject)6 JsonArray (com.hazelcast.internal.json.JsonArray)2 JsonValue (com.hazelcast.internal.json.JsonValue)2