### Question:
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);  }### Answer:
@Test public void found_NO_block_when_children_block_has_only_1_entry() { StringBuilder sb = new StringBuilder(); sb.append("1234\n"); sb.append(" 8\n\n"); sb.append("1234\n"); String text = sb.toString(); List<IndentionBlock> result = builderToTest.build(text); assertEquals(0,result.size()); }
@Test public void found_NO_block_when_children_block_has_only_2_entries() { StringBuilder sb = new StringBuilder(); sb.append("1234\n"); sb.append(" 8\n\n"); sb.append(" 8\n\n"); sb.append("1234\n"); String text = sb.toString(); List<IndentionBlock> result = builderToTest.build(text); assertEquals(0,result.size()); }
@Test public void found_one_Block_when_3_chilren_in_block() { 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"); String text = sb.toString(); List<IndentionBlock> result = builderToTest.build(text); assertEquals(1,result.size()); Iterator<IndentionBlock> iterator = result.iterator(); IndentionBlock block1 = iterator.next(); assertEquals(0,block1.getStart()); assertEquals(19,block1.getEnd()); assertEquals(0,block1.getIndention()); }
@Test public void found_one_Block_when_3_chilren_different_indents_in_block() { 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"); String text = sb.toString(); List<IndentionBlock> result = builderToTest.build(text); assertEquals(1,result.size()); Iterator<IndentionBlock> iterator = result.iterator(); IndentionBlock block1 = iterator.next(); assertEquals(0,block1.getStart()); assertEquals(22,block1.getEnd()); assertEquals(0,block1.getIndention()); }
@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()); }