Search in sources :

Example 61 with HazelcastJsonValue

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();
    }
}
Also used : NavigableJsonInputAdapter(com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue)

Example 62 with HazelcastJsonValue

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 63 with HazelcastJsonValue

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"));
}
Also used : IMap(com.hazelcast.map.IMap) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 64 with HazelcastJsonValue

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);
}
Also used : IMap(com.hazelcast.map.IMap) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) Collection(java.util.Collection) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 65 with HazelcastJsonValue

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);
        }
    }
}
Also used : MapBackupAccessor(com.hazelcast.test.backup.MapBackupAccessor) HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) Record(com.hazelcast.map.impl.record.Record) JsonMetadata(com.hazelcast.query.impl.JsonMetadata)

Aggregations

HazelcastJsonValue (com.hazelcast.core.HazelcastJsonValue)99 Test (org.junit.Test)80 QuickTest (com.hazelcast.test.annotation.QuickTest)74 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)67 JsonObject (com.hazelcast.internal.json.JsonObject)25 JsonValue (com.hazelcast.internal.json.JsonValue)19 NavigableJsonInputAdapter (com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter)12 JsonArray (com.hazelcast.internal.json.JsonArray)9 IMap (com.hazelcast.map.IMap)9 Map (java.util.Map)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 Data (com.hazelcast.internal.serialization.Data)5 JsonSchemaNode (com.hazelcast.json.internal.JsonSchemaNode)3 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)2 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)2 CompactGenericRecord (com.hazelcast.internal.serialization.impl.compact.CompactGenericRecord)2 PortableGenericRecord (com.hazelcast.internal.serialization.impl.portable.PortableGenericRecord)2 StringUtil.bytesToString (com.hazelcast.internal.util.StringUtil.bytesToString)2 ExpressionValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionValue)2