Search in sources :

Example 1 with GenericMaster

use of org.mockito.internal.util.reflection.GenericMaster in project mockito by mockito.

the class CaptorAnnotationProcessor method process.

@Override
public Object process(Captor annotation, Field field) {
    Class<?> type = field.getType();
    if (!ArgumentCaptor.class.isAssignableFrom(type)) {
        throw new MockitoException("@Captor field must be of the type ArgumentCaptor.\n" + "Field: '" + field.getName() + "' has wrong type\n" + "For info how to use @Captor annotations see examples in javadoc for MockitoAnnotations class.");
    }
    Class<?> cls = new GenericMaster().getGenericType(field);
    return ArgumentCaptor.forClass(cls);
}
Also used : GenericMaster(org.mockito.internal.util.reflection.GenericMaster) ArgumentCaptor(org.mockito.ArgumentCaptor) MockitoException(org.mockito.exceptions.base.MockitoException)

Example 2 with GenericMaster

use of org.mockito.internal.util.reflection.GenericMaster in project powermock by powermock.

the class AnnotationEnabler method processAnnotationOn.

private Object processAnnotationOn(Captor annotation, Field field) {
    Class<?> type = field.getType();
    if (!ArgumentCaptor.class.isAssignableFrom(type)) {
        throw new MockitoException("@Captor field must be of the type ArgumentCaptor.\n" + "Field: '" + field.getName() + "' has wrong type\n" + "For info how to use @Captor annotations see examples in javadoc for MockitoAnnotations class.");
    }
    Class cls = new GenericMaster().getGenericType(field);
    return ArgumentCaptor.forClass(cls);
}
Also used : GenericMaster(org.mockito.internal.util.reflection.GenericMaster) ArgumentCaptor(org.mockito.ArgumentCaptor) MockitoException(org.mockito.exceptions.base.MockitoException)

Aggregations

ArgumentCaptor (org.mockito.ArgumentCaptor)2 MockitoException (org.mockito.exceptions.base.MockitoException)2 GenericMaster (org.mockito.internal.util.reflection.GenericMaster)2