Search in sources :

Example 6 with ViewMetamodel

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

the class ViewMetamodelTest method testNoMappingNonConflictingMapping.

@Test
public void testNoMappingNonConflictingMapping() {
    ViewMetamodel metamodel = build(NoMappingNonConflictingDoc.class).getMetamodel();
    MappingAttribute<?, ?> mappingAttribute = (MappingAttribute<?, ?>) metamodel.view(NoMappingNonConflictingDoc.class).getAttribute("name");
    assertEquals("COALESCE(name, '')", mappingAttribute.getMapping());
}
Also used : ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) MappingAttribute(com.blazebit.persistence.view.metamodel.MappingAttribute) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 7 with ViewMetamodel

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

the class ViewMetamodelTest method testImplicitAbstractClassMethodPreferredOverInterfaceMethod.

@Test
public void testImplicitAbstractClassMethodPreferredOverInterfaceMethod() {
    ViewMetamodel metamodel = build(ImplicitAbstractClassMethodPreferredOverInterfaceMethod.class).getMetamodel();
    MethodAttribute<?, ?> methodAttribute = metamodel.view(ImplicitAbstractClassMethodPreferredOverInterfaceMethod.class).getAttribute("name");
    assertEquals(ImplicitAbstractClassMethodPreferredOverInterfaceMethodAbstractClass.class, methodAttribute.getJavaMethod().getDeclaringClass());
}
Also used : ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 8 with ViewMetamodel

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

the class ViewMetamodelTest method testMappingParameterClassView.

@Test
public void testMappingParameterClassView() throws Exception {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    ViewType<?> viewType = viewMetamodel.view(DocumentViewAbstractClass.class);
    MethodAttribute<?, ?> attribute = viewType.getAttribute("contactPersonNumber2");
    assertNotNull(attribute);
    assertEquals("contactPersonNumber2", attribute.getName());
    assertFalse(attribute.isSubquery());
    assertEquals("contactPersonNumber", ((MappingAttribute<?, ?>) attribute).getMapping());
    assertFalse(attribute.isCollection());
    assertTrue(((SingularAttribute<?, ?>) attribute).isQueryParameter());
    assertEquals(Integer.class, attribute.getJavaType());
    assertEquals(DocumentViewInterface.class.getMethod("getContactPersonNumber2"), 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 9 with ViewMetamodel

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

the class ViewMetamodelTest method testMappingParameterInterfaceView.

@Test
public void testMappingParameterInterfaceView() throws Exception {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    ViewType<?> viewType = viewMetamodel.view(DocumentViewInterface.class);
    MethodAttribute<?, ?> attribute = viewType.getAttribute("contactPersonNumber2");
    assertNotNull(attribute);
    assertEquals("contactPersonNumber2", attribute.getName());
    assertFalse(attribute.isSubquery());
    assertEquals("contactPersonNumber", ((MappingAttribute<?, ?>) attribute).getMapping());
    assertFalse(attribute.isCollection());
    assertTrue(((SingularAttribute<?, ?>) attribute).isQueryParameter());
    assertEquals(Integer.class, attribute.getJavaType());
    assertEquals(DocumentViewInterface.class.getMethod("getContactPersonNumber2"), 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 10 with ViewMetamodel

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

the class ViewMetamodelTest method testMappingAttributesInterfaceView.

@Test
public void testMappingAttributesInterfaceView() {
    ViewMetamodel viewMetamodel = getViewMetamodel();
    Set<MethodAttribute<? super DocumentViewInterface, ?>> attributes = viewMetamodel.view(DocumentViewInterface.class).getAttributes();
    assertEquals(6, attributes.size());
}
Also used : DocumentViewInterface(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewInterface) MethodAttribute(com.blazebit.persistence.view.metamodel.MethodAttribute) 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