use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class LikePredicateTest method likePredicateIsNotIndexed_whenPercentWildcardIsUsedAtTheBeginning.
@Test
public void likePredicateIsNotIndexed_whenPercentWildcardIsUsedAtTheBeginning() {
QueryContext queryContext = mock(QueryContext.class);
when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.SORTED));
assertFalse(new LikePredicate("this", "%string").isIndexed(queryContext));
}
use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class LikePredicateTest method likePredicateIsNotIndexed_whenPercentWildcardIsNotTheLastSymbol.
@Test
public void likePredicateIsNotIndexed_whenPercentWildcardIsNotTheLastSymbol() {
QueryContext queryContext = mock(QueryContext.class);
when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.SORTED));
assertFalse(new LikePredicate("this", "sub%str").isIndexed(queryContext));
assertFalse(new LikePredicate("this", "sub% ").isIndexed(queryContext));
}
use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class LikePredicateTest method likePredicateIsIndexed_whenPercentWildcardIsUsed_andIndexIsSorted.
@Test
public void likePredicateIsIndexed_whenPercentWildcardIsUsed_andIndexIsSorted() {
QueryContext queryContext = mock(QueryContext.class);
when(queryContext.matchIndex("this", QueryContext.IndexMatchHint.PREFER_ORDERED)).thenReturn(createIndex(IndexType.SORTED));
assertTrue(new LikePredicate("this", "sub%").isIndexed(queryContext));
assertTrue(new LikePredicate("this", "sub\\\\%").isIndexed(queryContext));
assertTrue(new LikePredicate("this", "sub\\%string%").isIndexed(queryContext));
assertTrue(new LikePredicate("this", "sub\\_string%").isIndexed(queryContext));
}
use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class PredicatesTest method testNotEqualsPredicateDoesNotUseIndex.
@Test
public void testNotEqualsPredicateDoesNotUseIndex() {
Index dummyIndex = new IndexImpl("foo", false, ss, Extractors.empty());
QueryContext mockQueryContext = mock(QueryContext.class);
when(mockQueryContext.getIndex(anyString())).thenReturn(dummyIndex);
NotEqualPredicate p = new NotEqualPredicate("foo", "bar");
boolean indexed = p.isIndexed(mockQueryContext);
assertFalse(indexed);
}
use of com.hazelcast.query.impl.QueryContext in project hazelcast by hazelcast.
the class NotEqualPredicateTest method filter_givenAttributeNameIsFoo_whenTheFooFieldIsIndex_thenReturnsNullAndDoesNotTouchQueryContext.
@Test
public void filter_givenAttributeNameIsFoo_whenTheFooFieldIsIndex_thenReturnsNullAndDoesNotTouchQueryContext() {
/** see {@link #isIndexed_givenAttributeNameIsFoo_whenTheFooFieldIsIndexed_returnFalse()} */
String fieldName = "foo";
NotEqualPredicate predicate = new NotEqualPredicate(fieldName, "foo");
QueryContext queryContext = newMockContextWithIndex(fieldName);
Set<QueryableEntry> filter = predicate.filter(queryContext);
assertNull(filter);
verifyZeroInteractions(queryContext);
}
Aggregations