AsciiDoctorScriptModelBuilder { public AsciiDoctorScriptModel build(String asciidoctorScript) throws AsciiDoctorScriptModelException { AsciiDoctorScriptModel model = new AsciiDoctorScriptModel(); Collection<AsciiDoctorHeadline> headlines = headlineParser.parse(asciidoctorScript); Collection<AsciiDoctorFileReference> includes = INCLUDE_PARSER.parse(asciidoctorScript); Collection<AsciiDoctorFileReference> images = IMAGE_PARSER.parse(asciidoctorScript); Collection<AsciiDoctorFileReference> plantuml = PLANTUML_PARSER.parse(asciidoctorScript); Collection<AsciiDoctorFileReference> ditaa = DITAA_PARSER.parse(asciidoctorScript); Collection<AsciiDoctorInlineAnchor> inlineAnchors = inlineAnchorParser.parse(asciidoctorScript); model.getHeadlines().addAll(headlines); model.getIncludes().addAll(includes); model.getInlineAnchors().addAll(inlineAnchors); model.getImages().addAll(images); model.getDiagrams().addAll(plantuml); model.getDiagrams().addAll(ditaa); handleHeadlinesWithAnchorsBefore(model); handleHeadlinesWithSameCalculatedIdsWhereNoIdSet(model); return model; }  AsciiDoctorScriptModel build(String asciidoctorScript);  }
@Test public void a_headline_with_anker_before_gets_id_of_anker() throws Exception { AsciiDoctorScriptModel asciidoctorScriptModel = builderToTest.build("[[anker1]]\n== Headline1"); assertThat(asciidoctorScriptModel).hasHeadlines(1).hasHeadline("Headline1").hasHeadlineWithId("anker1"); }
@Test public void three_headlines_with_same_name_got_numbering_first_has_no_number() throws Exception { AsciiDoctorScriptModel asciidoctorScriptModel = builderToTest.build("== Headline1\nsometext\n\n== Headline1\nsometext\n\n== Headline1\nsometext\n\n"); assertThat(asciidoctorScriptModel). hasHeadlines(3). hasHeadlineWithId("_headline1"). hasHeadlineWithId("_headline1_2"). hasHeadlineWithId("_headline1_3"); }
@Test public void a_line_with_5_spaces_and_Xfunction_test_is_NOT_recognized() throws Exception { AsciiDoctorScriptModel asciidoctorScriptModel = builderToTest.build(" Xfunction test {}"); assertThat(asciidoctorScriptModel).hasNoHeadlines(); }