use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testQueryOnArray_whenAnyIsUsed.
@Test
public void testQueryOnArray_whenAnyIsUsed() {
JsonObject value1 = Json.object();
JsonObject value2 = Json.object();
JsonObject value3 = Json.object();
JsonArray array1 = Json.array(new int[] { 1, 2, 3, 4, 20 });
JsonArray array2 = Json.array(new int[] { 10, 20, 30 });
JsonArray array3 = Json.array(new int[] { 100, 200, 300, 400 });
value1.add("numbers", array1);
value2.add("numbers", array2);
value3.add("numbers", array3);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
putJsonString(map, "one", value1);
HazelcastJsonValue p2 = putJsonString(map, "two", value2);
HazelcastJsonValue p3 = putJsonString(map, "three", value3);
Collection<JsonValue> vals = map.values(Predicates.greaterThan("numbers[any]", 20));
assertEquals(2, vals.size());
assertTrue(vals.contains(p2));
assertTrue(vals.contains(p3));
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MapAggregationJsonTest method createJsonString.
private String createJsonString(String stringValue, long longValue, double doubleValue, long nestedLongValue) {
JsonObject object = Json.object();
JsonArray array = new JsonArray();
array.add(Json.object().add("nestedArrayObject", Json.object().add("secondary", Json.object().add("nestedObjectLongValue", nestedLongValue))));
object.add("nestedArray", array);
object.add("stringValue", stringValue).add("longValue", longValue).add("doubleValue", doubleValue).add("nestedObject", Json.object().add("nestedLongValue", nestedLongValue)).add("stringValueArray", Json.array("nested0 " + stringValue, "nested1 " + stringValue));
return object.toString();
}
use of com.hazelcast.internal.json.JsonArray 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());
}
use of com.hazelcast.internal.json.JsonArray 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());
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testSkipsNestedObjectsInAnyQuery.
@Test
public void testSkipsNestedObjectsInAnyQuery() {
JsonObject value1 = Json.object();
JsonObject value2 = Json.object();
JsonObject value3 = Json.object();
JsonObject innerObject = Json.object().add("s1", 1001).add("s2", 1002);
JsonArray array1 = Json.array();
array1.add(1).add(2).add(innerObject).add(3).add(4).add(20);
JsonArray array2 = Json.array(new int[] { 10, 20, 30 });
JsonArray array3 = Json.array(new int[] { 100, 200, 300, 400 });
value1.add("numbers", array1);
value2.add("numbers", array2);
value3.add("numbers", array3);
IMap<String, HazelcastJsonValue> map = instance.getMap(randomMapName());
putJsonString(map, "one", value1);
HazelcastJsonValue p2 = putJsonString(map, "two", value2);
HazelcastJsonValue p3 = putJsonString(map, "three", value3);
Collection<HazelcastJsonValue> vals = map.values(Predicates.greaterThan("numbers[any]", 20));
assertEquals(2, vals.size());
assertTrue(vals.contains(p2));
assertTrue(vals.contains(p3));
}
Aggregations