use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class AndPredicateTest method accept_whenInnerPredicateChangedOnAccept_thenReturnAndNewAndPredicate.
@Test
public void accept_whenInnerPredicateChangedOnAccept_thenReturnAndNewAndPredicate() {
Visitor mockVisitor = createPassthroughVisitor();
Indexes mockIndexes = mock(Indexes.class);
Predicate transformed = mock(Predicate.class);
Predicate innerPredicate = createMockVisitablePredicate(transformed);
Predicate[] innerPredicates = new Predicate[1];
innerPredicates[0] = innerPredicate;
AndPredicate andPredicate = new AndPredicate(innerPredicates);
AndPredicate result = (AndPredicate) andPredicate.accept(mockVisitor, mockIndexes);
assertThat(result, not(sameInstance(andPredicate)));
Predicate[] newInnerPredicates = result.predicates;
assertThat(newInnerPredicates, arrayWithSize(1));
assertThat(newInnerPredicates[0], equalTo(transformed));
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class CompositeIndexVisitorTest method before.
@Before
public void before() {
indexes = mock(Indexes.class);
o123 = mock(InternalIndex.class);
when(o123.isOrdered()).thenReturn(true);
when(o123.getComponents()).thenReturn(components("a1", "a2", "a3"));
u321 = mock(InternalIndex.class);
when(u321.isOrdered()).thenReturn(false);
when(u321.getComponents()).thenReturn(components("a3", "a2", "a1"));
o567 = mock(InternalIndex.class);
when(o567.isOrdered()).thenReturn(true);
when(o567.getComponents()).thenReturn(components("a5", "a6", "a7"));
// needed to test the preference of shorter indexes over longer ones
InternalIndex o1234 = mock(InternalIndex.class);
when(o1234.isOrdered()).thenReturn(true);
when(o1234.getComponents()).thenReturn(components("a1", "a2", "a3", "a4"));
when(indexes.getCompositeIndexes()).thenReturn(new InternalIndex[] { o1234, o123, u321, o567 });
visitor = new CompositeIndexVisitor();
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class EmptyOptimizerTest method optimize_returnsOriginalPredicate.
@Test
public void optimize_returnsOriginalPredicate() {
EmptyOptimizer emptyOptimizer = new EmptyOptimizer();
Predicate predicate = mock(Predicate.class);
Indexes indexes = mock(Indexes.class);
Predicate result = emptyOptimizer.optimize(predicate, indexes);
assertSame(predicate, result);
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class NotPredicateTest method accept_whenNullPredicate_thenReturnItself.
@Test
public void accept_whenNullPredicate_thenReturnItself() {
Visitor mockVisitor = createPassthroughVisitor();
Indexes mockIndexes = mock(Indexes.class);
NotPredicate notPredicate = new NotPredicate(null);
NotPredicate result = (NotPredicate) notPredicate.accept(mockVisitor, mockIndexes);
assertThat(result, sameInstance(notPredicate));
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class NotPredicateTest method accept_whenPredicateChangedOnAccept_thenReturnAndNewNotPredicate.
@Test
public void accept_whenPredicateChangedOnAccept_thenReturnAndNewNotPredicate() {
Visitor mockVisitor = createPassthroughVisitor();
Indexes mockIndexes = mock(Indexes.class);
Predicate transformed = mock(Predicate.class);
Predicate predicate = createMockVisitablePredicate(transformed);
NotPredicate notPredicate = new NotPredicate(predicate);
NotPredicate result = (NotPredicate) notPredicate.accept(mockVisitor, mockIndexes);
assertThat(result, not(sameInstance(notPredicate)));
assertThat(result.predicate, equalTo(transformed));
}
Aggregations