Home | History | Annotate | Download | only in debugging
      1 /*
      2  * Copyright (c) 2007 Mockito contributors
      3  * This program is made available under the terms of the MIT License.
      4  */
      5 package org.mockito.internal.debugging;
      6 
      7 import org.mockito.internal.invocation.InvocationMatcher;
      8 import org.mockito.invocation.Invocation;
      9 
     10 import java.util.List;
     11 
     12 public class WarningsPrinterImpl {
     13 
     14     private final boolean warnAboutUnstubbed;
     15     private final WarningsFinder finder;
     16 
     17     public WarningsPrinterImpl(List<Invocation> unusedStubs, List<InvocationMatcher> allInvocations, boolean warnAboutUnstubbed) {
     18         this(warnAboutUnstubbed, new WarningsFinder(unusedStubs, allInvocations));
     19     }
     20 
     21     WarningsPrinterImpl(boolean warnAboutUnstubbed, WarningsFinder finder) {
     22         this.warnAboutUnstubbed = warnAboutUnstubbed;
     23         this.finder = finder;
     24     }
     25 
     26     public String print() {
     27         LoggingListener listener = new LoggingListener(warnAboutUnstubbed);
     28         finder.find(listener);
     29         return listener.getStubbingInfo();
     30     }
     31 }
     32