use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleServiceImplResolvePackageInvalidNoKModuleTest method testResolvePackageWithJavaFileInSubPackage.
@Test
public void testResolvePackageWithJavaFileInSubPackage() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureInvalidNoKModule/src/main/java/org/kie/test");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureInvalidNoKModule/src/main/java/org/kie/test/Bean.java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
// Test a non-Project Path resolves to null
final Package result = moduleService.resolvePackage(testPath);
assertNull(result);
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleServiceImplResolvePackageNameValidTest method testResolvePackageWithRootPath.
@Test
public void testResolvePackageWithRootPath() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
// Test a root resolves to null
final Package result = moduleService.resolvePackage(rootPath);
assertNull(result);
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleServiceImplResolvePackageNameValidTest method testResolvePackageWithMainPath.
@Test
public void testResolvePackageWithMainPath() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
// Test a root/src/main resolves to null
final Package result = moduleService.resolvePackage(rootPath);
assertNull(result);
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleServiceImplResolvePackageNameValidTest method testResolvePackageDefaultResources.
@Test
public void testResolvePackageDefaultResources() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/resources");
final org.uberfire.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 = moduleService.resolvePackage(testPath);
assertEquals("", result.getPackageName());
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleServiceImplResolvePackageNameValidTest method testResolvePackageWithJavaFileInDefaultPackage.
@Test
public void testResolvePackageWithJavaFileInDefaultPackage() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java/Bean.java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
// Test a Java file resolves to the containing package
final Package result = moduleService.resolvePackage(testPath);
assertEquals("", result.getPackageName());
}
Aggregations