diff options
author | Paul Duffin <paulduffin@google.com> | 2017-03-03 10:59:02 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2017-03-07 13:42:56 +0000 |
commit | d174d376bccaf52c3273473bcc34bdb11b50bd67 (patch) | |
tree | 1fc35d29b265d03aec96fc5c74f050365a2695b5 /src/main/java/org/mockito/mock | |
parent | 134e857e0377f553c0be5f0344238ade69c5de53 (diff) | |
download | mockito-d174d376bccaf52c3273473bcc34bdb11b50bd67.tar.gz |
Restructure files to match upstream mockito
Makes the file structure match upstream mockito so that it is
simpler to update in future. Moving the files as a separate
step to upgrading makes it easier for git to track renames and
simplifies future diffs and reviews.
Bug: 32912773
Test: make checkbuild
Change-Id: I884ba2cc2856fd19d31bdb658fa058c47d078982
Diffstat (limited to 'src/main/java/org/mockito/mock')
-rw-r--r-- | src/main/java/org/mockito/mock/MockCreationSettings.java | 83 | ||||
-rw-r--r-- | src/main/java/org/mockito/mock/MockName.java | 21 | ||||
-rw-r--r-- | src/main/java/org/mockito/mock/SerializableMode.java | 26 |
3 files changed, 130 insertions, 0 deletions
diff --git a/src/main/java/org/mockito/mock/MockCreationSettings.java b/src/main/java/org/mockito/mock/MockCreationSettings.java new file mode 100644 index 0000000..6b91a47 --- /dev/null +++ b/src/main/java/org/mockito/mock/MockCreationSettings.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2007 Mockito contributors + * This program is made available under the terms of the MIT License. + */ + +package org.mockito.mock; + +import org.mockito.Incubating; +import org.mockito.listeners.InvocationListener; +import org.mockito.stubbing.Answer; + +import java.util.List; +import java.util.Set; + +/** + * Informs about the mock settings. An immutable view of {@link org.mockito.MockSettings}. + */ +public interface MockCreationSettings<T> { + + /** + * Mocked type. An interface or class the mock should implement / extend. + */ + Class<T> getTypeToMock(); + + /** + * the extra interfaces the mock object should implement. + */ + Set<Class> getExtraInterfaces(); + + /** + * the name of this mock, as printed on verification errors; see {@link org.mockito.MockSettings#name}. + */ + MockName getMockName(); + + /** + * the default answer for this mock, see {@link org.mockito.MockSettings#defaultAnswer}. + */ + Answer getDefaultAnswer(); + + /** + * the spied instance - needed for spies. + */ + Object getSpiedInstance(); + + /** + * if the mock is serializable, see {@link org.mockito.MockSettings#serializable}. + */ + boolean isSerializable(); + + /** + * @return the serializable mode of this mock + */ + SerializableMode getSerializableMode(); + + /** + * Whether the mock is only for stubbing, i.e. does not remember + * parameters on its invocation and therefore cannot + * be used for verification + */ + boolean isStubOnly(); + + /** + * The invocation listeners attached to this mock, see {@link org.mockito.MockSettings#invocationListeners}. + */ + List<InvocationListener> getInvocationListeners(); + + /** + * Informs whether the mock instance should be created via constructor + * + * @since 1.10.12 + */ + @Incubating + boolean isUsingConstructor(); + + /** + * Used when mocking non-static inner classes in conjunction with {@link #isUsingConstructor()} + * + * @return the outer class instance used for creation of the mock object via the constructor. + * @since 1.10.12 + */ + @Incubating + Object getOuterClassInstance(); +}
\ No newline at end of file diff --git a/src/main/java/org/mockito/mock/MockName.java b/src/main/java/org/mockito/mock/MockName.java new file mode 100644 index 0000000..d3f6e7d --- /dev/null +++ b/src/main/java/org/mockito/mock/MockName.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2007 Mockito contributors + * This program is made available under the terms of the MIT License. + */ +package org.mockito.mock; + +/** + * Represents the name of the mock as shown in the verification failure reports, etc. + */ +public interface MockName { + + /** + * the name + */ + String toString(); + + /** + * default name means generated by Mockito. non-default means the user has named the mock at creation. + */ + boolean isDefault(); +} diff --git a/src/main/java/org/mockito/mock/SerializableMode.java b/src/main/java/org/mockito/mock/SerializableMode.java new file mode 100644 index 0000000..d10b1d6 --- /dev/null +++ b/src/main/java/org/mockito/mock/SerializableMode.java @@ -0,0 +1,26 @@ +package org.mockito.mock; + +import org.mockito.Incubating; + +/** + * Mock serializable style. + */ +@Incubating +public enum SerializableMode { + + /** + * No serialization. + */ + NONE, + + /** + * Basic serializable mode for mock objects. Introduced in Mockito 1.8.1. + */ + BASIC, + + /** + * Useful if the mock is deserialized in a different classloader / vm. + */ + @Incubating + ACROSS_CLASSLOADERS +}
\ No newline at end of file |