JavaParserUtils { public static CompilationUnit getFromFileName(String fileName) { try { final InputStream resource = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); return StaticJavaParser.parse(resource); } catch (ParseProblemException e) { throw new KiePMMLInternalException(String.format("Failed to parse %s due to %s", fileName, e.getMessage()), e); } catch (Exception e) { throw new ExternalException(String.format("Failed to read %s due to %s", fileName, e.getMessage()), e); } } private  JavaParserUtils(); static CompilationUnit getFromFileName(String fileName); static CompilationUnit getKiePMMLModelCompilationUnit(final String className,
                                                                 final String packageName,
                                                                 final String javaTemplate,
                                                                 final String modelClassName); static String getFullClassName(final CompilationUnit cu); static final String MAIN_CLASS_NOT_FOUND; }
@Test public void getFromFileName() { CompilationUnit retrieved = JavaParserUtils.getFromFileName(TEMPLATE_FILE); assertNotNull(retrieved); }
@Test(expected = KiePMMLInternalException.class) public void getFromFileNameNotParsable() { JavaParserUtils.getFromFileName(NOT_PARSABLE_FILE); }
@Test(expected = AssertionError.class) public void getFromFileNameNotExisting() { JavaParserUtils.getFromFileName("not_existing"); }