1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5package org.mockito;
6
7import org.mockito.internal.stubbing.answers.CallsRealMethods;
8import org.mockito.internal.stubbing.defaultanswers.GloballyConfiguredAnswer;
9import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
10import org.mockito.internal.stubbing.defaultanswers.ReturnsMocks;
11import org.mockito.internal.stubbing.defaultanswers.ReturnsSmartNulls;
12import org.mockito.stubbing.Answer;
13
14/**
15 * Enumeration of pre-configured mock answers
16 * <p>
17 * You can use it to pass extra parameters to &#064;Mock annotation, see more info here: {@link Mock}
18 * <p>
19 * Example:
20 * <pre class="code"><code class="java">
21 *   &#064;Mock(answer = RETURNS_DEEP_STUBS) UserProvider userProvider;
22 * </code></pre>
23 * <b>This is not the full list</b> of Answers available in Mockito. Some interesting answers can be found in org.mockito.stubbing.answers package.
24 */
25public enum Answers {
26
27    /**
28     * The default configured answer of every mock.
29     *
30     * <p>Please see the {@link org.mockito.Mockito#RETURNS_DEFAULTS} documentation for more details.</p>
31     *
32     * @see org.mockito.Mockito#RETURNS_DEFAULTS
33     */
34    RETURNS_DEFAULTS(new GloballyConfiguredAnswer()),
35
36    /**
37     * An answer that returns smart-nulls.
38     *
39     * <p>Please see the {@link org.mockito.Mockito#RETURNS_SMART_NULLS} documentation for more details.</p>
40     *
41     * @see org.mockito.Mockito#RETURNS_SMART_NULLS
42     */
43    RETURNS_SMART_NULLS(new ReturnsSmartNulls()),
44
45    /**
46     * An answer that returns <strong>mocks</strong> (not stubs).
47     *
48     * <p>Please see the {@link org.mockito.Mockito#RETURNS_MOCKS} documentation for more details.</p>
49     *
50     * @see org.mockito.Mockito#RETURNS_MOCKS
51     */
52    RETURNS_MOCKS(new ReturnsMocks()),
53
54
55    /**
56     * An answer that returns <strong>deep stubs</strong> (not mocks).
57     *
58     * <p>Please see the {@link org.mockito.Mockito#RETURNS_DEEP_STUBS} documentation for more details.</p>
59     *
60     * @see org.mockito.Mockito#RETURNS_DEEP_STUBS
61     */
62    RETURNS_DEEP_STUBS(new ReturnsDeepStubs()),
63
64    /**
65     * An answer that calls the real methods (used for partial mocks).
66     *
67     * <p>Please see the {@link org.mockito.Mockito#CALLS_REAL_METHODS} documentation for more details.</p>
68     *
69     * @see org.mockito.Mockito#CALLS_REAL_METHODS
70     */
71    CALLS_REAL_METHODS(new CallsRealMethods())
72    ;
73
74    private Answer<Object> implementation;
75
76    private Answers(Answer<Object> implementation) {
77        this.implementation = implementation;
78    }
79
80    public Answer<Object> get() {
81        return implementation;
82    }
83}