• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockito.plugins;
6 
7 import org.mockito.Mockito;
8 import org.mockito.MockitoFramework;
9 
10 /**
11  * Instance of this interface is available via {@link MockitoFramework#getPlugins()}.
12  * This object enables framework integrators to get access to default Mockito plugins.
13  * <p>
14  * Example use case: one needs to implement custom {@link MockMaker}
15  * and delegate some behavior to the default Mockito implementation.
16  * The interface was introduced to help framework integrations.
17  *
18  * @since 2.10.0
19  */
20 public interface MockitoPlugins {
21 
22     /**
23      * Returns the default plugin implementation used by Mockito.
24      * Mockito plugins are stateless so it is recommended to keep hold of the returned plugin implementation
25      * rather than calling this method multiple times.
26      * Each time this method is called, new instance of the plugin is created.
27      *
28      * @param pluginType type of the plugin, for example {@link MockMaker}.
29      * @return the plugin instance
30      * @since 2.10.0
31      */
getDefaultPlugin(Class<T> pluginType)32     <T> T getDefaultPlugin(Class<T> pluginType);
33 
34     /**
35      * Returns inline mock maker, an optional mock maker that is bundled with Mockito distribution.
36      * This method is needed because {@link #getDefaultPlugin(Class)} does not provide an instance of inline mock maker.
37      * Creates new instance each time is called so it is recommended to keep hold of the resulting object for future invocations.
38      * For more information about inline mock maker see the javadoc for main {@link Mockito} class.
39      *
40      * @return instance of inline mock maker
41      * @since 2.10.0
42      */
getInlineMockMaker()43     MockMaker getInlineMockMaker();
44 }
45