Search in sources :

Example 1 with PortableEmployee

use of com.hazelcast.query.SampleObjects.PortableEmployee in project hazelcast by hazelcast.

the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withoutIndex.

@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withoutIndex() {
    String mapName = randomMapName();
    Config config = getConfig();
    config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {

        public Portable create(int classId) {
            return new PortableEmployee();
        }
    });
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
    for (int i = 0; i < 5; i++) {
        map.put(i, new PortableEmployee(i, "name_" + i));
    }
    Collection values = map.values(new SqlPredicate("notExist = name_0 OR a > 1"));
    assertEquals(3, values.size());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Portable(com.hazelcast.nio.serialization.Portable) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) PortableEmployee(com.hazelcast.query.SampleObjects.PortableEmployee) Collection(java.util.Collection) SqlPredicate(com.hazelcast.query.SqlPredicate) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with PortableEmployee

use of com.hazelcast.query.SampleObjects.PortableEmployee in project hazelcast by hazelcast.

the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withIndex.

@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withIndex() {
    String mapName = "default";
    Config config = getConfig();
    config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {

        public Portable create(int classId) {
            return new PortableEmployee();
        }
    });
    config.getMapConfig(mapName).addMapIndexConfig(new MapIndexConfig("notExist", false)).addMapIndexConfig(new MapIndexConfig("n", false));
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
    for (int i = 0; i < 5; i++) {
        map.put(i, new PortableEmployee(i, "name_" + i));
    }
    Collection values = map.values(new SqlPredicate("n = name_2 OR notExist = name_0"));
    assertEquals(1, values.size());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Portable(com.hazelcast.nio.serialization.Portable) MapIndexConfig(com.hazelcast.config.MapIndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) PortableEmployee(com.hazelcast.query.SampleObjects.PortableEmployee) Collection(java.util.Collection) SqlPredicate(com.hazelcast.query.SqlPredicate) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Config (com.hazelcast.config.Config)2 MapIndexConfig (com.hazelcast.config.MapIndexConfig)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Portable (com.hazelcast.nio.serialization.Portable)2 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)2 PortableEmployee (com.hazelcast.query.SampleObjects.PortableEmployee)2 SqlPredicate (com.hazelcast.query.SqlPredicate)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Collection (java.util.Collection)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.Test)2