Example usage for java.lang.reflect Type Type

List of usage examples for java.lang.reflect Type Type

Introduction

In this page you can find the example usage for java.lang.reflect Type Type.

Prototype

Type

Source Link

Usage

From source file:org.localmatters.serializer.tool.ConfigWriterFromClassTest.java

/**
 * Tests handling a parameterized type when the raw type is not a class 
 *//*w w w.  j  av a2s.com*/
public void testHandleParametrizedTypeWhenRawNotClass() {
    ConfigWriterFromClass writer = new ConfigWriterFromClass(Object.class);
    AttributeSerialization attribute = new AttributeSerialization();
    Serialization ser = writer.handleType("invalid", new ParameterizedType() {
        public Type getRawType() {
            return new Type() {
            };
        }

        public Type getOwnerType() {
            return null;
        }

        public Type[] getActualTypeArguments() {
            return null;
        }
    }, attribute);
    assertTrue(ser instanceof NameSerialization);
    NameSerialization name = (NameSerialization) ser;
    assertEquals("value", name.getName());
    assertTrue(name.getDelegate() instanceof ComplexSerialization);
    ComplexSerialization complex = (ComplexSerialization) name.getDelegate();
    assertEquals(1, CollectionUtils.size(complex.getAttributes()));
    assertSame(attribute, complex.getAttributes().get(0));
    assertTrue(CollectionUtils.isEmpty(complex.getElements()));
    assertEquals(2, CollectionUtils.size(complex.getComments()));
    assertEquals("Unable to resolve the class for the element [invalid]!", complex.getComments().get(0));
    assertEquals("Its configuration must be written manually.", complex.getComments().get(1));
}