public class ToStringGenerator {
public String generate(Object mock, Method method, Object[] arguments) {
final List<Matcher> matcherList = ArgumentsProcessor.argumentsToMatchers(arguments);
final PrintSettings printSettings = new PrintSettings();
MatchersPrinter matchersPrinter = new MatchersPrinter();
String methodName = Whitebox.getType(mock).getName() + "." + method.getName();
String invocation = methodName + matchersPrinter.getArgumentsLine(matcherList, printSettings);
if (printSettings.isMultiline()
|| (!matcherList.isEmpty() && invocation.length() > Whitebox.<Integer> getInternalState(
PrintSettings.class, "MAX_LINE_LENGTH"))) {
return methodName + matchersPrinter.getArgumentsBlock(matcherList, printSettings);
} else {
return invocation;
}
}