blob: d92fc287340c262ba1f3e2ca02385ff5137eda79 (
plain)
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
|
/*
* Copyright (c) 2016 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.framework;
import org.mockito.MockitoFramework;
import org.mockito.internal.configuration.plugins.Plugins;
import org.mockito.internal.invocation.DefaultInvocationFactory;
import org.mockito.internal.util.Checks;
import org.mockito.invocation.InvocationFactory;
import org.mockito.listeners.MockitoListener;
import org.mockito.plugins.InlineMockMaker;
import org.mockito.plugins.MockMaker;
import org.mockito.plugins.MockitoPlugins;
import static org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress;
public class DefaultMockitoFramework implements MockitoFramework {
public MockitoFramework addListener(MockitoListener listener) {
Checks.checkNotNull(listener, "listener");
mockingProgress().addListener(listener);
return this;
}
public MockitoFramework removeListener(MockitoListener listener) {
Checks.checkNotNull(listener, "listener");
mockingProgress().removeListener(listener);
return this;
}
@Override
public MockitoPlugins getPlugins() {
return Plugins.getPlugins();
}
@Override
public InvocationFactory getInvocationFactory() {
return new DefaultInvocationFactory();
}
private InlineMockMaker getInlineMockMaker() {
MockMaker mockMaker = Plugins.getMockMaker();
return (mockMaker instanceof InlineMockMaker) ? (InlineMockMaker) mockMaker : null;
}
@Override
public void clearInlineMocks() {
InlineMockMaker mockMaker = getInlineMockMaker();
if (mockMaker != null) {
mockMaker.clearAllMocks();
}
}
@Override
public void clearInlineMock(Object mock) {
InlineMockMaker mockMaker = getInlineMockMaker();
if (mockMaker != null) {
mockMaker.clearMock(mock);
}
}
}
|