Search in sources :

Example 1 with EscapeBuilder

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;
}
Also used : LikeBuilder(com.blazebit.persistence.LikeBuilder) WhereBuilder(com.blazebit.persistence.WhereBuilder) EscapeBuilder(com.blazebit.persistence.EscapeBuilder) RestrictionBuilder(com.blazebit.persistence.RestrictionBuilder)

Aggregations

EscapeBuilder (com.blazebit.persistence.EscapeBuilder)1 LikeBuilder (com.blazebit.persistence.LikeBuilder)1 RestrictionBuilder (com.blazebit.persistence.RestrictionBuilder)1 WhereBuilder (com.blazebit.persistence.WhereBuilder)1