Search in sources :

Example 1 with DocumentViewAbstractClass

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());
}
Also used : MappingConstructor(com.blazebit.persistence.view.metamodel.MappingConstructor) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) DocumentViewAbstractClass(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 2 with DocumentViewAbstractClass

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)));
}
Also used : MappingConstructor(com.blazebit.persistence.view.metamodel.MappingConstructor) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) DocumentViewAbstractClass(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Example 3 with DocumentViewAbstractClass

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());
}
Also used : MethodAttribute(com.blazebit.persistence.view.metamodel.MethodAttribute) ViewMetamodel(com.blazebit.persistence.view.metamodel.ViewMetamodel) DocumentViewAbstractClass(com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass) Test(org.junit.Test) AbstractEntityViewTest(com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)

Aggregations

ViewMetamodel (com.blazebit.persistence.view.metamodel.ViewMetamodel)3 AbstractEntityViewTest (com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)3 DocumentViewAbstractClass (com.blazebit.persistence.view.testsuite.basic.model.DocumentViewAbstractClass)3 Test (org.junit.Test)3 MappingConstructor (com.blazebit.persistence.view.metamodel.MappingConstructor)2 MethodAttribute (com.blazebit.persistence.view.metamodel.MethodAttribute)1