org.mockito.internal.invocation.UnusedStubsFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-core Show documentation
Show all versions of mockito-core Show documentation
Mockito mock objects library core API and implementation
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.invocation;
import org.mockito.internal.util.MockUtil;
import org.mockito.invocation.Invocation;
import org.mockito.stubbing.Stubbing;
import java.util.LinkedList;
import java.util.List;
@Deprecated
public class UnusedStubsFinder {
/**
* Finds all unused stubs for given mocks
*
* @param mocks full list of mocks
*/
public List find(List mocks) {
List unused = new LinkedList();
for (Object mock : mocks) {
List fromSingleMock = MockUtil.getInvocationContainer(mock).getStubbingsDescending();
for(Stubbing s : fromSingleMock) {
if (!s.wasUsed()) {
unused.add(s.getInvocation());
}
}
}
return unused;
}
}