Search in sources :

Example 1 with FilteredDocument

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());
}
Also used : EntityViewManager(com.blazebit.persistence.view.EntityViewManager) FilteredDocument(com.blazebit.persistence.view.testsuite.basic.model.FilteredDocument) Document(com.blazebit.persistence.testsuite.entity.Document) FilteredDocument(com.blazebit.persistence.view.testsuite.basic.model.FilteredDocument) PaginatedCriteriaBuilder(com.blazebit.persistence.PaginatedCriteriaBuilder) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Aggregations

PaginatedCriteriaBuilder (com.blazebit.persistence.PaginatedCriteriaBuilder)1 Document (com.blazebit.persistence.testsuite.entity.Document)1 EntityViewManager (com.blazebit.persistence.view.EntityViewManager)1 AbstractEntityViewTest (com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)1 FilteredDocument (com.blazebit.persistence.view.testsuite.basic.model.FilteredDocument)1 Test (org.junit.Test)1