@Test public void testFillIndexBuilderWithUnavailablePath() throws Exception { final Path mockPath = mock(Path.class); when(ioService.exists(mockPath)).thenReturn(false); assertNull(indexer.fillIndexBuilder(mockPath)); }
@Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { if (!ioService.exists(path)) { logger.error("Unable to index {} : file does not exist.", path.toUri()); return null; } final KieModule module = getModule(path); if (module == null) { logger.error("Unable to index " + path.toUri().toString() + ": module could not be resolved."); return null; } final Package pkg = getPackage(path); if (pkg == null) { logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved."); return null; } final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), module, pkg); final String javaSource = ioService.readAllString(path); org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource); if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) { if (javaFileIndexerExtensions != null) { for (JavaFileIndexerExtension javaFileIndexerExtension : javaFileIndexerExtensions) { javaFileIndexerExtension.process(builder, javaType); } } String pkgName = pkg.getPackageName(); pkgName = javaType.getPackage(); if (pkgName == null) { pkgName = ""; } builder.setPackageName(pkgName); String javaTypeName = javaType.getQualifiedName(); Resource resParts = new Resource(javaTypeName, ResourceType.JAVA); if (javaType instanceof JavaSource) { ClassLoader moduleClassLoader = getModuleClassLoader(module); JavaSourceVisitor visitor = new JavaSourceVisitor((JavaSource) javaType, moduleClassLoader, resParts); visitor.visit((JavaSource) javaType); addReferencedResourcesToIndexBuilder(builder, visitor); } builder.addGenerator(resParts); } return builder; }
JavaFileIndexer extends AbstractFileIndexer { @Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { if (!ioService.exists(path)) { logger.error("Unable to index {} : file does not exist.", path.toUri()); return null; } final KieModule module = getModule(path); if (module == null) { logger.error("Unable to index " + path.toUri().toString() + ": module could not be resolved."); return null; } final Package pkg = getPackage(path); if (pkg == null) { logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved."); return null; } final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), module, pkg); final String javaSource = ioService.readAllString(path); org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource); if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) { if (javaFileIndexerExtensions != null) { for (JavaFileIndexerExtension javaFileIndexerExtension : javaFileIndexerExtensions) { javaFileIndexerExtension.process(builder, javaType); } } String pkgName = pkg.getPackageName(); pkgName = javaType.getPackage(); if (pkgName == null) { pkgName = ""; } builder.setPackageName(pkgName); String javaTypeName = javaType.getQualifiedName(); Resource resParts = new Resource(javaTypeName, ResourceType.JAVA); if (javaType instanceof JavaSource) { ClassLoader moduleClassLoader = getModuleClassLoader(module); JavaSourceVisitor visitor = new JavaSourceVisitor((JavaSource) javaType, moduleClassLoader, resParts); visitor.visit((JavaSource) javaType); addReferencedResourcesToIndexBuilder(builder, visitor); } builder.addGenerator(resParts); } return builder; } }
JavaFileIndexer extends AbstractFileIndexer { @Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { if (!ioService.exists(path)) { logger.error("Unable to index {} : file does not exist.", path.toUri()); return null; } final KieModule module = getModule(path); if (module == null) { logger.error("Unable to index " + path.toUri().toString() + ": module could not be resolved."); return null; } final Package pkg = getPackage(path); if (pkg == null) { logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved."); return null; } final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), module, pkg); final String javaSource = ioService.readAllString(path); org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource); if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) { if (javaFileIndexerExtensions != null) { for (JavaFileIndexerExtension javaFileIndexerExtension : javaFileIndexerExtensions) { javaFileIndexerExtension.process(builder, javaType); } } String pkgName = pkg.getPackageName(); pkgName = javaType.getPackage(); if (pkgName == null) { pkgName = ""; } builder.setPackageName(pkgName); String javaTypeName = javaType.getQualifiedName(); Resource resParts = new Resource(javaTypeName, ResourceType.JAVA); if (javaType instanceof JavaSource) { ClassLoader moduleClassLoader = getModuleClassLoader(module); JavaSourceVisitor visitor = new JavaSourceVisitor((JavaSource) javaType, moduleClassLoader, resParts); visitor.visit((JavaSource) javaType); addReferencedResourcesToIndexBuilder(builder, visitor); } builder.addGenerator(resParts); } return builder; }  }
JavaFileIndexer extends AbstractFileIndexer { @Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { if (!ioService.exists(path)) { logger.error("Unable to index {} : file does not exist.", path.toUri()); return null; } final KieModule module = getModule(path); if (module == null) { logger.error("Unable to index " + path.toUri().toString() + ": module could not be resolved."); return null; } final Package pkg = getPackage(path); if (pkg == null) { logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved."); return null; } final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), module, pkg); final String javaSource = ioService.readAllString(path); org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource); if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) { if (javaFileIndexerExtensions != null) { for (JavaFileIndexerExtension javaFileIndexerExtension : javaFileIndexerExtensions) { javaFileIndexerExtension.process(builder, javaType); } } String pkgName = pkg.getPackageName(); pkgName = javaType.getPackage(); if (pkgName == null) { pkgName = ""; } builder.setPackageName(pkgName); String javaTypeName = javaType.getQualifiedName(); Resource resParts = new Resource(javaTypeName, ResourceType.JAVA); if (javaType instanceof JavaSource) { ClassLoader moduleClassLoader = getModuleClassLoader(module); JavaSourceVisitor visitor = new JavaSourceVisitor((JavaSource) javaType, moduleClassLoader, resParts); visitor.visit((JavaSource) javaType); addReferencedResourcesToIndexBuilder(builder, visitor); } builder.addGenerator(resParts); } return builder; }  @Override boolean supportsPath(final Path path); @Override IndexBuilder fillIndexBuilder(final Path path); }
JavaFileIndexer extends AbstractFileIndexer { @Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { if (!ioService.exists(path)) { logger.error("Unable to index {} : file does not exist.", path.toUri()); return null; } final KieModule module = getModule(path); if (module == null) { logger.error("Unable to index " + path.toUri().toString() + ": module could not be resolved."); return null; } final Package pkg = getPackage(path); if (pkg == null) { logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved."); return null; } final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), module, pkg); final String javaSource = ioService.readAllString(path); org.jboss.forge.roaster.model.JavaType<?> javaType = Roaster.parse(javaSource); if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) { if (javaFileIndexerExtensions != null) { for (JavaFileIndexerExtension javaFileIndexerExtension : javaFileIndexerExtensions) { javaFileIndexerExtension.process(builder, javaType); } } String pkgName = pkg.getPackageName(); pkgName = javaType.getPackage(); if (pkgName == null) { pkgName = ""; } builder.setPackageName(pkgName); String javaTypeName = javaType.getQualifiedName(); Resource resParts = new Resource(javaTypeName, ResourceType.JAVA); if (javaType instanceof JavaSource) { ClassLoader moduleClassLoader = getModuleClassLoader(module); JavaSourceVisitor visitor = new JavaSourceVisitor((JavaSource) javaType, moduleClassLoader, resParts); visitor.visit((JavaSource) javaType); addReferencedResourcesToIndexBuilder(builder, visitor); } builder.addGenerator(resParts); } return builder; }  @Override boolean supportsPath(final Path path); @Override IndexBuilder fillIndexBuilder(final Path path);  }