@Test public void returnsComponentTypeForMultiDimensionalArrayCorrectly() { TypeInformation<?> information = from(String[][].class); assertThat(information.getType(), is((Object) String[][].class)); assertThat(information.getComponentType().getType(), is((Object) String[].class)); assertThat(information.getActualType().getActualType().getType(), is((Object) String.class)); }
/** @see DATACMNS-39 */ @Test public void resolvesWildCardTypeCorrectly() { TypeInformation<ClassWithWildCardBound> information = ClassTypeInformation.from(ClassWithWildCardBound.class); TypeInformation<?> property = information.getProperty("wildcard"); assertThat(property.isCollectionLike(), is(true)); assertThat(property.getComponentType().getType(), is(typeCompatibleWith(String.class))); property = information.getProperty("complexWildcard"); assertThat(property.isCollectionLike(), is(true)); TypeInformation<?> component = property.getComponentType(); assertThat(component.isCollectionLike(), is(true)); assertThat(component.getComponentType().getType(), is(typeCompatibleWith(String.class))); }
@Test public void discoversTypeForSimpleGenericField() { TypeInformation<ConcreteType> discoverer = ClassTypeInformation.from(ConcreteType.class); assertEquals(ConcreteType.class, discoverer.getType()); TypeInformation<?> content = discoverer.getProperty("content"); assertEquals(String.class, content.getType()); assertNull(content.getComponentType()); assertNull(content.getMapValueType()); }
@Test public void discoversArraysAndCollections() { TypeInformation<StringCollectionContainer> information = ClassTypeInformation.from(StringCollectionContainer.class); TypeInformation<?> property = information.getProperty("array"); assertEquals(property.getComponentType().getType(), String.class); Class<?> type = property.getType(); assertEquals(String[].class, type); assertThat(type.isArray(), is(true)); property = information.getProperty("foo"); assertEquals(Collection[].class, property.getType()); assertEquals(Collection.class, property.getComponentType().getType()); assertEquals(String.class, property.getComponentType().getComponentType().getType()); property = information.getProperty("rawSet"); assertEquals(Set.class, property.getType()); assertEquals(Object.class, property.getComponentType().getType()); assertNull(property.getMapValueType()); }