use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method test_nested_json.
@Test
public void test_nested_json() {
IMap<Integer, HazelcastJsonValue> map = instance.getMap(randomMapName());
map.put(1, new HazelcastJsonValue(nestedJsonString()));
Long sum = map.aggregate(Aggregators.longSum("list[any].secondLevelItem.thirdLevelItem"));
assertEquals(6L, sum.longValue());
}
use of com.hazelcast.core.HazelcastJsonValue 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);
}
use of com.hazelcast.core.HazelcastJsonValue 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);
}
use of com.hazelcast.core.HazelcastJsonValue 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());
}
use of com.hazelcast.core.HazelcastJsonValue 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());
}
Aggregations