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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations