### Question:
ScriptDocumentationFactory implements TopLevelDocumentationFactory<ScriptDocumentation> { @Override public boolean canParse(final int currentIndex, final List<String> source) { int previousNonEmptyIndex = -1; for (int previousIndex = currentIndex - 1; previousIndex > -1; previousIndex--) { if (!StringUtils.strip(source.get(previousIndex)).isEmpty()) { previousNonEmptyIndex = previousIndex; break; } } return parser.canParse(source.get(currentIndex)) && previousNonEmptyIndex > -1 && StringUtils .startsWithIgnoreCase(StringUtils.strip(source.get(previousNonEmptyIndex)), "CREATE PROGRAM "); } ScriptDocumentationFactory();  ScriptDocumentationFactory(final ScriptDocumentationParser parser); @Override boolean canParse(final int currentIndex, final List<String> source); @Override int getEndingIndex(); @Override ScriptDocumentation parse(final int currentIndex, final List<String> source);  }### Answer:
@Test public void testCanParse() { final List<String> source = Arrays.asList("CREATE PROGRAM TEST", ""); when(parser.canParse(source.get(1))).thenReturn(Boolean.TRUE); assertThat(factory.canParse(1, source)).isTrue(); }
@Test public void testCanParseFirstLine() { final List<String> source = Arrays.asList("CREATE PROGRAM TEST", ""); when(parser.canParse(source.get(0))).thenReturn(Boolean.TRUE); assertThat(factory.canParse(0, source)).isFalse(); }
@Test public void testCanParseNotCreateProgram() { final List<String> source = Arrays.asList("DROP PROGRAM TEST", ""); when(parser.canParse(source.get(1))).thenReturn(Boolean.TRUE); assertThat(factory.canParse(1, source)).isFalse(); }
@Test public void testCanParseParserCannotParse() { final List<String> source = Arrays.asList("CREATE PROGRAM TEST", ""); when(parser.canParse(source.get(1))).thenReturn(Boolean.FALSE); assertThat(factory.canParse(1, source)).isFalse(); }