• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 
6 package org.mockito.internal.invocation;
7 
8 import org.mockito.internal.util.MockUtil;
9 import org.mockito.invocation.Invocation;
10 import org.mockito.stubbing.Stubbing;
11 
12 import java.util.LinkedList;
13 import java.util.List;
14 
15 @Deprecated
16 public class UnusedStubsFinder {
17 
18     /**
19      * Finds all unused stubs for given mocks
20      *
21      * @param mocks full list of mocks
22      */
find(List<?> mocks)23     public List<Invocation> find(List<?> mocks) {
24         List<Invocation> unused = new LinkedList<Invocation>();
25         for (Object mock : mocks) {
26             List<Stubbing> fromSingleMock = MockUtil.getInvocationContainer(mock).getStubbingsDescending();
27             for(Stubbing s : fromSingleMock) {
28                 if (!s.wasUsed()) {
29                      unused.add(s.getInvocation());
30                 }
31             }
32         }
33         return unused;
34     }
35 }
36