use of com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass in project blaze-persistence by Blazebit.
the class ViewMetamodelTest method testMappingConstructor.
@Test
public void testMappingConstructor() throws Exception {
ViewMetamodel viewMetamodel = getViewMetamodel();
ViewType<DocumentViewAbstractClass> viewType = viewMetamodel.view(DocumentViewAbstractClass.class);
Set<MappingConstructor<DocumentViewAbstractClass>> constructors = viewType.getConstructors();
MappingConstructor<DocumentViewAbstractClass> constructor = constructors.iterator().next();
assertNotNull(constructor);
assertEquals(3, constructor.getParameterAttributes().size());
assertEquals(Long.class, constructor.getParameterAttributes().get(0).getJavaType());
assertEquals(constructor, constructor.getParameterAttributes().get(0).getDeclaringConstructor());
assertEquals(viewType, constructor.getParameterAttributes().get(0).getDeclaringType());
assertEquals(0, constructor.getParameterAttributes().get(0).getIndex());
assertFalse(constructor.getParameterAttributes().get(0).isSubquery());
assertEquals("age + 1", ((MappingAttribute<?, ?>) constructor.getParameterAttributes().get(0)).getMapping());
assertFalse(constructor.getParameterAttributes().get(0).isCollection());
assertFalse(((SingularAttribute<?, ?>) constructor.getParameterAttributes().get(0)).isQueryParameter());
assertEquals(Integer.class, constructor.getParameterAttributes().get(1).getJavaType());
assertEquals(constructor, constructor.getParameterAttributes().get(1).getDeclaringConstructor());
assertEquals(viewType, constructor.getParameterAttributes().get(1).getDeclaringType());
assertEquals(1, constructor.getParameterAttributes().get(1).getIndex());
assertFalse(constructor.getParameterAttributes().get(1).isSubquery());
assertEquals("contactPersonNumber", ((MappingAttribute<?, ?>) constructor.getParameterAttributes().get(1)).getMapping());
assertFalse(constructor.getParameterAttributes().get(1).isCollection());
assertTrue(((SingularAttribute<?, ?>) constructor.getParameterAttributes().get(1)).isQueryParameter());
assertEquals(String.class, constructor.getParameterAttributes().get(2).getJavaType());
assertEquals(constructor, constructor.getParameterAttributes().get(2).getDeclaringConstructor());
assertEquals(viewType, constructor.getParameterAttributes().get(2).getDeclaringType());
assertEquals(2, constructor.getParameterAttributes().get(2).getIndex());
assertFalse(constructor.getParameterAttributes().get(2).isSubquery());
assertEquals("optionalParameter", ((MappingAttribute<?, ?>) constructor.getParameterAttributes().get(2)).getMapping());
assertFalse(constructor.getParameterAttributes().get(2).isCollection());
assertTrue(((SingularAttribute<?, ?>) constructor.getParameterAttributes().get(2)).isQueryParameter());
assertEquals(DocumentViewAbstractClass.class.getConstructor(Long.class, Integer.class, String.class), constructor.getJavaConstructor());
assertEquals(viewType, constructor.getDeclaringType());
}
use of com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass 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.testsuite.basic.model.DocumentViewAbstractClass in project blaze-persistence by Blazebit.
the class ViewMetamodelTest method testMappingAttributesClassView.
@Test
public void testMappingAttributesClassView() {
ViewMetamodel viewMetamodel = getViewMetamodel();
Set<MethodAttribute<? super DocumentViewAbstractClass, ?>> attributes = viewMetamodel.view(DocumentViewAbstractClass.class).getAttributes();
assertEquals(7, attributes.size());
}
Aggregations