StringWrapper { public static String wrap(String input, Formatter formatter) throws FormatterException { return StringWrapper.wrap(Formatter.MAX_LINE_LENGTH, input, formatter); } private  StringWrapper(); static String wrap(String input, Formatter formatter); static final CharMatcher STRING_CONCAT_DELIMITER; }
@Test public void testAwkwardLineEndWrapping() throws Exception { String input = lines( "class T {", " String s = someMethodWithQuiteALongNameThatWillGetUsUpCloseToTheColumnLimit() " + "+ \"foo bar foo bar foo bar\";", "", " String someMethodWithQuiteALongNameThatWillGetUsUpCloseToTheColumnLimit() {", " return null;", " }", "}"); String output = lines( "class T {", " String s =", " someMethodWithQuiteALongNameThatWillGetUsUpCloseToTheColumnLimit()", " + \"foo bar foo bar foo bar\";", "", " String someMethodWithQuiteALongNameThatWillGetUsUpCloseToTheColumnLimit() {", " return null;", " }", "}"); assertThat(StringWrapper.wrap(100, input, new Formatter())).isEqualTo(output); }