Search in sources :

Example 1 with ViewFilterPrimitiveDocumentView

use of com.blazebit.persistence.view.testsuite.filter.basic.model.ViewFilterPrimitiveDocumentView in project blaze-persistence by Blazebit.

the class AttributeFilterTest method testViewFilter.

@Test
public void testViewFilter() {
    EntityViewManager evm = build(ViewFilterPrimitiveDocumentView.class);
    EntityViewSetting<ViewFilterPrimitiveDocumentView, CriteriaBuilder<ViewFilterPrimitiveDocumentView>> setting = EntityViewSetting.create(ViewFilterPrimitiveDocumentView.class);
    setting.addViewFilter("viewFilter1");
    List<ViewFilterPrimitiveDocumentView> results = evm.applySetting(setting, cbf.create(em, PrimitiveDocument.class)).getResultList();
    assertEquals(1, results.size());
    Assert.assertEquals(Long.valueOf(doc1.getId()), results.get(0).getId());
}
Also used : CriteriaBuilder(com.blazebit.persistence.CriteriaBuilder) EntityViewManager(com.blazebit.persistence.view.EntityViewManager) ViewFilterPrimitiveDocumentView(com.blazebit.persistence.view.testsuite.filter.basic.model.ViewFilterPrimitiveDocumentView) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 2 with ViewFilterPrimitiveDocumentView

use of com.blazebit.persistence.view.testsuite.filter.basic.model.ViewFilterPrimitiveDocumentView in project blaze-persistence by Blazebit.

the class AttributeFilterTest method testMultipleViewFilter.

@Test
public void testMultipleViewFilter() {
    EntityViewManager evm = build(ViewFilterPrimitiveDocumentView.class);
    EntityViewSetting<ViewFilterPrimitiveDocumentView, CriteriaBuilder<ViewFilterPrimitiveDocumentView>> setting = EntityViewSetting.create(ViewFilterPrimitiveDocumentView.class);
    setting.addViewFilter("viewFilter1");
    setting.addViewFilter("viewFilter2");
    setting.withOptionalParameter("viewFilterParam", "Jack");
    List<ViewFilterPrimitiveDocumentView> results = evm.applySetting(setting, cbf.create(em, PrimitiveDocument.class)).getResultList();
    assertEquals(0, results.size());
}
Also used : CriteriaBuilder(com.blazebit.persistence.CriteriaBuilder) EntityViewManager(com.blazebit.persistence.view.EntityViewManager) ViewFilterPrimitiveDocumentView(com.blazebit.persistence.view.testsuite.filter.basic.model.ViewFilterPrimitiveDocumentView) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Aggregations

CriteriaBuilder (com.blazebit.persistence.CriteriaBuilder)2 EntityViewManager (com.blazebit.persistence.view.EntityViewManager)2 AbstractEntityViewTest (com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)2 ViewFilterPrimitiveDocumentView (com.blazebit.persistence.view.testsuite.filter.basic.model.ViewFilterPrimitiveDocumentView)2 Test (org.junit.Test)2