Пример #1
0
 private String getFullyQualifiedClassName(final Path path) {
   final Package pkg = projectService.resolvePackage(Paths.convert(path));
   final String packageName = pkg.getPackageName();
   if (packageName == null) {
     return null;
   }
   final String className = path.getFileName().toString().replace(".java", "");
   return (packageName.equals("") ? className : packageName + "." + className);
 }
  @Test
  public void testResolvePackageDefaultResources() throws Exception {

    final Bean projectServiceBean =
        (Bean) beanManager.getBeans(ProjectService.class).iterator().next();
    final CreationalContext cc = beanManager.createCreationalContext(projectServiceBean);
    final ProjectService projectService =
        (ProjectService) beanManager.getReference(projectServiceBean, ProjectService.class, cc);

    final URL testUrl =
        this.getClass().getResource("/ProjectBackendTestProjectStructureValid/src/main/resources");
    final org.kie.commons.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
    final Path testPath = paths.convert(nioTestPath);

    // Test /src/main/resources resolves as the default package
    final Package result = projectService.resolvePackage(testPath);
    assertEquals("", result.getPackageName());
  }