### Question:
MirrorClassFactory implements XTypeFactory { @Override public XClass fromTypeMirror(TypeMirror typeMirror) { if (typeMirror == null) { return null; } switch (typeMirror.getKind()) { case ERROR: throw new IllegalStateException("Unresolved type : " + typeMirror.toString()); case VOID: return voidType; case BOOLEAN: return booleanType; case BYTE: return byteType; case SHORT: return shortType; case INT: return intType; case LONG: return longType; case CHAR: return charType; case FLOAT: return floatType; case DOUBLE: return doubleType; case DECLARED: { DeclaredType declaredType = (DeclaredType) typeMirror; String fqn = ((TypeElement) declaredType.asElement()).getQualifiedName().toString(); XClass xclass = classCache.get(fqn); if (xclass == null) { xclass = new MirrorClass(declaredType); classCache.put(fqn, xclass); } return xclass; } case ARRAY: { XClass componentType = fromTypeMirror(((ArrayType) typeMirror).getComponentType()); String fqn = "[" + componentType.getName(); XClass xclass = classCache.get(fqn); if (xclass == null) { xclass = new MirrorArray(componentType); classCache.put(fqn, xclass); } return xclass; } default: throw new IllegalStateException("Unexpected type kind : " + typeMirror.getKind()); } } MirrorClassFactory(ProcessingEnvironment processingEnv); @Override XClass fromClass(Class<?> c); @Override XClass fromTypeMirror(TypeMirror typeMirror);  }### Answer:
@Test public void testFromTypeMirror() { ProcessingEnvironment processingEnvironmentMock = mock(ProcessingEnvironment.class); Elements elementsMock = mock(Elements.class); Types typesMock = mock(Types.class); when(processingEnvironmentMock.getElementUtils()).thenReturn(elementsMock); when(processingEnvironmentMock.getTypeUtils()).thenReturn(typesMock); TypeElement typeElementMock = mock(TypeElement.class); DeclaredType typeMirrorMock = mock(DeclaredType.class); when(typeMirrorMock.asElement()).thenReturn(typeElementMock); when(typeElementMock.asType()).thenReturn(typeMirrorMock); when(typeMirrorMock.getKind()).thenReturn(TypeKind.DECLARED); when(typeElementMock.getKind()).thenReturn(ElementKind.CLASS); Name nameMock = mock(Name.class); when(nameMock.toString()).thenReturn("java.lang.Integer"); when(typeElementMock.getQualifiedName()).thenReturn(nameMock); when(elementsMock.getTypeElement("java.lang.Integer")).thenReturn(typeElementMock); when(elementsMock.getBinaryName(typeElementMock)).thenReturn(nameMock); MirrorClassFactory typeFactory = new MirrorClassFactory(processingEnvironmentMock); XClass integerClass = typeFactory.fromTypeMirror(typeMirrorMock); assertFalse(integerClass.isArray()); }