Search in sources :

Example 1 with FullAgedCTEProvider

use of com.blazebit.persistence.view.testsuite.cte.model.PersonWithPartnerDocumentFullAged.FullAgedCTEProvider in project blaze-persistence by Blazebit.

the class WithCTEMappingTest method testCteBindingWithSubview.

@Test
public void testCteBindingWithSubview() {
    EntityViewManager evm = build(DocumentWithCTE.class, PersonWithPartnerDocument.class, PersonWithPartnerDocumentFullAged.class, PersonWithPartnerDocumentUnderAged.class);
    CriteriaBuilder<Person> cb = cbf.create(em, Person.class).orderByAsc("id");
    EntityViewSetting<PersonWithPartnerDocument, CriteriaBuilder<PersonWithPartnerDocument>> setting;
    setting = EntityViewSetting.create(PersonWithPartnerDocument.class);
    List<PersonWithPartnerDocument> list = evm.applySetting(setting, cb).getResultList();
    assertEquals(3, list.size());
    assertEquals("doc1", list.get(0).getPartnerDocument().getName());
    assertEquals(Long.valueOf(1), list.get(0).getPartnerDocument().getOwnedDocumentCount());
    boolean containsProvider = false;
    ManagedViewType<?> viewType = evm.getMetamodel().managedView(PersonWithPartnerDocumentFullAged.class);
    for (CTEProvider provider : viewType.getCteProviders()) {
        if (provider instanceof FullAgedCTEProvider) {
            containsProvider = true;
        }
    }
    assertTrue(containsProvider);
}
Also used : CriteriaBuilder(com.blazebit.persistence.CriteriaBuilder) FullAgedCTEProvider(com.blazebit.persistence.view.testsuite.cte.model.PersonWithPartnerDocumentFullAged.FullAgedCTEProvider) CTEProvider(com.blazebit.persistence.view.CTEProvider) FullAgedCTEProvider(com.blazebit.persistence.view.testsuite.cte.model.PersonWithPartnerDocumentFullAged.FullAgedCTEProvider) EntityViewManager(com.blazebit.persistence.view.EntityViewManager) PersonWithPartnerDocument(com.blazebit.persistence.view.testsuite.cte.model.PersonWithPartnerDocument) Person(com.blazebit.persistence.testsuite.entity.Person) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Aggregations

CriteriaBuilder (com.blazebit.persistence.CriteriaBuilder)1 Person (com.blazebit.persistence.testsuite.entity.Person)1 CTEProvider (com.blazebit.persistence.view.CTEProvider)1 EntityViewManager (com.blazebit.persistence.view.EntityViewManager)1 AbstractEntityViewTest (com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)1 PersonWithPartnerDocument (com.blazebit.persistence.view.testsuite.cte.model.PersonWithPartnerDocument)1 FullAgedCTEProvider (com.blazebit.persistence.view.testsuite.cte.model.PersonWithPartnerDocumentFullAged.FullAgedCTEProvider)1 Test (org.junit.Test)1