Search in sources :

Example 1 with ChildPortableObject

use of com.hazelcast.nio.serialization.PortableTest.ChildPortableObject in project hazelcast by hazelcast.

the class QueryBasicTest method testQueryPortableField.

@Test(expected = QueryException.class)
public void testQueryPortableField() {
    Config config = getConfig();
    HazelcastInstance instance = createHazelcastInstance(config);
    IMap<Object, Object> map = instance.getMap(randomMapName());
    map.put(1, new GrandParentPortableObject(1, new ParentPortableObject(1L, new ChildPortableObject(1L))));
    Collection<Object> values = map.values(new SqlPredicate("child > 0"));
    values.size();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ChildPortableObject(com.hazelcast.nio.serialization.PortableTest.ChildPortableObject) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) ParentPortableObject(com.hazelcast.nio.serialization.PortableTest.ParentPortableObject) GrandParentPortableObject(com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject) SqlPredicate(com.hazelcast.query.SqlPredicate) EntryObject(com.hazelcast.query.EntryObject) ParentPortableObject(com.hazelcast.nio.serialization.PortableTest.ParentPortableObject) GrandParentPortableObject(com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject) ChildPortableObject(com.hazelcast.nio.serialization.PortableTest.ChildPortableObject) GrandParentPortableObject(com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with ChildPortableObject

use of com.hazelcast.nio.serialization.PortableTest.ChildPortableObject in project hazelcast by hazelcast.

the class QueryBasicTest method testQueryUsingNestedPortableObject.

private void testQueryUsingNestedPortableObject(Config config, String name) {
    addPortableFactories(config);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    IMap<String, GrandParentPortableObject> map = instance2.getMap(name);
    String key = generateKeyOwnedBy(instance1);
    map.put(key, new GrandParentPortableObject(1, new ParentPortableObject(1L, new ChildPortableObject(1L))));
    waitAllForSafeState(instance1, instance2);
    Collection<GrandParentPortableObject> values = map.values(new SqlPredicate("child.timestamp > 0"));
    assertEquals(1, values.size());
    values = map.values(new SqlPredicate("child.child.timestamp > 0"));
    assertEquals(1, values.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ChildPortableObject(com.hazelcast.nio.serialization.PortableTest.ChildPortableObject) ParentPortableObject(com.hazelcast.nio.serialization.PortableTest.ParentPortableObject) GrandParentPortableObject(com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject) SqlPredicate(com.hazelcast.query.SqlPredicate) GrandParentPortableObject(com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 3 with ChildPortableObject

use of com.hazelcast.nio.serialization.PortableTest.ChildPortableObject in project hazelcast by hazelcast.

the class QueryBasicTest method testSqlQueryUsingPortable__KeyField.

@Test
public void testSqlQueryUsingPortable__KeyField() {
    Config config = getConfig();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    factory.newHazelcastInstance(config);
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    IMap<Object, Object> map = instance.getMap(randomMapName());
    Object key = new ChildPortableObject(123L);
    Object value = "value";
    map.put(key, value);
    Collection<Object> values = map.values(new SqlPredicate("__key.timestamp = 123"));
    assertEquals(1, values.size());
    assertEquals(value, values.iterator().next());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ChildPortableObject(com.hazelcast.nio.serialization.PortableTest.ChildPortableObject) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) SqlPredicate(com.hazelcast.query.SqlPredicate) EntryObject(com.hazelcast.query.EntryObject) ParentPortableObject(com.hazelcast.nio.serialization.PortableTest.ParentPortableObject) GrandParentPortableObject(com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject) ChildPortableObject(com.hazelcast.nio.serialization.PortableTest.ChildPortableObject) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 ChildPortableObject (com.hazelcast.nio.serialization.PortableTest.ChildPortableObject)3 GrandParentPortableObject (com.hazelcast.nio.serialization.PortableTest.GrandParentPortableObject)3 ParentPortableObject (com.hazelcast.nio.serialization.PortableTest.ParentPortableObject)3 SqlPredicate (com.hazelcast.query.SqlPredicate)3 Config (com.hazelcast.config.Config)2 MapConfig (com.hazelcast.config.MapConfig)2 MapIndexConfig (com.hazelcast.config.MapIndexConfig)2 EntryObject (com.hazelcast.query.EntryObject)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2