@Test public void found_two_Blocks_when_3_chilren_in_blocks() { StringBuilder sb = new StringBuilder(); sb.append("1234\n"); sb.append(" 8\n\n"); sb.append(" 8\n\n"); sb.append(" 8\n\n"); sb.append("1234\n"); sb.append(" 8\n\n"); sb.append(" 8\n\n"); sb.append(" 8"); String text = sb.toString(); List<IndentionBlock> result = builderToTest.build(text); assertEquals(2,result.size()); Iterator<IndentionBlock> iterator = result.iterator(); IndentionBlock block1 = iterator.next(); assertEquals(0,block1.getStart()); assertEquals(19,block1.getEnd()); assertEquals(0,block1.getIndention()); IndentionBlock block2 = iterator.next(); assertEquals(20,block2.getStart()); assertEquals(38,block2.getEnd()); assertEquals(0,block2.getIndention()); }
public List<IndentionBlock> build(String text) { String[] lines = LINE_SPLIT_PATTERN.split(text, -1); IndentContext context = new IndentContext(lines); for (int i = 0; i < lines.length; i++) { context.calculateIndentBlockForLineIfNecessary(i); } return context.list; }
IndentionBlockBuilder { public List<IndentionBlock> build(String text) { String[] lines = LINE_SPLIT_PATTERN.split(text, -1); IndentContext context = new IndentContext(lines); for (int i = 0; i < lines.length; i++) { context.calculateIndentBlockForLineIfNecessary(i); } return context.list; } }
IndentionBlockBuilder { public List<IndentionBlock> build(String text) { String[] lines = LINE_SPLIT_PATTERN.split(text, -1); IndentContext context = new IndentContext(lines); for (int i = 0; i < lines.length; i++) { context.calculateIndentBlockForLineIfNecessary(i); } return context.list; }  }
IndentionBlockBuilder { public List<IndentionBlock> build(String text) { String[] lines = LINE_SPLIT_PATTERN.split(text, -1); IndentContext context = new IndentContext(lines); for (int i = 0; i < lines.length; i++) { context.calculateIndentBlockForLineIfNecessary(i); } return context.list; }  List<IndentionBlock> build(String text); }
IndentionBlockBuilder { public List<IndentionBlock> build(String text) { String[] lines = LINE_SPLIT_PATTERN.split(text, -1); IndentContext context = new IndentContext(lines); for (int i = 0; i < lines.length; i++) { context.calculateIndentBlockForLineIfNecessary(i); } return context.list; }  List<IndentionBlock> build(String text);  }