Search in sources :

Example 16 with Value

use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.

the class QueryIndexTest method testPredicateNotEqualWithIndex.

@Test(timeout = 1000 * 60)
public void testPredicateNotEqualWithIndex() {
    HazelcastInstance instance = createTestHazelcastInstance();
    IMap<Integer, Value> map1 = instance.getMap("testPredicateNotEqualWithIndex-ordered");
    IMap<Integer, Value> map2 = instance.getMap("testPredicateNotEqualWithIndex-unordered");
    testPredicateNotEqualWithIndex(map1, true);
    testPredicateNotEqualWithIndex(map2, false);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Value(com.hazelcast.query.SampleTestObjects.Value) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 17 with Value

use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.

the class QueryIndexTest method testQueryDoesNotMatchOldResults_whenEntriesAreUpdated.

@Test(timeout = 1000 * 60)
public void testQueryDoesNotMatchOldResults_whenEntriesAreUpdated() {
    HazelcastInstance instance = createTestHazelcastInstance();
    IMap<String, SampleTestObjects.Value> map = instance.getMap("default");
    map.addIndex(IndexType.SORTED, "name");
    map.put("0", new Value("name"));
    map.put("0", new Value("newName"));
    Collection<SampleTestObjects.Value> values = map.values(Predicates.sql("name='name'"));
    assertEquals(0, values.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Value(com.hazelcast.query.SampleTestObjects.Value) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with Value

use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.

the class QueryIndexTest method issue685RemoveIndexesOnClear.

@Test(timeout = 1000 * 60)
public void issue685RemoveIndexesOnClear() {
    HazelcastInstance instance = createTestHazelcastInstance();
    IMap<String, SampleTestObjects.Value> map = instance.getMap("default");
    map.addIndex(IndexType.SORTED, "name");
    for (int i = 0; i < 4; i++) {
        Value v = new Value("name" + i);
        map.put("" + i, v);
    }
    map.clear();
    Predicate predicate = Predicates.sql("name='name0'");
    Collection<SampleTestObjects.Value> values = map.values(predicate);
    assertEquals(0, values.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Value(com.hazelcast.query.SampleTestObjects.Value) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with Value

use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.

the class QueryIndexTest method testPredicateNotEqualWithIndex.

private void testPredicateNotEqualWithIndex(IMap<Integer, Value> map, boolean ordered) {
    map.addIndex(ordered ? IndexType.SORTED : IndexType.HASH, "name");
    map.put(1, new Value("abc", 1));
    map.put(2, new Value("xyz", 2));
    map.put(3, new Value("aaa", 3));
    assertEquals(3, map.values(Predicates.sql("name != 'aac'")).size());
    assertEquals(2, map.values(Predicates.sql("index != 2")).size());
    assertEquals(3, map.values(Predicates.sql("name <> 'aac'")).size());
    assertEquals(2, map.values(Predicates.sql("index <> 2")).size());
    assertEquals(3, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").notEqual("aac")).size());
    assertEquals(2, map.values(Predicates.newPredicateBuilder().getEntryObject().get("index").notEqual(2)).size());
}
Also used : Value(com.hazelcast.query.SampleTestObjects.Value)

Example 20 with Value

use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.

the class QueryBasicTest method testPredicateStringAttribute.

private void testPredicateStringAttribute(IMap<Integer, Value> map) {
    map.put(1, new Value("abc"));
    map.put(2, new Value("xyz"));
    map.put(3, new Value("aaa"));
    map.put(4, new Value("zzz"));
    map.put(5, new Value("klm"));
    map.put(6, new Value("prs"));
    map.put(7, new Value("prs"));
    map.put(8, new Value("def"));
    map.put(9, new Value("qwx"));
    assertEquals(8, map.values(Predicates.sql("name > 'aac'")).size());
    assertEquals(9, map.values(Predicates.sql("name between 'aaa' and 'zzz'")).size());
    assertEquals(7, map.values(Predicates.sql("name < 't'")).size());
    assertEquals(6, map.values(Predicates.sql("name >= 'gh'")).size());
    assertEquals(8, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").greaterThan("aac")).size());
    assertEquals(9, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").between("aaa", "zzz")).size());
    assertEquals(7, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").lessThan("t")).size());
    assertEquals(6, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").greaterEqual("gh")).size());
}
Also used : Value(com.hazelcast.query.SampleTestObjects.Value)

Aggregations

Value (com.hazelcast.query.SampleTestObjects.Value)25 Test (org.junit.Test)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)20 QuickTest (com.hazelcast.test.annotation.QuickTest)20 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 Predicate (com.hazelcast.query.Predicate)12 ArrayList (java.util.ArrayList)7 ValueType (com.hazelcast.query.SampleTestObjects.ValueType)6 Config (com.hazelcast.config.Config)2 IndexConfig (com.hazelcast.config.IndexConfig)2 MapConfig (com.hazelcast.config.MapConfig)1 EntryObject (com.hazelcast.query.PredicateBuilder.EntryObject)1 SqlPredicate (com.hazelcast.query.impl.predicates.SqlPredicate)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Future (java.util.concurrent.Future)1 Ignore (org.junit.Ignore)1