Search in sources :

Example 1 with DefaultMockingDetails

use of org.mockito.internal.util.DefaultMockingDetails in project mockito by mockito.

the class AllInvocationsFinder method findStubbings.

/**
 * Gets all stubbings from mocks. Invocations are ordered earlier first.
 *
 * @param mocks mocks
 * @return stubbings
 */
public static Set<Stubbing> findStubbings(Iterable<?> mocks) {
    Set<Stubbing> stubbings = new TreeSet<>(new StubbingComparator());
    for (Object mock : mocks) {
        // the static mock.
        if (mock instanceof Class<?>) {
            continue;
        }
        Collection<? extends Stubbing> fromSingleMock = new DefaultMockingDetails(mock).getStubbings();
        stubbings.addAll(fromSingleMock);
    }
    return stubbings;
}
Also used : Stubbing(org.mockito.stubbing.Stubbing) StubbingComparator(org.mockito.internal.stubbing.StubbingComparator) TreeSet(java.util.TreeSet) DefaultMockingDetails(org.mockito.internal.util.DefaultMockingDetails)

Example 2 with DefaultMockingDetails

use of org.mockito.internal.util.DefaultMockingDetails 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

TreeSet (java.util.TreeSet)2 DefaultMockingDetails (org.mockito.internal.util.DefaultMockingDetails)2 LinkedList (java.util.LinkedList)1 InvocationComparator (org.mockito.internal.invocation.InvocationComparator)1 StubbingComparator (org.mockito.internal.stubbing.StubbingComparator)1 Invocation (org.mockito.invocation.Invocation)1 Stubbing (org.mockito.stubbing.Stubbing)1