### Question:
Types { public static Type valueOf(String typeName) { return valueOf(typeName, Collections.<String>emptySet()); } private  Types(); static TypeVariable<D> typeVariable(D declaration, String name,
		Type... bounds); static GenericArrayType genericArrayType(Type componentType); static ParameterizedType parameterizedType(Class<?> rawType, Type... actualTypeArguments); static WildcardType unboundedWildcardType(); static WildcardType upperBoundedWildcardType(Type upperBound); static WildcardType lowerBoundedWildcardType(Type lowerBound); static Type valueOf(String typeName); static Type valueOf(String typeName, Set<String> imports);  }### Answer:
@Test public void valueOfWithClass() { assertEquals(Integer.class, Types.valueOf("java.lang.Integer")); }
@Test public void valueOfWithClassAndWhitespace() { assertEquals(Integer.class, Types.valueOf(" java.lang.Integer ")); }
@Test public void valueOfWithClassAndCustomClassLoader() throws ClassNotFoundException { ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); final ClassLoader newClassLoader = context.mock(ClassLoader.class); context.checking(new Expectations() {{ one(newClassLoader).loadClass("java.lang.Integer"); will(returnValue(Integer.class)); }}); try { Thread.currentThread().setContextClassLoader(newClassLoader); assertEquals(Integer.class, Types.valueOf("java.lang.Integer")); } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } }
@Test public void valueOfWithArrayAndWhitespace() { assertEquals(Integer[].class, Types.valueOf(" java.lang.Integer [ ] ")); }
@Test public void valueOfWithArray() { assertEquals(Integer[].class, Types.valueOf("java.lang.Integer[]")); }
@Ignore @Test public void valueOfWithMemberClassAndImportContext() { Set<String> importContext = Collections.singleton(Map.class.getName()); assertEquals(Map.Entry.class, Types.valueOf("Map.Entry", importContext)); }
@Test public void valueOfWithMemberClassAndMemberImportContext() { Set<String> importContext = Collections.singleton(Map.Entry.class.getName()); assertEquals(Map.Entry.class, Types.valueOf("Entry", importContext)); }
@Test(expected = MalformedParameterizedTypeException.class) public void valueOfWithMismatchedArgumentParameterizedType() { Types.valueOf("java.util.Map<java.lang.String>"); }
@Test public void valueOfWithClassAndImportContext() { Set<String> importContext = Collections.singleton(Integer.class.getName()); assertEquals(Integer.class, Types.valueOf("Integer", importContext)); }
@Test(expected = IllegalArgumentException.class) public void valueOfWithClassAndMissingImportContext() { try { Types.valueOf("Integer"); } catch (IllegalArgumentException exception) { assertEquals("Class not found: Integer", exception.getMessage()); throw exception; } }
@Test(expected = IllegalArgumentException.class) public void valueOfWithClassAndInvalidImportContext() { Set<String> importContext = new LinkedHashSet<String>(); importContext.add(Integer.class.getName()); importContext.add("another.Integer"); try { Types.valueOf("Integer", importContext); } catch (IllegalArgumentException exception) { assertEquals("Duplicate imports: java.lang.Integer and another.Integer", exception.getMessage()); throw exception; } }