use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testQueryOnArrayIndex.
@Test
public void testQueryOnArrayIndex() {
JsonObject value1 = Json.object();
JsonObject value2 = Json.object();
JsonObject value3 = Json.object();
JsonArray array1 = Json.array(new int[] { 1, 2, 3, 4, 5 });
JsonArray array2 = Json.array(new int[] { 10, 20, 30, 40, 50 });
JsonArray array3 = Json.array(new int[] { 100, 200, 300, 400, 500 });
value1.add("numbers", array1);
value2.add("numbers", array2);
value3.add("numbers", array3);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", value1);
HazelcastJsonValue p2 = putJsonString(map, "two", value2);
HazelcastJsonValue p3 = putJsonString(map, "three", value3);
Collection<String> vals = map.keySet(Predicates.greaterEqual("numbers[1]", 20));
assertEquals(2, vals.size());
assertTrue(vals.contains("two"));
assertTrue(vals.contains("three"));
}
use of com.hazelcast.internal.json.JsonObject 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.JsonObject 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.JsonObject 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.internal.json.JsonObject 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());
}
Aggregations