@Test public void resolvesNestedInheritedTypeParameters() { TypeInformation<SecondExtension> information = ClassTypeInformation.from(SecondExtension.class); TypeInformation<?> superTypeInformation = information.getSuperTypeInformation(Base.class); List<TypeInformation<?>> parameters = superTypeInformation.getTypeArguments(); assertThat(parameters, hasSize(1)); assertThat(parameters.get(0).getType(), is((Object) String.class)); }
@Test public void resolvesTypeParametersCorrectly() { TypeInformation<ConcreteType> information = ClassTypeInformation.from(ConcreteType.class); TypeInformation<?> superTypeInformation = information.getSuperTypeInformation(GenericType.class); List<TypeInformation<?>> parameters = superTypeInformation.getTypeArguments(); assertThat(parameters, hasSize(2)); assertThat(parameters.get(0).getType(), is((Object) String.class)); assertThat(parameters.get(1).getType(), is((Object) Object.class)); }
@Test public void discoversImplementationBindingCorrectlyForString() throws Exception { TypeInformation<TypedClient> information = from(TypedClient.class); Method method = TypedClient.class.getMethod("stringMethod", GenericInterface.class); TypeInformation<?> parameterType = information.getParameterTypes(method).get(0); TypeInformation<StringImplementation> stringInfo = from(StringImplementation.class); assertThat(parameterType.isAssignableFrom(stringInfo), is(true)); assertThat( stringInfo.getSuperTypeInformation(GenericInterface.class), is((Object) parameterType)); assertThat(parameterType.isAssignableFrom(from(LongImplementation.class)), is(false)); assertThat( parameterType.isAssignableFrom( from(StringImplementation.class).getSuperTypeInformation(GenericInterface.class)), is(true)); }