AsciiDoctorErrorBuilder { public AsciiDoctorMarker build(String originMessage){ int start=-1; int end=-1; String message = null; if (originMessage==null){ message="Unknown failure"; }else{ message = handleNotNullMessages(originMessage); } if (message==null){ message = originMessage; } AsciiDoctorMarker error = new AsciiDoctorMarker(start, end, message.trim()); return error; }  AsciiDoctorMarker build(String originMessage);  }
@Test public void even_a_null_message_results_in_error() { String message = null; AsciiDoctorMarker error = builderToTest.build(message); assertNotNull(error); assertEquals(-1, error.getStart()); assertEquals(-1, error.getEnd()); assertEquals(Type.ERROR, error.getType()); assertEquals("Unknown failure", error.getMessage()); }
@Test public void an_argument_error_with_adoc_colon_in_string_results_in_last_message_only() { String message = "(ArgumentError) asciidoctor: FAILED: C:/develop/projects/JCUP/eclipse-asciidoctor-editor/asciidoctor-editor-other/testscripts/17.failure_asciidocfile_not_utf_8_but_umlauts.adoc: Failed to load AsciiDoc document - invalid byte sequence in UTF-8"; AsciiDoctorMarker error = builderToTest.build(message); assertNotNull(error); assertEquals(-1, error.getStart()); assertEquals(-1, error.getEnd()); assertEquals(Type.ERROR, error.getType()); assertEquals("Failed to load AsciiDoc document - invalid byte sequence in UTF-8", error.getMessage()); }
@Test public void an_argument_error_with_adoc_no_colon_in_string_results_in_complete_message() { String message = "(ArgumentError) asciidoctor: FAILED: C:/develop/projects/JCUP/eclipse-asciidoctor-editor/asciidoctor-editor-other/testscripts/17.failure_asciidocfile_not_utf_8_but_umlauts.adoc Failed to load AsciiDoc document - invalid byte sequence in UTF-8"; AsciiDoctorMarker error = builderToTest.build(message); assertNotNull(error); assertEquals(-1, error.getStart()); assertEquals(-1, error.getEnd()); assertEquals(Type.ERROR, error.getType()); assertEquals(message, error.getMessage()); }