use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class AbstractJsonSchemaTest method validateJson.
protected void validateJson(String originalString, JsonValue jsonValue) throws IOException {
NavigableJsonInputAdapter input = toAdapter(new HazelcastJsonValue(originalString));
JsonSchemaNode description = JsonSchemaHelper.createSchema(createParserFromInput(input));
if (jsonValue.isObject()) {
validateJsonObject(originalString, new JsonPattern(), jsonValue.asObject(), description, input, null);
} else if (jsonValue.isArray()) {
validateJsonArray(originalString, new JsonPattern(), jsonValue.asArray(), description, input, null);
} else {
// shoult not reach here
fail();
}
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class JsonMetadataCreationMigrationTest method testMetadataIsCreatedWhenRecordsAreMigrated.
@Test
public void testMetadataIsCreatedWhenRecordsAreMigrated() throws InterruptedException {
HazelcastInstance instance = factory.newHazelcastInstance(getConfig());
final IMap<HazelcastJsonValue, HazelcastJsonValue> map = instance.getMap(randomMapName());
for (int i = 0; i < ENTRY_COUNT; i++) {
map.put(createJsonValue("key", i), createJsonValue("value", i));
}
for (int i = 1; i < NODE_COUNT; i++) {
factory.newHazelcastInstance(getConfig());
}
waitAllForSafeState(factory.getAllHazelcastInstances());
warmUpPartitions(factory.getAllHazelcastInstances());
assertMetadataCreatedEventually(map.getName());
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonMixedTypeTest method testPutGet.
@Test
public void testPutGet() {
IMap map = instance.getMap(randomMapName());
map.put("k_int", 5);
map.put("k_json", new HazelcastJsonValue("10"));
map.put("k_int_2", 11);
assertEquals(5, map.get("k_int"));
assertEquals(10, Json.parse(((HazelcastJsonValue) map.get("k_json")).toString()).asInt());
assertEquals(11, map.get("k_int_2"));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonMixedTypeTest method testThisPredicate.
@Test
public void testThisPredicate() {
IMap map = instance.getMap(randomMapName());
map.put("k_int", 5);
map.put("k_json", new HazelcastJsonValue("10"));
map.put("k_int_2", 11);
Collection vals = map.values(Predicates.greaterEqual("this", 8));
assertEquals(2, vals.size());
assertContains(vals, new HazelcastJsonValue("10"));
assertContains(vals, 11);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class JsonMetadataCreationTest method assertMetadataCreated.
private void assertMetadataCreated(String mapName, int replicaCount) {
for (int i = 0; i < replicaCount; i++) {
MapBackupAccessor mapBackupAccessor = (MapBackupAccessor) TestBackupUtils.newMapAccessor(instances, mapName, i);
for (int j = 0; j < ENTRY_COUNT; j++) {
Record record = mapBackupAccessor.getRecord(createJsonValue("key", j));
assertNotNull(record);
HazelcastJsonValue jsonValue = createJsonValue("key", j);
JsonMetadata metadata = getMetadata(mapName, jsonValue, i);
assertMetadata("Replica index=" + i, metadata);
}
}
}
Aggregations