Search in sources :

Example 1 with InvocationComparator

use of org.mockito.internal.invocation.InvocationComparator in project mockito by mockito.

the class AllInvocationsFinder method find.

/**
 * gets all invocations from mocks. Invocations are ordered earlier first.
 *
 * @param mocks mocks
 * @return invocations
 */
public static List<Invocation> find(Iterable<?> mocks) {
    Set<Invocation> invocationsInOrder = new TreeSet<>(new InvocationComparator());
    for (Object mock : mocks) {
        Collection<Invocation> fromSingleMock = new DefaultMockingDetails(mock).getInvocations();
        invocationsInOrder.addAll(fromSingleMock);
    }
    return new LinkedList<>(invocationsInOrder);
}
Also used : Invocation(org.mockito.invocation.Invocation) TreeSet(java.util.TreeSet) DefaultMockingDetails(org.mockito.internal.util.DefaultMockingDetails) InvocationComparator(org.mockito.internal.invocation.InvocationComparator) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 TreeSet (java.util.TreeSet)1 InvocationComparator (org.mockito.internal.invocation.InvocationComparator)1 DefaultMockingDetails (org.mockito.internal.util.DefaultMockingDetails)1 Invocation (org.mockito.invocation.Invocation)1