All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockito.internal.invocation.UnusedStubsFinder Maven / Gradle / Ivy

There is a newer version: 5.12.0
Show newest version
/*
 * 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy