use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testNestedQueryInArray_whenAnyMatchesMultipleNestedObjects_shouldReturnAllMatching.
@Test
public void testNestedQueryInArray_whenAnyMatchesMultipleNestedObjects_shouldReturnAllMatching() {
JsonValue array1 = Json.array();
array1.asArray().add(createNameAgeOnDuty("a", 50, false)).add(createNameAgeOnDuty("b", 30, true)).add(createNameAgeOnDuty("c", 32, true)).add(createNameAgeOnDuty("d", 17, false));
JsonValue array2 = Json.array();
array2.asArray().add(createNameAgeOnDuty("e", 10, false)).add(createNameAgeOnDuty("f", 20, true)).add(createNameAgeOnDuty("g", 30, true)).add(createNameAgeOnDuty("h", 40, false));
JsonValue array3 = Json.array();
array3.asArray().add(createNameAgeOnDuty("i", 26, false)).add(createNameAgeOnDuty("j", 24, true)).add(createNameAgeOnDuty("k", 1, true)).add(createNameAgeOnDuty("l", 90, false));
JsonObject obj1 = Json.object();
obj1.add("arr", array1);
JsonObject obj2 = Json.object();
obj2.add("arr", array2);
JsonObject obj3 = Json.object();
obj3.add("arr", array3);
IMap<String, HazelcastJsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", obj1);
HazelcastJsonValue p2 = putJsonString(map, "two", obj2);
HazelcastJsonValue p3 = putJsonString(map, "three", obj3);
Collection<HazelcastJsonValue> vals = map.values(Predicates.greaterThan("arr[any].age", 40));
assertEquals(2, vals.size());
assertTrue(vals.contains(p1));
assertTrue(vals.contains(p3));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method putWithJsonStringKey.
private static String putWithJsonStringKey(Map map, JsonValue key, String value) {
HazelcastJsonValue lazyKey = new HazelcastJsonValue(key.toString());
map.put(lazyKey, value);
return value;
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method putWithJsonStringKey.
private static String putWithJsonStringKey(Map map, String name, int age, boolean onDuty) {
String f = createNameAgeOnDuty(name, age, onDuty).toString();
HazelcastJsonValue json = new HazelcastJsonValue(f);
map.put(json, name);
return name;
}
use of com.hazelcast.core.HazelcastJsonValue 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());
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class JsonSchemaHelperTest method testQueryToNonTerminalValueCreatesPattern.
@Test
public void testQueryToNonTerminalValueCreatesPattern() throws IOException {
JsonObject object = Json.object().add("a", Json.object().add("x", 1).add("y", 2)).add("b", false);
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(object.toString()));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
JsonPattern pattern = JsonSchemaHelper.createPattern(input, description, splitPath("a"));
assertEquals(new JsonPattern(asList(0)), pattern);
}
Aggregations