### Question:
MoreTypes { public static Element asElement(TypeMirror typeMirror) { return typeMirror.accept(AsElementVisitor.INSTANCE, null); } private  MoreTypes(); static Equivalence<TypeMirror> equivalence(); static ImmutableSet<TypeElement> referencedTypes(TypeMirror type); static Element asElement(TypeMirror typeMirror); static TypeElement asTypeElement(TypeMirror mirror); static ImmutableSet<TypeElement> asTypeElements(Iterable<? extends TypeMirror> mirrors); static ArrayType asArray(TypeMirror maybeArrayType); static DeclaredType asDeclared(TypeMirror maybeDeclaredType); static ErrorType asError(TypeMirror maybeErrorType); static ExecutableType asExecutable(TypeMirror maybeExecutableType); static IntersectionType asIntersection(TypeMirror maybeIntersectionType); static NoType asNoType(TypeMirror maybeNoType); static NullType asNullType(TypeMirror maybeNullType); static PrimitiveType asPrimitiveType(TypeMirror maybePrimitiveType); static TypeVariable asTypeVariable(TypeMirror maybeTypeVariable); static WildcardType asWildcard(TypeMirror maybeWildcardType); static boolean isType(TypeMirror type); static boolean isTypeOf(final Class<?> clazz, TypeMirror type); static Optional<DeclaredType> nonObjectSuperclass(Types types, Elements elements,
      DeclaredType type); static TypeMirror asMemberOf(Types types, DeclaredType container,
      VariableElement variable); static boolean isConversionFromObjectUnchecked(TypeMirror type);  }### Answer:
@Test public void asElement_throws() { TypeMirror javaDotLang = compilationRule.getElements().getPackageElement("java.lang").asType(); try { MoreTypes.asElement(javaDotLang); fail(); } catch (IllegalArgumentException expected) {} }
@Test public void asElement() { Elements elements = compilationRule.getElements(); TypeElement stringElement = elements.getTypeElement("java.lang.String"); assertThat(MoreTypes.asElement(stringElement.asType())).isEqualTo(stringElement); TypeParameterElement setParameterElement = Iterables.getOnlyElement( compilationRule.getElements().getTypeElement("java.util.Set").getTypeParameters()); assertThat(MoreTypes.asElement(setParameterElement.asType())).isEqualTo(setParameterElement); }