Search in sources :

Example 11 with ViewMetamodel

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

the class ViewMetamodelTest method testMultipleSetterLikeMethods.

@Test
public void testMultipleSetterLikeMethods() {
    ViewMetamodel metamodel = build(MultipleSetterLikeMethodsDocument.class).getMetamodel();
    MethodAttribute<? super MultipleSetterLikeMethodsDocument, ?> idAttribute = metamodel.view(MultipleSetterLikeMethodsDocument.class).getAttribute("id");
    assertFalse(idAttribute.isMutable());
    assertFalse(idAttribute.isUpdatable());
}
Also used : ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 12 with ViewMetamodel

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

the class ViewMetamodelTest method testMappingAttributeInterfaceInheritedInterfaceView.

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

Example 13 with ViewMetamodel

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

the class ViewMetamodelTest method testMappingAttributeImplicitAttributeClassView.

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

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

the class ViewMetamodelTest method testResolveConflictingMapping.

@Test
public void testResolveConflictingMapping() {
    EntityViewConfiguration cfg = EntityViews.createDefaultConfiguration();
    cfg.addEntityView(ResolveConflictingDoc.class);
    ViewMetamodel metamodel = build(ResolveConflictingDoc.class).getMetamodel();
    MappingAttribute<?, ?> mappingAttribute = (MappingAttribute<?, ?>) metamodel.view(ResolveConflictingDoc.class).getAttribute("name");
    assertEquals("UPPER(name)", mappingAttribute.getMapping());
}
Also used : EntityViewConfiguration(com.blazebit.persistence.view.spi.EntityViewConfiguration) 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 15 with ViewMetamodel

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

the class EntityViewMetamodelFlatViewTest method nonUpdatableCreateMutableFlatView.

@Test
public void nonUpdatableCreateMutableFlatView() {
    ViewMetamodel metamodel = build(entityViewConfiguration, DocumentViewWithNonUpdatableCreateMutableFlatView.class, NameObjectView.class, NameObjectCreateAndUpdateView.class).getMetamodel();
    ManagedViewType<?> nameObjectViewType = metamodel.managedView(NameObjectCreateAndUpdateView.class);
    ManagedViewType<?> docViewType = metamodel.managedView(DocumentViewWithNonUpdatableCreateMutableFlatView.class);
    assertTrue(docViewType.getAttribute("nameObject").isUpdatable());
    assertTrue(docViewType.getAttribute("nameObject").isPersistCascaded());
    assertTrue(docViewType.getAttribute("nameObject").isUpdateCascaded());
    assertTrue(docViewType.getAttribute("nameObject").getPersistCascadeAllowedSubtypes().contains(nameObjectViewType));
    assertTrue(docViewType.getAttribute("nameObject").getUpdateCascadeAllowedSubtypes().contains(nameObjectViewType));
    assertTrue(docViewType.getAttribute("nameObject").isMutable());
}
Also used : 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