use of com.blazebit.persistence.EscapeBuilder in project blaze-persistence by Blazebit.
the class FilterTest method verifyLikeFilter.
@SuppressWarnings({ "rawtypes", "unchecked" })
public RestrictionBuilder<?> verifyLikeFilter(AttributeFilterProvider<?> filter, String expression) {
WhereBuilder whereBuilder = Mockito.mock(WhereBuilder.class);
RestrictionBuilder rb = Mockito.mock(RestrictionBuilder.class, Mockito.RETURNS_DEEP_STUBS);
EscapeBuilder eb = Mockito.mock(EscapeBuilder.class);
LikeBuilder lb = Mockito.mock(LikeBuilder.class);
Mockito.when(whereBuilder.where(expression)).thenReturn(rb);
Mockito.when(rb.like()).thenReturn(lb);
Mockito.when(rb.like(false)).thenReturn(lb);
Mockito.when(lb.value("%" + value)).thenReturn(eb);
Mockito.when(lb.value(value + "%")).thenReturn(eb);
Mockito.when(lb.value("%" + value + "%")).thenReturn(eb);
Mockito.when(eb.noEscape()).thenReturn(whereBuilder);
filter.apply(whereBuilder, expression);
return rb;
}
Aggregations