Search in sources :

Example 1 with QueryContext

use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.

the class NotEqualPredicateTest method newMockContextWithIndex.

private QueryContext newMockContextWithIndex(String indexedFieldName) {
    QueryContext queryContext = mock(QueryContext.class);
    Index mockIndex = mock(Index.class);
    when(queryContext.getIndex(indexedFieldName)).thenReturn(mockIndex);
    return queryContext;
}
Also used : Index(com.hazelcast.query.impl.Index) QueryContext(com.hazelcast.query.impl.QueryContext)

Example 2 with QueryContext

use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.

the class NotEqualPredicateTest method isIndexed_givenAttributeNameIsFoo_whenTheFooFieldIsIndexed_returnFalse.

@Test
public void isIndexed_givenAttributeNameIsFoo_whenTheFooFieldIsIndexed_returnFalse() {
    // see https://github.com/hazelcast/hazelcast/pull/5847
    String fieldName = "name";
    NotEqualPredicate name = new NotEqualPredicate(fieldName, "foo");
    QueryContext queryContext = newMockContextWithIndex(fieldName);
    boolean indexed = name.isIndexed(queryContext);
    assertFalse(indexed);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) QueryContext(com.hazelcast.query.impl.QueryContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with QueryContext

use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.

the class LikePredicateTest method likePredicateIsNotIndexed_whenPercentWildcardIsUsedMultipleTimes.

@Test
public void likePredicateIsNotIndexed_whenPercentWildcardIsUsedMultipleTimes() {
    QueryContext queryContext = mock(QueryContext.class);
    when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.SORTED));
    assertFalse(new LikePredicate("this", "sub%string%").isIndexed(queryContext));
}
Also used : QueryContext(com.hazelcast.query.impl.QueryContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with QueryContext

use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.

the class LikePredicateTest method likePredicateIsNotIndexed_whenBitmapIndexIsUsed.

@Test
public void likePredicateIsNotIndexed_whenBitmapIndexIsUsed() {
    QueryContext queryContext = mock(QueryContext.class);
    when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.BITMAP));
    assertFalse(new LikePredicate("this", "string%").isIndexed(queryContext));
}
Also used : QueryContext(com.hazelcast.query.impl.QueryContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with QueryContext

use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.

the class LikePredicateTest method likePredicateIsNotIndexed_whenHashIndexIsUsed.

@Test
public void likePredicateIsNotIndexed_whenHashIndexIsUsed() {
    QueryContext queryContext = mock(QueryContext.class);
    when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.HASH));
    assertFalse(new LikePredicate("this", "string%").isIndexed(queryContext));
}
Also used : QueryContext(com.hazelcast.query.impl.QueryContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

QueryContext (com.hazelcast.query.impl.QueryContext)13 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)8 Index (com.hazelcast.query.impl.Index)2 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Matchers.anyString (org.mockito.Matchers.anyString)2 PartitionMigrationEvent (com.hazelcast.internal.partition.PartitionMigrationEvent)1 Predicate (com.hazelcast.query.Predicate)1 IndexImpl (com.hazelcast.query.impl.IndexImpl)1 EqualPredicate (com.hazelcast.query.impl.predicates.EqualPredicate)1