use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class JsonSchemaHelperTest method testEmptyStringReturnsNullSchema.
@Test
public void testEmptyStringReturnsNullSchema() throws IOException {
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(""));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
assertNull(description);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenAttributePathIsNotTerminal_distinct.
@Test
public void testValueIsOmitted_whenAttributePathIsNotTerminal_distinct() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().add("longValue", Json.object()).toString()));
Collection<Object> distinctLongValues = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>, Object>distinct("longValue"));
assertEquals(OBJECT_COUNT, distinctLongValues.size());
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenAttributePathIsNotTerminal.
@Test
public void testValueIsOmitted_whenAttributePathIsNotTerminal() {
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>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, count);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonMixedTypeTest method createNameAgeOnDuty.
private HazelcastJsonValue createNameAgeOnDuty(String name, int age, boolean onDuty) {
JsonObject object = Json.object();
object.add("name", name);
object.add("age", age);
object.add("onDuty", onDuty);
return new HazelcastJsonValue(object.toString());
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class AbstractJsonGetterTest method createJsonValueWithRandomStructure.
/**
* Creates a one level json object from given names and values. Each
* value is associated with the respective name in given order. However,
* the order of name-value pairs within object are random
* @param names
* @param values
* @return
*/
private HazelcastJsonValue createJsonValueWithRandomStructure(String[] names, String[] values) {
Random random = new Random();
for (int i = names.length - 1; i > 0; i--) {
int swapIndex = random.nextInt(i + 1);
String tempName = names[i];
names[i] = names[swapIndex];
names[swapIndex] = tempName;
String tempValue = values[i];
values[i] = values[swapIndex];
values[swapIndex] = tempValue;
}
JsonObject object = Json.object();
for (int i = 0; i < names.length; i++) {
object.add(names[i], values[i]);
}
return new HazelcastJsonValue(object.toString());
}
Aggregations