use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testPagingPredicate.
@Test
public void testPagingPredicate() {
IMap<Integer, HazelcastJsonValue> map = instance.getMap(randomMapName());
for (int i = 0; i < 100; i++) {
String json = Json.object().add("user", randomString()).add("id", i).toString();
map.put(i, new HazelcastJsonValue(json));
}
PagingPredicate<Integer, HazelcastJsonValue> pagingPredicate = Predicates.pagingPredicate(Predicates.alwaysTrue(), 10);
Collection<HazelcastJsonValue> values = map.values(pagingPredicate);
int totalSize = values.size();
while (values.size() > 0) {
int size = values.size();
assertEquals(10, size);
pagingPredicate.nextPage();
values = map.values(pagingPredicate);
totalSize += values.size();
}
assertEquals(100, totalSize);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenObjectIsEmpty.
@Test
public void testValueIsOmitted_whenObjectIsEmpty() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().toString()));
long maxLongValue = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, maxLongValue);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenValueIsNotAnObject.
@Test
public void testValueIsOmitted_whenValueIsNotAnObject() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.value(5).toString()));
long maxLongValue = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, maxLongValue);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenAttributePathIsNotTerminal_count.
@Test
public void testValueIsOmitted_whenAttributePathIsNotTerminal_count() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().add("longValue", Json.object()).toString()));
long count = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>count("longValue"));
assertEquals(OBJECT_COUNT, count);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenAttributePathDoesNotExist.
@Test
public void testValueIsOmitted_whenAttributePathDoesNotExist() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().add("someField", "someValue").toString()));
long maxLongValue = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, maxLongValue);
}
Aggregations