ApiModelBuilder { public ApiModel buildApiModel(String sourceFileName) { RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(sourceFileName); log.debug("Finished parsing"); if (ramlModelResult.hasErrors()) { StringBuilder builder = new StringBuilder("RAML syntax errors:\n"); for (ValidationResult result : ramlModelResult.getValidationResults()) { builder.append(result.getPath()); builder.append(": "); builder.append(result.getMessage()); } throw new ParserException(builder.toString()); } Api api = ramlModelResult.getApiV10(); return new ApiModel(api); }  ApiModel buildApiModel(String sourceFileName);  }
@Test public void shouldLogParserErrors() { assertThatExceptionOfType(ParserException.class) .isThrownBy(() -> new ApiModelBuilder().buildApiModel("raml/syntaxError.raml")) .withMessageContaining("RAML syntax errors") .withMessageContaining("/types/City/properties/population/type") .withMessageContaining("Invalid reference 'int'"); }