ModelBasedFlexibleSearchForm extends AbstractModelBasedSearchForm<ID, T> { private void addFilter() { FilterRegion region = new FilterRegion(this); regions.add(region); getFilterLayout().add(region.getLayout()); toggle(true); } ModelBasedFlexibleSearchForm(Searchable<T> searchable, EntityModel<T> entityModel, FormOptions formOptions);  ModelBasedFlexibleSearchForm(Searchable<T> searchable, EntityModel<T> entityModel, FormOptions formOptions,
            List<SerializablePredicate<T>> defaultFilters, Map<String, SerializablePredicate<?>> fieldFilters); @SuppressWarnings({ "unchecked", "rawtypes" }) void addFilter(AttributeModel am, FlexibleFilterType filterType, Object value, Object auxValue); @Override void clear(); List<FlexibleFilterDefinition> extractFilterDefinitions(); Button getAddFilterButton(); Set<String> getBasicStringFilterProperties(); FlexibleFilterType getDefaultFilterType(AttributeModel am); FilterRegion getFilterRegion(AttributeModel attributeModel); FilterRegion getFilterRegion(String path); boolean hasFilter(AttributeModel attributeModel); @Override void refresh(); void restoreFilterDefinitions(List<FlexibleFilterDefinition> definitions); void setBasicStringFilterProperties(Set<String> basicStringFilterProperties); @Override void toggleAdvancedMode();  }
@Test public void testStringContains() { form.addFilter(am, FlexibleFilterType.CONTAINS, "a", null); search(); assertEquals(1, wrapper.getDataProviderSize()); }
@Test public void testStringNotEquals() { form.addFilter(am, FlexibleFilterType.NOT_EQUAL, "Bob", null); search(); assertEquals(1, wrapper.getDataProviderSize()); }
@Test public void testStringNotContains() { form.addFilter(am, FlexibleFilterType.NOT_CONTAINS, "x", null); search(); assertEquals(2, wrapper.getDataProviderSize()); }
@Test public void testStringStartsWith() { form.addFilter(am, FlexibleFilterType.STARTS_WITH, "a", null); search(); assertEquals(0, wrapper.getDataProviderSize()); }
@Test public void testNotStringStartsWith() { form.addFilter(am, FlexibleFilterType.NOT_STARTS_WITH, "a", null); search(); assertEquals(2, wrapper.getDataProviderSize()); }
@Test public void testNumeric() { am = em.getAttributeModel("age"); form.addFilter(am, FlexibleFilterType.EQUALS, "11", null); search(); assertEquals(1, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.BETWEEN, "11", "14"); search(); assertEquals(2, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.GREATER_THAN, "12", null); search(); assertEquals(0, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.LESS_THAN, "12", null); search(); assertEquals(1, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.LESS_OR_EQUAL, "12", null); search(); assertEquals(2, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.GREATER_OR_EQUAL, "13", null); search(); assertEquals(0, wrapper.getDataProviderSize()); }
@Test public void testEnum() { am = em.getAttributeModel("someEnum"); form.addFilter(am, FlexibleFilterType.EQUALS, TestEnum.A, null); search(); assertEquals(0, wrapper.getDataProviderSize()); }
@Test public void testBoolean() { am = em.getAttributeModel("someBoolean"); form.addFilter(am, FlexibleFilterType.EQUALS, true, null); search(); assertEquals(0, wrapper.getDataProviderSize()); }
@Test public void testBigDecimal() { am = em.getAttributeModel("rate"); form.addFilter(am, FlexibleFilterType.EQUALS, "4", null); search(); assertEquals(1, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.BETWEEN, "1", "5"); search(); assertEquals(2, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.GREATER_THAN, "3", null); search(); assertEquals(1, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.LESS_THAN, "2", null); search(); assertEquals(0, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.LESS_OR_EQUAL, "3", null); search(); assertEquals(1, wrapper.getDataProviderSize()); form.addFilter(am, FlexibleFilterType.GREATER_OR_EQUAL, "4", null); search(); assertEquals(1, wrapper.getDataProviderSize()); }