• 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.internal.listeners;
6 
7 /**
8  * Listens to attempts to look up stubbing answer for given mocks. This class is internal for now.
9  * <p>
10  * How does it work?
11  * When method is called on the mock object, Mockito looks for any answer (stubbing) declared on that mock.
12  * If the stubbed answer is found, that answer is invoked (value returned, thrown exception, etc.).
13  * If the answer is not found (e.g. that invocation was not stubbed on the mock), mock's default answer is used.
14  * This listener implementation is notified when Mockito looked up an answer for invocation on a mock.
15  * <p>
16  * If we make this interface a part of public API (and we should):
17  *  - make the implementation unified with InvocationListener (for example: common parent, marker interface MockObjectListener
18  *  single method for adding listeners so long they inherit from the parent)
19  *  - make the error handling strict
20  * so that Mockito provides decent message when listener fails due to poor implementation.
21  */
22 public interface StubbingLookupListener {
23 
24     /**
25      * Called by the framework when Mockito looked up an answer for invocation on a mock.
26      *
27      * @param stubbingLookupEvent - Information about the looked up stubbing
28      */
onStubbingLookup(StubbingLookupEvent stubbingLookupEvent)29     void onStubbingLookup(StubbingLookupEvent stubbingLookupEvent);
30 }
31