org.mockito.internal.exceptions.util.ScenarioPrinter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-core Show documentation
Show all versions of mockito-core Show documentation
Mockito mock objects library core API and implementation
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.exceptions.util;
import java.util.List;
import org.mockito.internal.exceptions.VerificationAwareInvocation;
public class ScenarioPrinter {
public String print(List invocations) {
if (invocations.size() == 1) {
return "Actually, above is the only interaction with this mock.";
}
StringBuilder sb = new StringBuilder(
"***\n" +
"For your reference, here is the list of all invocations ([?] - means unverified).\n");
int counter = 0;
for (VerificationAwareInvocation i : invocations) {
sb.append(++counter).append(". ");
if (!i.isVerified()) {
sb.append("[?]");
}
sb.append(i.getLocation()).append("\n");
}
return sb.toString();
}
}