org.mockito.internal.configuration.injection.MockInjection Maven / Gradle / Ivy
Show all versions of mockito-core Show documentation
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.configuration.injection;
import static org.mockito.internal.util.Checks.checkItemsNotNull;
import static org.mockito.internal.util.Checks.checkNotNull;
import static org.mockito.internal.util.collections.Sets.newMockSafeHashSet;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Internal injection configuration utility.
*
* Allow the user of this class to configure the way the injection of mocks will happen.
*/
public final class MockInjection {
/**
* Create a new configuration setup for a field
*
*
* @param field Field needing mock injection
* @param ofInstance Instance owning the field
* @return New configuration builder
*/
public static OngoingMockInjection onField(Field field, Object ofInstance) {
return new OngoingMockInjection(field, ofInstance);
}
/**
* Create a new configuration setup for fields
*
*
* @param fields Fields needing mock injection
* @param ofInstance Instance owning the field
* @return New configuration builder
*/
public static OngoingMockInjection onFields(Set fields, Object ofInstance) {
return new OngoingMockInjection(fields, ofInstance);
}
/**
* Ongoing configuration of the mock injector.
*/
public static class OngoingMockInjection {
private final Set fields = new HashSet<>();
private final Set