use of com.blazebit.persistence.view.testsuite.basic.model.FilteredDocument in project blaze-persistence by Blazebit.
the class EntityViewSettingTest method testEntityViewSetting.
@Test
public void testEntityViewSetting() {
EntityViewManager evm = build(FilteredDocument.class);
// Base setting
EntityViewSetting<FilteredDocument, PaginatedCriteriaBuilder<FilteredDocument>> setting = EntityViewSetting.create(FilteredDocument.class, 0, 1);
// Query
CriteriaBuilder<Document> cb = cbf.create(em, Document.class);
setting.addAttributeFilter("name", "Test");
setting.addAttributeFilter("contactCount", "1");
setting.addAttributeSorter("name", Sorters.descending());
setting.addAttributeSorter("id", Sorters.descending());
setting.addOptionalParameter("index", 1);
PaginatedCriteriaBuilder<FilteredDocument> paginatedCb = evm.applySetting(setting, cb);
PagedList<FilteredDocument> result = paginatedCb.getResultList();
assertEquals(1, result.size());
assertEquals(2, result.getTotalSize());
assertEquals("YourTest", result.get(0).getName());
assertEquals("pers2", result.get(0).getContactName());
}
Aggregations