IndentTracker { String indent(String s) { if (count > 0) { StringBuilder sb = new StringBuilder(); sb.append("\n"); sb.append(getIndentation()); StringBuilder r = new StringBuilder(); r.append(getIndentation()); r.append(s.replaceAll("\n", sb.toString())); return r.toString(); } else { return s; } } IndentTracker();   }
@Test public void testIndent_1Level_SingleLine() { String expected = "\t1 line string"; String input = "1 line string"; String actual = it.indent(input); assertEquals(expected, actual); }
@Test public void testIndent_1Level_MultiLine() { String expected = "\tmulti\n\tline\n\tstring"; String input = "multi\nline\nstring"; String actual = it.indent(input); assertEquals(expected, actual); }