@Override public String toString() { return String.format("%s %s", getQualifier(), getInjectedType().getFullyQualifiedNameWithTypeParms()); }
@Override public String toString() { return String.format("%s %s", getQualifier(), getType().getFullyQualifiedNameWithTypeParms()); } }
return String.format("%s %s %s", injectableDescriptor, getQualifier(), getInjectedType().getFullyQualifiedNameWithTypeParms());
sb.append(i.getFullyQualifiedNameWithTypeParms()); sb.append(dc.getFullyQualifiedNameWithTypeParms());
sb.append(i.getFullyQualifiedNameWithTypeParms()); sb.append(dc.getFullyQualifiedNameWithTypeParms());
if (m != null) { e.appendFailureInfo("This value came from method " + m.getDeclaringClass().getFullyQualifiedNameWithTypeParms() + "." + m.getName() + ", which has return type " + m.getReturnType());
if (m != null) { e.appendFailureInfo("This value came from method " + m.getDeclaringClass().getFullyQualifiedNameWithTypeParms() + "." + m.getName() + ", which has return type " + m.getReturnType());
@Test public void testFieldWithStringTypeParam() throws Exception { final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); final MetaField field = metaClass.getDeclaredField("hasStringParam"); assertNotNull(field); assertEquals("Collection", field.getType().getName()); assertEquals("java.util.Collection", field.getType().getFullyQualifiedName()); assertEquals("<java.lang.String>", field.getType().getParameterizedType().toString()); assertEquals("java.util.Collection<java.lang.String>", field.getType().getFullyQualifiedNameWithTypeParms()); assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms()); assertEquals( Arrays.asList(getMetaClass(String.class)), Arrays.asList(field.getType().getParameterizedType().getTypeParameters())); }
@Test public void testMethodObjectReturnType() { final MetaClass c = getMetaClass(ClassWithGenericMethods.class); final MetaMethod method = c.getMethod("methodReturningObject", new Class[] {}); assertEquals("java.lang.Object", method.getReturnType().getFullyQualifiedNameWithTypeParms()); assertEquals(getTypeOfMetaClassBeingTested(), method.getReturnType().getClass()); // the generic return type should be the same: plain old Object assertEquals(getMetaClass(Object.class), method.getGenericReturnType()); }
@Test public void testFieldWithStringBoundedWildcardTypeParam() throws Exception { final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); final MetaField field = metaClass.getDeclaredField("hasWildcardExtendsStringParam"); assertNotNull(field); assertEquals("Collection", field.getType().getName()); assertEquals("java.util.Collection", field.getType().getFullyQualifiedName()); assertEquals("<? extends java.lang.String>", field.getType().getParameterizedType().toString()); assertEquals("java.util.Collection<? extends java.lang.String>", field.getType().getFullyQualifiedNameWithTypeParms()); assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms()); assertEquals(1, field.getType().getParameterizedType().getTypeParameters().length); final MetaWildcardType typeParam = (MetaWildcardType) field.getType().getParameterizedType().getTypeParameters()[0]; assertEquals("Should have no lower bound", Arrays.asList(), Arrays.asList(typeParam.getLowerBounds())); assertEquals("Upper bound should be java.lang.String", Arrays.asList(getMetaClass(String.class)), Arrays.asList(typeParam.getUpperBounds())); }
@Test public void testEraseParameterizedTopLevelType() throws Exception { final MetaClass parameterized = getMetaClass(ParameterizedClass.class); assertEquals("ParameterizedClass", parameterized.getName()); assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getFullyQualifiedName()); assertNull(parameterized.getParameterizedType()); // I think this would be correct, but right now we get the raw type name //assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass<T>", parameterized.getFullyQualifiedNameWithTypeParms()); assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getErased().getFullyQualifiedNameWithTypeParms()); }
@Test public void testMethodReturnTypeWithUpperBoundedWildcardParameter() { final MetaClass c = getMetaClass(ClassWithGenericMethods.class); final MetaMethod method = c.getMethod("methodReturningUpperBoundedWildcardCollection", new Class[] {}); // TODO (ERRAI-459) decide whether it's correct to have the type param present or not // then adjust this assertion to strict equality rather than startsWith() assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection")); final MetaType genericReturnType = method.getGenericReturnType(); assertNotNull(genericReturnType); assertTrue("Got unexpected return type type " + genericReturnType.getClass(), genericReturnType instanceof MetaParameterizedType); final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType; assertEquals(1, mpReturnType.getTypeParameters().length); // Sole type parameter should be <? extends String> assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType); final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0]; assertArrayEquals(new MetaType[] {}, typeParam.getLowerBounds()); assertArrayEquals(new MetaType[] { getMetaClass(String.class) }, typeParam.getUpperBounds()); }
@Test public void testFieldWithUnboundedTypeVarParam() throws Exception { final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); final MetaField field = metaClass.getDeclaredField("hasUnboundedTypeVarFromClass"); assertNotNull(field); assertEquals("Collection", field.getType().getName()); assertEquals("java.util.Collection", field.getType().getFullyQualifiedName()); assertEquals("java.util.Collection<T>", field.getType().getParameterizedType().getName()); assertEquals("java.util.Collection<T>", field.getType().getFullyQualifiedNameWithTypeParms()); assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms()); assertEquals(1, field.getType().getParameterizedType().getTypeParameters().length); final MetaTypeVariable typeVar = (MetaTypeVariable) field.getType().getParameterizedType().getTypeParameters()[0]; assertEquals("T", typeVar.getName()); assertEquals("Should have no upper bound", Arrays.asList(getMetaClass(Object.class)), Arrays.asList(typeVar.getBounds())); }
@Test public void testMethodReturnTypeWithWildcardParameter() { final MetaClass c = getMetaClass(ClassWithGenericMethods.class); final MetaMethod method = c.getMethod("methodReturningUnboundedWildcardCollection", new Class[] {}); // TODO (ERRAI-459) decide whether it's correct to have the type param present or not // then adjust this assertion to strict equality rather than startsWith() assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection")); final MetaType genericReturnType = method.getGenericReturnType(); assertNotNull(genericReturnType); assertTrue("Got unexpected return type type " + genericReturnType.getClass(), genericReturnType instanceof MetaParameterizedType); final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType; assertEquals(1, mpReturnType.getTypeParameters().length); // Sole type parameter should be <?> assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType); final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0]; assertArrayEquals(new MetaType[] {}, typeParam.getLowerBounds()); assertArrayEquals(new MetaType[] { getMetaClass(Object.class) }, typeParam.getUpperBounds()); }
@Test public void testMethodReturnTypeWithLowerBoundedWildcardParameter() { final MetaClass c = getMetaClass(ClassWithGenericMethods.class); final MetaMethod method = c.getMethod("methodReturningLowerBoundedWildcardCollection", new Class[] {}); // TODO (ERRAI-459) decide whether it's correct to have the type param present or not // then adjust this assertion to strict equality rather than startsWith() assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection")); final MetaType genericReturnType = method.getGenericReturnType(); assertNotNull(genericReturnType); assertTrue("Got unexpected return type type " + genericReturnType.getClass(), genericReturnType instanceof MetaParameterizedType); final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType; assertEquals(1, mpReturnType.getTypeParameters().length); // Sole type parameter should be <? extends String> assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType); final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0]; assertArrayEquals(new MetaType[] { getMetaClass(String.class) }, typeParam.getLowerBounds()); assertArrayEquals(new MetaType[] { getMetaClass(Object.class)}, typeParam.getUpperBounds()); }