Search in sources :

Example 6 with CollectionModel

use of org.apache.wicket.model.util.CollectionModel in project wicket-orientdb by OrienteerBAP.

the class TestFilters method testCollectionFilterCriteria.

@Test
@SuppressWarnings("unchecked")
public void testCollectionFilterCriteria() {
    List<Integer> models = Lists.newArrayList();
    models.add(NUM_VALUE_1);
    models.add(NUM_VALUE_2);
    IModel<Collection<Integer>> collectionModel = new CollectionModel<>(models);
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
    manager.addFilterCriteria(manager.createCollectionFilterCriteria(collectionModel, Model.of(true)));
    String field = wicket.getProperty(NUMBER_FIELD).getObject().getName();
    queryModel.addFilterCriteriaManager(field, manager);
    queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING);
    assertTrue(queryModel.getObject().size() == 2);
    assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
    assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2));
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) CollectionModel(org.apache.wicket.model.util.CollectionModel) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Aggregations

CollectionModel (org.apache.wicket.model.util.CollectionModel)6 Test (org.junit.Test)5 FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)5 IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)5 IFilterCriteria (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria)3 GitBlitException (com.gitblit.GitBlitException)1 RegistrantAccessPermission (com.gitblit.models.RegistrantAccessPermission)1 TeamModel (com.gitblit.models.TeamModel)1 UserModel (com.gitblit.models.UserModel)1 PasswordHash (com.gitblit.utils.PasswordHash)1 NonTrimmedPasswordTextField (com.gitblit.wicket.NonTrimmedPasswordTextField)1 StringChoiceRenderer (com.gitblit.wicket.StringChoiceRenderer)1 RegistrantPermissionsPanel (com.gitblit.wicket.panels.RegistrantPermissionsPanel)1 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 SimpleAttributeModifier (org.apache.wicket.behavior.SimpleAttributeModifier)1