ModelBasedSearchDialog extends SimpleModalDialog { @SuppressWarnings("unchecked") public void select(Object selectedItems) { if (selectedItems instanceof Collection) { Collection<T> col = (Collection<T>) selectedItems; for (T t : col) { searchLayout.getGridWrapper().getGrid().select(t); } } else { T t = (T) selectedItems; searchLayout.getGridWrapper().getGrid().select(t); } } ModelBasedSearchDialog(BaseService<ID, T> service, EntityModel<T> entityModel, List<SerializablePredicate<T>> filters,
            List<SortOrder<?>> sortOrders, boolean multiSelect, boolean searchImmediately, FetchJoinInformation... joins); List<SerializablePredicate<T>> getFilters(); SimpleSearchLayout<ID, T> getSearchLayout(); @SuppressWarnings("unchecked") void select(Object selectedItems); void setFilters(List<SerializablePredicate<T>> filters);  }
@Test public void testCreateSingleSelect() { ModelBasedSearchDialog<Integer, TestEntity> dialog = new ModelBasedSearchDialog<>(testEntityService, entityModelFactory.getModel(TestEntity.class), new ArrayList<>(), null, false, true); dialog.build(); dialog.select(e1); }
@Test public void testCreateMultiSelect() { ModelBasedSearchDialog<Integer, TestEntity> dialog = new ModelBasedSearchDialog<>(testEntityService, entityModelFactory.getModel(TestEntity.class), new ArrayList<>(), null, true, true); dialog.build(); dialog.select(Lists.newArrayList(e1, e2)); }