Search in sources :

Example 26 with ViewMetamodel

use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.

the class ViewMetamodelTest method testMappingAttributeExplicitAttributeInterfaceView.

@Test
public void testMappingAttributeExplicitAttributeInterfaceView() throws Exception {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    ViewType<?> viewType = viewMetamodel.view(DocumentViewInterface.class);
    MethodAttribute<?, ?> attribute = viewType.getAttribute("firstContactPerson");
    assertNotNull(attribute);
    assertEquals("firstContactPerson", attribute.getName());
    assertFalse(attribute.isSubquery());
    assertEquals("contacts[1]", ((MappingAttribute<?, ?>) attribute).getMapping());
    assertFalse(attribute.isCollection());
    assertFalse(((SingularAttribute<?, ?>) attribute).isQueryParameter());
    assertEquals(Person.class, attribute.getJavaType());
    assertEquals(DocumentViewInterface.class.getMethod("getFirstContactPerson"), attribute.getJavaMethod());
    assertEquals(viewType, attribute.getDeclaringType());
}
Also used : DocumentViewInterface(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewInterface) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 27 with ViewMetamodel

use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.

the class ViewMetamodelTest method testViewReturnsViewTypes.

@Test
public void testViewReturnsViewTypes() {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    assertNotNull(viewMetamodel.view(DocumentViewInterface.class));
    assertNotNull(viewMetamodel.view(DocumentViewAbstractClass.class));
    assertNotNull(viewMetamodel.view(PersonView.class));
    assertNull(viewMetamodel.view(IdHolderView.class));
}
Also used : DocumentViewInterface(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewInterface) IdHolderView(com.blazebit.persistence.view.testsuite.basic.model.IdHolderView) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) PersonView(com.blazebit.persistence.view.testsuite.basic.model.PersonView) DocumentViewAbstractClass(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 28 with ViewMetamodel

use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.

the class ViewMetamodelTest method testMappingSubqueryClassView.

@Test
public void testMappingSubqueryClassView() throws Exception {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    ViewType<?> viewType = viewMetamodel.view(DocumentViewAbstractClass.class);
    MethodAttribute<?, ?> attribute = viewType.getAttribute("contactCount");
    assertNotNull(attribute);
    assertEquals("contactCount", attribute.getName());
    assertTrue(attribute.isSubquery());
    assertEquals(CountSubqueryProvider.class, ((SubqueryAttribute<?, ?>) attribute).getSubqueryProvider());
    assertFalse(attribute.isCollection());
    assertFalse(((SingularAttribute<?, ?>) attribute).isQueryParameter());
    assertEquals(Long.class, attribute.getJavaType());
    assertEquals(DocumentViewInterface.class.getMethod("getContactCount"), attribute.getJavaMethod());
    assertEquals(viewType, attribute.getDeclaringType());
}
Also used : DocumentViewInterface(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewInterface) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 29 with ViewMetamodel

use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.

the class ViewMetamodelTest method testGetConstructorsClassView.

@Test
public void testGetConstructorsClassView() {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    ViewType<DocumentViewAbstractClass> viewType = viewMetamodel.view(DocumentViewAbstractClass.class);
    Set<MappingConstructor<DocumentViewAbstractClass>> constructors = viewType.getConstructors();
    assertEquals(1, constructors.size());
    assertNotNull(viewType.getConstructor(Long.class, Integer.class, String.class));
    assertTrue(constructors.contains(viewType.getConstructor(Long.class, Integer.class, String.class)));
}
Also used : MappingConstructor(com.blazebit.persistence.view.metamodel.MappingConstructor) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) DocumentViewAbstractClass(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 30 with ViewMetamodel

use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.

the class ViewMetamodelTest method testGetConstructorsInterfaceView.

@Test
public void testGetConstructorsInterfaceView() {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    ViewType<DocumentViewInterface> viewType = viewMetamodel.view(DocumentViewInterface.class);
    Set<MappingConstructor<DocumentViewInterface>> constructors = viewType.getConstructors();
    assertEquals(0, constructors.size());
}
Also used : DocumentViewInterface(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewInterface) MappingConstructor(com.blazebit.persistence.view.metamodel.MappingConstructor) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Aggregations

ViewMetamodel (com.blazebit.persistence.view.metamodel.ViewMetamodel)44 AbstractEntityViewTest (com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)44 Test (org.junit.Test)44 DocumentViewInterface (com.blazebit.persistence.view.testsuite.basic.model.DocumentViewInterface)15 EntityViewConfiguration (com.blazebit.persistence.view.spi.EntityViewConfiguration)5 DocumentViewAbstractClass (com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass)5 MappingAttribute (com.blazebit.persistence.view.metamodel.MappingAttribute)3 MappingConstructor (com.blazebit.persistence.view.metamodel.MappingConstructor)3 IdHolderView (com.blazebit.persistence.view.testsuite.basic.model.IdHolderView)3 PersonView (com.blazebit.persistence.view.testsuite.basic.model.PersonView)3 MethodAttribute (com.blazebit.persistence.view.metamodel.MethodAttribute)2 Document (com.blazebit.persistence.testsuite.entity.Document)1 Person (com.blazebit.persistence.testsuite.entity.Person)1 FlatViewType (com.blazebit.persistence.view.metamodel.FlatViewType)1 SingularAttribute (com.blazebit.persistence.view.metamodel.SingularAttribute)1 CircularDocument (com.blazebit.persistence.view.testsuite.basic.model.CircularDocument)1 CircularPerson (com.blazebit.persistence.view.testsuite.basic.model.CircularPerson)1 PersonViewWithSingularMapping (com.blazebit.persistence.view.testsuite.basic.model.PersonViewWithSingularMapping)1