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.exceptions.util; 6 7 import java.util.List; 8 9 import org.mockito.internal.exceptions.VerificationAwareInvocation; 10 11 public class ScenarioPrinter { 12 print(List<VerificationAwareInvocation> invocations)13 public String print(List<VerificationAwareInvocation> invocations) { 14 if (invocations.size() == 1) { 15 return "Actually, above is the only interaction with this mock."; 16 } 17 StringBuilder sb = new StringBuilder( 18 "***\n" + 19 "For your reference, here is the list of all invocations ([?] - means unverified).\n"); 20 21 int counter = 0; 22 for (VerificationAwareInvocation i : invocations) { 23 sb.append(++counter + ". "); 24 if (!i.isVerified()) { 25 sb.append("[?]"); 26 } 27 sb.append(i.getLocation() + "\n"); 28 } 29 String scenario = sb.toString(); 30 return scenario; 31 } 32 33 } 34