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

com.fitbur.mockito.internal.debugging.WarningsCollector Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package com.fitbur.mockito.internal.debugging;

import com.fitbur.mockito.internal.invocation.InvocationMatcher;
import com.fitbur.mockito.internal.invocation.UnusedStubsFinder;
import com.fitbur.mockito.internal.invocation.finder.AllInvocationsFinder;
import com.fitbur.mockito.internal.listeners.CollectCreatedMocks;
import com.fitbur.mockito.internal.progress.MockingProgress;
import com.fitbur.mockito.internal.progress.ThreadSafeMockingProgress;
import com.fitbur.mockito.invocation.Invocation;

import java.util.LinkedList;
import java.util.List;

@SuppressWarnings("unchecked")
public class WarningsCollector {
   
    private final List createdMocks;

    public WarningsCollector() {
        createdMocks = new LinkedList();
        MockingProgress progress = new ThreadSafeMockingProgress();
        progress.setListener(new CollectCreatedMocks(createdMocks));
    }

    public String getWarnings() {
        List unused = new UnusedStubsFinder().find(createdMocks);
        List all = new AllInvocationsFinder().find(createdMocks);
        List allInvocationMatchers = InvocationMatcher.createFrom(all);

        return new WarningsPrinterImpl(unused, allInvocationMatchers, false).print();
    }
}