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