Search in sources :

Example 16 with Value

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

the class QueryIndexTest method issue685RemoveIndexesOnClear.

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

Example 17 with Value

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

the class QueryIndexTest method testQueryDoesNotMatchOldResults_whenEntriesAreUpdated.

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

Example 18 with Value

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

the class QueryIndexTest method testPredicateNotEqualWithIndex.

private void testPredicateNotEqualWithIndex(IMap<Integer, Value> map, boolean ordered) {
    map.addIndex("name", ordered);
    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(new SqlPredicate("name != 'aac'")).size());
    assertEquals(2, map.values(new SqlPredicate("index != 2")).size());
    assertEquals(3, map.values(new SqlPredicate("name <> 'aac'")).size());
    assertEquals(2, map.values(new SqlPredicate("index <> 2")).size());
    assertEquals(3, map.values(new PredicateBuilder().getEntryObject().get("name").notEqual("aac")).size());
    assertEquals(2, map.values(new PredicateBuilder().getEntryObject().get("index").notEqual(2)).size());
}
Also used : PredicateBuilder(com.hazelcast.query.PredicateBuilder) Value(com.hazelcast.query.SampleObjects.Value) SqlPredicate(com.hazelcast.query.SqlPredicate)

Example 19 with Value

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

the class QueryBasicTest method testPredicateStringAttribute.

/**
     * Github issues 98 and 131
     */
@Test(timeout = 1000 * 60)
public void testPredicateStringAttribute() {
    HazelcastInstance instance = createHazelcastInstance(getConfig());
    IMap<Integer, Value> map = instance.getMap("testPredicateStringWithString");
    testPredicateStringAttribute(map);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Value(com.hazelcast.query.SampleObjects.Value) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 20 with Value

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

the class QueryBasicTest method testPredicateStringAttributesWithIndex.

/**
     * Github issues 98 and 131
     */
@Test(timeout = 1000 * 60)
public void testPredicateStringAttributesWithIndex() {
    HazelcastInstance instance = createHazelcastInstance(getConfig());
    IMap<Integer, Value> map = instance.getMap("testPredicateStringWithStringIndex");
    map.addIndex("name", false);
    testPredicateStringAttribute(map);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Value(com.hazelcast.query.SampleObjects.Value) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Value (com.hazelcast.query.SampleObjects.Value)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)17 Test (org.junit.Test)17 ParallelTest (com.hazelcast.test.annotation.ParallelTest)16 QuickTest (com.hazelcast.test.annotation.QuickTest)16 SqlPredicate (com.hazelcast.query.SqlPredicate)13 Predicate (com.hazelcast.query.Predicate)9 ArrayList (java.util.ArrayList)7 PredicateBuilder (com.hazelcast.query.PredicateBuilder)6 ValueType (com.hazelcast.query.SampleObjects.ValueType)6 Config (com.hazelcast.config.Config)2 MapIndexConfig (com.hazelcast.config.MapIndexConfig)2 MapConfig (com.hazelcast.config.MapConfig)1 EntryObject (com.hazelcast.query.EntryObject)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Future (java.util.concurrent.Future)1 Matchers.anyString (org.mockito.Matchers.anyString)1