use of com.hazelcast.query.impl.Indexes.SKIP_PARTITIONS_COUNT_CHECK in project hazelcast by hazelcast.
the class EvaluateVisitorTest method before.
@SuppressWarnings("SuspiciousMethodCalls")
@Before
public void before() {
indexes = mock(Indexes.class);
InternalIndex bitmapA = mock(InternalIndex.class);
when(bitmapA.getConverter()).thenReturn(TypeConverters.INTEGER_CONVERTER);
when(bitmapA.getName()).thenReturn("a");
when(indexes.matchIndex(eq("a"), any(), eq(IndexMatchHint.EXACT_NAME), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> EVALUABLE_PREDICATES.contains(invocation.getArgument(1)) ? bitmapA : null);
when(indexes.matchIndex(eq("a"), any(), eq(IndexMatchHint.PREFER_UNORDERED), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> EVALUABLE_PREDICATES.contains(invocation.getArgument(1)) ? bitmapA : null);
InternalIndex bitmapB = mock(InternalIndex.class);
when(bitmapB.getConverter()).thenReturn(TypeConverters.STRING_CONVERTER);
when(bitmapB.getName()).thenReturn("b");
when(indexes.matchIndex(eq("b"), any(), eq(IndexMatchHint.EXACT_NAME), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> EVALUABLE_PREDICATES.contains(invocation.getArgument(1)) ? bitmapB : null);
when(indexes.matchIndex(eq("b"), any(), eq(IndexMatchHint.PREFER_UNORDERED), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> EVALUABLE_PREDICATES.contains(invocation.getArgument(1)) ? bitmapB : null);
InternalIndex bitmapNoConverter = mock(InternalIndex.class);
when(bitmapNoConverter.getName()).thenReturn("nc");
when(bitmapNoConverter.getConverter()).thenReturn(null);
when(indexes.matchIndex(eq("nc"), any(), eq(IndexMatchHint.EXACT_NAME), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> EVALUABLE_PREDICATES.contains(invocation.getArgument(1)) ? bitmapNoConverter : null);
when(indexes.matchIndex(eq("nc"), any(), eq(IndexMatchHint.PREFER_UNORDERED), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> EVALUABLE_PREDICATES.contains(invocation.getArgument(1)) ? bitmapNoConverter : null);
InternalIndex bitmapNoSubPredicates = mock(InternalIndex.class);
when(bitmapNoSubPredicates.getName()).thenReturn("ns");
when(bitmapNoSubPredicates.getConverter()).thenReturn(TypeConverters.INTEGER_CONVERTER);
when(indexes.matchIndex(eq("ns"), any(), eq(IndexMatchHint.EXACT_NAME), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> {
Object clazz = invocation.getArgument(1);
if (clazz == AndPredicate.class || clazz == OrPredicate.class || clazz == NotPredicate.class) {
return null;
} else {
return bitmapNoSubPredicates;
}
});
when(indexes.matchIndex(eq("ns"), any(), eq(IndexMatchHint.PREFER_UNORDERED), eq(SKIP_PARTITIONS_COUNT_CHECK))).then((Answer<InternalIndex>) invocation -> {
Object clazz = invocation.getArgument(1);
if (clazz == AndPredicate.class || clazz == OrPredicate.class || clazz == NotPredicate.class) {
return null;
} else {
return bitmapNoSubPredicates;
}
});
visitor = new EvaluateVisitor();
}
Aggregations