/
MockCreationSettings.java
145 lines (124 loc) · 4.56 KB
/
MockCreationSettings.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.mock;
import java.util.List;
import java.util.Set;
import org.mockito.MockSettings;
import org.mockito.NotExtensible;
import org.mockito.listeners.InvocationListener;
import org.mockito.listeners.StubbingLookupListener;
import org.mockito.listeners.VerificationStartedListener;
import org.mockito.plugins.MockMaker;
import org.mockito.quality.Strictness;
import org.mockito.stubbing.Answer;
/**
* Informs about the mock settings. An immutable view of {@link org.mockito.MockSettings}.
*/
@NotExtensible
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();
/**
* Whether the mock should not make a best effort to preserve annotations.
*/
boolean isStripAnnotations();
/**
* Returns {@link StubbingLookupListener} instances attached to this mock via {@link MockSettings#stubbingLookupListeners(StubbingLookupListener...)}.
* The resulting list is mutable, you can add/remove listeners even after the mock was created.
* <p>
* For more details see {@link StubbingLookupListener}.
*
* @since 2.24.6
*/
List<StubbingLookupListener> getStubbingLookupListeners();
/**
* {@link InvocationListener} instances attached to this mock, see {@link org.mockito.MockSettings#invocationListeners(InvocationListener...)}.
*/
List<InvocationListener> getInvocationListeners();
/**
* {@link VerificationStartedListener} instances attached to this mock,
* see {@link org.mockito.MockSettings#verificationStartedListeners(VerificationStartedListener...)}
*
* @since 2.11.0
*/
List<VerificationStartedListener> getVerificationStartedListeners();
/**
* Informs whether the mock instance should be created via constructor
*
* @since 1.10.12
*/
boolean isUsingConstructor();
/**
* Used when arguments should be passed to the mocked object's constructor, regardless of whether these
* arguments are supplied directly, or whether they include the outer instance.
*
* @return An array of arguments that are passed to the mocked object's constructor. If
* {@link #getOuterClassInstance()} is available, it is prepended to the passed arguments.
*
* @since 2.7.14
*/
Object[] getConstructorArgs();
/**
* 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
*/
Object getOuterClassInstance();
/**
* @deprecated Use {@link MockCreationSettings#getStrictness()} instead.
*
* Informs if the mock was created with "lenient" strictness, e.g. having {@link Strictness#LENIENT} characteristic.
* For more information about using mocks with lenient strictness, see {@link MockSettings#lenient()}.
*
* @since 2.20.0
*/
@Deprecated
boolean isLenient();
/**
* Sets strictness level for the mock, e.g. having {@link Strictness#STRICT_STUBS} characteristic.
* For more information about using mocks with custom strictness, see {@link MockSettings#strictness(Strictness)}.
*
* @since 4.6.0
*/
Strictness getStrictness();
/**
* The {@link MockMaker} which shall by used instead of the default. When
* the return value is {@code null}, the default shall be used.
*/
Class<? extends MockMaker> getMockMaker();
}