use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class AbstractReplicatedMapListenerTest method testListenWithPredicateWithAttributePath.
@Test
public void testListenWithPredicateWithAttributePath() {
ReplicatedMap<Integer, HazelcastJsonValue> replicatedMap = createClusterAndGetRandomReplicatedMap();
EventCountingListener<Integer, HazelcastJsonValue> listener = new EventCountingListener<>();
replicatedMap.addEntryListener(listener, Predicates.equal("a", "foo"));
replicatedMap.put(1, new HazelcastJsonValue("{\"a\": \"notFoo\"}"));
replicatedMap.put(2, new HazelcastJsonValue("{\"a\": \"foo\"}"));
assertTrueEventually(() -> assertEquals(1, listener.addCount.get()));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class HazelcastJsonValueConstructorTest method test.
@Test
public void test() {
HazelcastJsonValue value = new HazelcastJsonValue("{\"a\": 11}");
HazelcastJsonValueConstructor constructor = new HazelcastJsonValueConstructor(HazelcastJsonValue.class);
HazelcastJsonValue cloned = (HazelcastJsonValue) constructor.createNew(value);
assertEquals(cloned, value);
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class SqlJsonTest method test_topLevelFieldExtraction.
@Test
public void test_topLevelFieldExtraction() {
String name = randomName();
sqlService.execute("CREATE MAPPING " + name + " (" + "id INT EXTERNAL NAME \"__key.id\"" + ", name VARCHAR EXTERNAL NAME \"this.name\"" + ") TYPE " + IMapSqlConnector.TYPE_NAME + ' ' + "OPTIONS (" + '\'' + OPTION_KEY_FORMAT + "'='" + JSON_FLAT_FORMAT + '\'' + ", '" + OPTION_VALUE_FORMAT + "'='" + JSON_FLAT_FORMAT + '\'' + ")");
sqlService.execute("SINK INTO " + name + " VALUES (1, 'Alice')");
assertRowsAnyOrder("SELECT __key, this FROM " + name, singletonList(new Row(new HazelcastJsonValue("{\"id\":1}"), new HazelcastJsonValue("{\"name\":\"Alice\"}"))));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class SqlJsonTest method test_jsonType.
@Test
public void test_jsonType() {
String name = randomName();
String createSql = format("CREATE MAPPING %s TYPE %s ", name, IMapSqlConnector.TYPE_NAME) + "OPTIONS ( " + format("'%s' = 'json'", OPTION_KEY_FORMAT) + format(", '%s' = 'json'", OPTION_VALUE_FORMAT) + ")";
sqlService.execute(createSql);
sqlService.execute("SINK INTO " + name + " VALUES (CAST('[1,2,3]' AS JSON), CAST('[4,5,6]' AS JSON))");
assertRowsAnyOrder("SELECT __key, this FROM " + name, singletonList(new Row(new HazelcastJsonValue("[1,2,3]"), new HazelcastJsonValue("[4,5,6]"))));
}
use of com.hazelcast.core.HazelcastJsonValue in project hazelcast by hazelcast.
the class SqlJsonTest method test_jsonType.
@Test
public void test_jsonType() {
String name = createRandomTopic();
String createSql = format("CREATE MAPPING %s TYPE %s ", name, KafkaSqlConnector.TYPE_NAME) + "OPTIONS ( " + format("'%s' = 'json'", OPTION_KEY_FORMAT) + format(", '%s' = 'json'", OPTION_VALUE_FORMAT) + format(", 'bootstrap.servers' = '%s'", kafkaTestSupport.getBrokerConnectionString()) + ", 'auto.offset.reset' = 'earliest'" + ")";
sqlService.execute(createSql);
assertTopicEventually(name, "INSERT INTO " + name + " VALUES ('[1,2,3]', '[4,5,6]')", createMap("[1,2,3]", "[4,5,6]"));
assertRowsEventuallyInAnyOrder("SELECT * FROM " + name, singletonList(new Row(new HazelcastJsonValue("[1,2,3]"), new HazelcastJsonValue("[4,5,6]"))));
}
Aggregations