org.mockito.internal.creation.MockSettingsImpl 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.creation;
import org.mockito.MockSettings;
import org.mockito.exceptions.Reporter;
import org.mockito.internal.creation.settings.CreationSettings;
import org.mockito.internal.debugging.VerboseMockInvocationLogger;
import org.mockito.internal.util.MockCreationValidator;
import org.mockito.internal.util.MockNameImpl;
import org.mockito.listeners.InvocationListener;
import org.mockito.mock.MockCreationSettings;
import org.mockito.mock.MockName;
import org.mockito.mock.SerializableMode;
import org.mockito.stubbing.Answer;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.mockito.internal.util.collections.Sets.newSet;
@SuppressWarnings("unchecked")
public class MockSettingsImpl extends CreationSettings implements MockSettings, MockCreationSettings {
private static final long serialVersionUID = 4475297236197939569L;
public MockSettings serializable() {
return serializable(SerializableMode.BASIC);
}
public MockSettings serializable(SerializableMode mode) {
this.serializableMode = mode;
return this;
}
public MockSettings extraInterfaces(Class... extraInterfaces) {
if (extraInterfaces == null || extraInterfaces.length == 0) {
new Reporter().extraInterfacesRequiresAtLeastOneInterface();
}
for (Class i : extraInterfaces) {
if (i == null) {
new Reporter().extraInterfacesDoesNotAcceptNullParameters();
} else if (!i.isInterface()) {
new Reporter().extraInterfacesAcceptsOnlyInterfaces(i);
}
}
this.extraInterfaces = newSet(extraInterfaces);
return this;
}
public MockName getMockName() {
return mockName;
}
public Set getExtraInterfaces() {
return extraInterfaces;
}
public Object getSpiedInstance() {
return spiedInstance;
}
public MockSettings name(String name) {
this.name = name;
return this;
}
public MockSettings spiedInstance(Object spiedInstance) {
this.spiedInstance = spiedInstance;
return this;
}
public MockSettings defaultAnswer(Answer defaultAnswer) {
this.defaultAnswer = defaultAnswer;
if (defaultAnswer == null) {
new Reporter().defaultAnswerDoesNotAcceptNullParameter();
}
return this;
}
public Answer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy