Search in sources :

Example 1 with ListModelType

use of com.vaadin.flow.template.angular.model.ListModelType in project flow by vaadin.

the class ModelDescriptorTest method listInsideList.

@Test
public void listInsideList() {
    ModelDescriptor<?> descriptor = ModelDescriptor.get(ListInsideListBeanModel.class);
    Assert.assertEquals(1, descriptor.getPropertyNames().count());
    ListModelType<?> listPropertyType = (ListModelType<?>) descriptor.getPropertyType("beans");
    Type javaType = listPropertyType.getJavaType();
    Assert.assertTrue("Expected instanceof ParameterizedType for List", javaType instanceof ParameterizedType);
    javaType = ((ParameterizedType) javaType).getActualTypeArguments()[0];
    Assert.assertTrue("Expected instanceof ParameterizedType for List in List", javaType instanceof ParameterizedType);
    Assert.assertEquals(Bean.class, ((ParameterizedType) javaType).getActualTypeArguments()[0]);
    Assert.assertTrue(listPropertyType.getItemType() instanceof ListModelType<?>);
    ListModelType<?> type = (ListModelType<?>) listPropertyType.getItemType();
    Assert.assertTrue(type.getItemType() instanceof BeanModelType<?>);
    BeanModelType<?> modelType = (BeanModelType<?>) type.getItemType();
    Assert.assertSame(Bean.class, modelType.getProxyType());
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) BasicModelType(com.vaadin.flow.templatemodel.BasicModelType) ListModelType(com.vaadin.flow.template.angular.model.ListModelType) ModelType(com.vaadin.flow.templatemodel.ModelType) BeanModelType(com.vaadin.flow.template.angular.model.BeanModelType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ListModelType(com.vaadin.flow.template.angular.model.ListModelType) BeanModelType(com.vaadin.flow.template.angular.model.BeanModelType) Test(org.junit.Test)

Example 2 with ListModelType

use of com.vaadin.flow.template.angular.model.ListModelType in project flow by vaadin.

the class ModelDescriptorTest method listInsideListInsideList.

@Test
public void listInsideListInsideList() {
    ModelDescriptor<?> descriptor = ModelDescriptor.get(ListInsideListInsideList.class);
    Assert.assertEquals(1, descriptor.getPropertyNames().count());
    ListModelType<?> listPropertyType = (ListModelType<?>) descriptor.getPropertyType("beans");
    Type javaType = listPropertyType.getJavaType();
    Assert.assertTrue("Expected instanceof ParameterizedType for List", javaType instanceof ParameterizedType);
    javaType = ((ParameterizedType) javaType).getActualTypeArguments()[0];
    Assert.assertTrue("Expected instanceof ParameterizedType for List in List", javaType instanceof ParameterizedType);
    javaType = ((ParameterizedType) javaType).getActualTypeArguments()[0];
    Assert.assertTrue("Expected instanceof ParameterizedType for List in List in List", javaType instanceof ParameterizedType);
    Assert.assertEquals(Bean.class, ((ParameterizedType) javaType).getActualTypeArguments()[0]);
    Assert.assertTrue(listPropertyType.getItemType() instanceof ListModelType<?>);
    ListModelType<?> type = (ListModelType<?>) listPropertyType.getItemType();
    Assert.assertTrue(type.getItemType() instanceof ListModelType<?>);
    type = (ListModelType<?>) type.getItemType();
    Assert.assertTrue(type.getItemType() instanceof BeanModelType<?>);
    BeanModelType<?> modelType = (BeanModelType<?>) type.getItemType();
    Assert.assertSame(Bean.class, modelType.getProxyType());
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) BasicModelType(com.vaadin.flow.templatemodel.BasicModelType) ListModelType(com.vaadin.flow.template.angular.model.ListModelType) ModelType(com.vaadin.flow.templatemodel.ModelType) BeanModelType(com.vaadin.flow.template.angular.model.BeanModelType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ListModelType(com.vaadin.flow.template.angular.model.ListModelType) BeanModelType(com.vaadin.flow.template.angular.model.BeanModelType) Test(org.junit.Test)

Aggregations

BeanModelType (com.vaadin.flow.template.angular.model.BeanModelType)2 ListModelType (com.vaadin.flow.template.angular.model.ListModelType)2 BasicModelType (com.vaadin.flow.templatemodel.BasicModelType)2 ModelType (com.vaadin.flow.templatemodel.ModelType)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 Test (org.junit.Test)2