org.mockito.internal.configuration.injection.MockInjection 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;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
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;
/**
* Internal injection configuration utility.
*
*
* Allow the user of this class to configure the way the injection of mocks will happen.
*
*
*/
public 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
© 2015 - 2024 Weber Informatics LLC | Privacy Policy