Search in sources :

Example 1 with MatchersPrinter

use of org.mockito.internal.matchers.text.MatchersPrinter in project mockito by mockito.

the class PrintSettings method print.

public String print(List<ArgumentMatcher> matchers, Invocation invocation) {
    MatchersPrinter matchersPrinter = new MatchersPrinter();
    String qualifiedName = MockUtil.getMockName(invocation.getMock()) + "." + invocation.getMethod().getName();
    String invocationString = qualifiedName + matchersPrinter.getArgumentsLine(matchers, this);
    if (isMultiline() || (!matchers.isEmpty() && invocationString.length() > MAX_LINE_LENGTH)) {
        return qualifiedName + matchersPrinter.getArgumentsBlock(matchers, this);
    } else {
        return invocationString;
    }
}
Also used : MatchersPrinter(org.mockito.internal.matchers.text.MatchersPrinter)

Example 2 with MatchersPrinter

use of org.mockito.internal.matchers.text.MatchersPrinter in project powermock by powermock.

the class ToStringGenerator method generate.

public String generate(Object mock, Method method, Object[] arguments) {
    final List<ArgumentMatcher> matcherList = ArgumentsProcessor.argumentsToMatchers(arguments);
    final PrintSettings printSettings = new PrintSettings();
    MatchersPrinter matchersPrinter = new MatchersPrinter();
    String methodName = Whitebox.getUnproxyType(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;
    }
}
Also used : ArgumentMatcher(org.mockito.ArgumentMatcher) PrintSettings(org.mockito.internal.reporting.PrintSettings) MatchersPrinter(org.mockito.internal.matchers.text.MatchersPrinter)

Aggregations

MatchersPrinter (org.mockito.internal.matchers.text.MatchersPrinter)2 ArgumentMatcher (org.mockito.ArgumentMatcher)1 PrintSettings (org.mockito.internal.reporting.PrintSettings)1