use of com.hazelcast.core.HazelcastJsonValue 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));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testNonTerminalAttributeIs_queriedWithNotEqualsNull_shouldReturn.
@Test
public void testNonTerminalAttributeIs_queriedWithNotEqualsNull_shouldReturn() {
String jsonWithNonTerminalQueryField = Json.object().add("user", Json.object().add("name", "abc").add("age", 23)).toString();
IMap<Integer, HazelcastJsonValue> map = instance.getMap(randomMapName());
map.put(1, new HazelcastJsonValue(jsonWithNonTerminalQueryField));
Collection<Integer> keys = map.keySet(Predicates.notEqual("user", null));
assertEquals(1, keys.size());
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method putJsonString.
private static HazelcastJsonValue putJsonString(Map map, String name, int age, boolean onDuty) {
String f = createNameAgeOnDuty(name, age, onDuty).toString();
HazelcastJsonValue json = new HazelcastJsonValue(f);
map.put(name, json);
return json;
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testSecondTimeKnownPatternIsUsed.
@Test
public void testSecondTimeKnownPatternIsUsed() {
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "a", 30, true);
HazelcastJsonValue p2 = putJsonString(map, "b", 20, false);
HazelcastJsonValue p3 = putJsonString(map, "c", 10, true);
Collection<JsonValue> vals = map.values(Predicates.greaterEqual("name", "b"));
assertEquals(2, vals.size());
assertTrue(vals.contains(p2));
assertTrue(vals.contains(p3));
vals = map.values(Predicates.greaterEqual("name", "b"));
assertEquals(2, vals.size());
assertTrue(vals.contains(p2));
assertTrue(vals.contains(p3));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class JsonValueSerializationTest method testSerializeDeserializeJsonValue.
@Test
public void testSerializeDeserializeJsonValue() {
HazelcastJsonValue jsonValue = new HazelcastJsonValue("{ \"key\": \"value\" }");
Data jsonData = serializationService.toData(jsonValue);
HazelcastJsonValue jsonDeserialized = serializationService.toObject(jsonData);
assertEquals(jsonValue, jsonDeserialized);
}
Aggregations