org.mockito.internal.configuration.injection.scanner.MockScanner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-all Show documentation
Show all versions of mockito-all Show documentation
Mock objects library for java
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.configuration.injection.scanner;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
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;
/**
* Scan mocks, and prepare them if needed.
*/
public class MockScanner {
private MockUtil mockUtil = new MockUtil();
private final Object instance;
private final Class> clazz;
/**
* Creates a MockScanner.
*
* @param instance The test instance
* @param clazz The class in the type hierarchy of this instance.
*/
public MockScanner(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
© 2015 - 2024 Weber Informatics LLC | Privacy Policy