### Question:
TypeUtil { public static JClass resolveType(JClassContainer _package, String typeDefinition) { try { FieldDeclaration fieldDeclaration = (FieldDeclaration) JavaParser.parseBodyDeclaration(typeDefinition + " foo;"); ClassOrInterfaceType c = (ClassOrInterfaceType) ((ReferenceType) fieldDeclaration.getType()).getType(); return buildClass(_package, c, 0); } catch (ParseException e) { throw new GenerationException("Couldn't parse type: " + typeDefinition, e); } }  static JClass resolveType(JClassContainer _package, String typeDefinition);  }### Answer:
@Test public void testResolveTypeCanHandleWildcard() { final JCodeModel codeModel = new JCodeModel(); final JClass _class = TypeUtil.resolveType(codeModel.rootPackage(), "java.util.List<?>"); assertThat(_class.erasure(), equalTo(codeModel.ref(List.class))); assertThat(_class.typeParams(), emptyArray()); assertThat(_class.isParameterized(), is(Boolean.TRUE)); assertThat(_class.getTypeParameters(), hasSize(1)); assertThat(_class.getTypeParameters().get(0)._extends(), is(equalTo(codeModel.ref(Object.class)))); }
@Test public void testResolveTypeCanHandleExtendsWildcard() { final JCodeModel codeModel = new JCodeModel(); final JClass _class = TypeUtil.resolveType(codeModel.rootPackage(), "java.util.List<? extends java.lang.Number>"); assertThat(_class.erasure(), equalTo(codeModel.ref(List.class))); assertThat(_class.typeParams(), emptyArray()); assertThat(_class.isParameterized(), is(Boolean.TRUE)); assertThat(_class.getTypeParameters(), hasSize(1)); assertThat(_class.getTypeParameters().get(0)._extends(), is(equalTo(codeModel.ref(Number.class)))); }
@Test(expected = IllegalArgumentException.class) public void testResolveTypeForSuperWildcardThrowsException() { TypeUtil.resolveType(new JCodeModel().rootPackage(), "java.util.List<? super java.lang.String>"); }