org.mockito.configuration.GwtMockScanner Maven / Gradle / Ivy
package org.mockito.configuration;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.internal.configuration.injection.scanner.MockScanner;
import org.mockito.internal.util.MockUtil;
import org.mockito.internal.util.reflection.FieldReader;
import java.lang.reflect.Field;
import java.util.Set;
import static org.mockito.internal.util.collections.Sets.newMockSafeHashSet;
/**
* Copied and adapted from {@link MockScanner}, to add gwt-test-utils
* {@link com.googlecode.gwt.test.Mock} annotation.
*/
class GwtMockScanner {
private final Class clazz;
private final Object instance;
private final MockUtil mockUtil = new MockUtil();
/**
* Creates a MockScanner.
*
* @param instance The test instance
* @param clazz The class in the type hierarchy of this instance.
*/
public GwtMockScanner(Object instance, Class clazz) {
this.instance = instance;
this.clazz = clazz;
}
/**
* Add the scanned and prepared mock instance to the given collection.
*
*
* The preparation of mocks consists only in defining a MockName if not already set.
*
*
* @param mocks Set of mocks
*/
public void addPreparedMocks(Set