com.fitbur.mockito.internal.creation.MockSettingsImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package com.fitbur.mockito.internal.creation;
import com.fitbur.mockito.MockSettings;
import com.fitbur.mockito.exceptions.Reporter;
import static com.fitbur.mockito.exceptions.Reporter.*;
import com.fitbur.mockito.internal.creation.settings.CreationSettings;
import com.fitbur.mockito.internal.debugging.VerboseMockInvocationLogger;
import com.fitbur.mockito.internal.util.MockCreationValidator;
import com.fitbur.mockito.internal.util.MockNameImpl;
import com.fitbur.mockito.listeners.InvocationListener;
import com.fitbur.mockito.mock.MockCreationSettings;
import com.fitbur.mockito.mock.MockName;
import com.fitbur.mockito.mock.SerializableMode;
import com.fitbur.mockito.stubbing.Answer;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static com.fitbur.mockito.internal.util.collections.Sets.newSet;
@SuppressWarnings("unchecked")
public class MockSettingsImpl extends CreationSettings implements MockSettings, MockCreationSettings {
private static final long serialVersionUID = 4475297236197939569L;
private boolean useConstructor;
private Object outerClassInstance;
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) {
throw extraInterfacesRequiresAtLeastOneInterface();
}
for (Class> i : extraInterfaces) {
if (i == null) {
throw extraInterfacesDoesNotAcceptNullParameters();
} else if (!i.isInterface()) {
throw 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) {
throw defaultAnswerDoesNotAcceptNullParameter();
}
return this;
}
public Answer