Search in sources :

Example 21 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class ModuleServiceImplResolvePackageInvalidNoPOMTest method testResolvePackageWithResourcesFileInDefaultPackage.

@Test
public void testResolvePackageWithResourcesFileInDefaultPackage() 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("/ModuleBackendTestModuleStructureInvalidNoPOM/src/main/resources/rule1.drl");
    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);
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Package(org.guvnor.common.services.project.model.Package) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 22 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class ModuleServiceImplResolvePackageInvalidNoPOMTest 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("/ModuleBackendTestModuleStructureInvalidNoPOM");
    final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
    final Path rootPath = paths.convert(nioRootPath);
    // Test a non-Project Path resolves to null
    final Package result = moduleService.resolvePackage(rootPath);
    assertNull(result);
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Package(org.guvnor.common.services.project.model.Package) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 23 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class ModuleServiceImplResolvePackageInvalidNoPOMTest method testResolvePackageWithResourcesFileInSubPackage.

@Test
public void testResolvePackageWithResourcesFileInSubPackage() 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("/ModuleBackendTestModuleStructureInvalidNoPOM/src/main/resources/org/kie/test/rule1.drl");
    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);
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Package(org.guvnor.common.services.project.model.Package) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 24 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class ModuleServiceImplResolvePackageNameValidTest method testResolvePackageDefaultJava.

@Test
public void testResolvePackageDefaultJava() 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");
    final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
    final Path testPath = paths.convert(nioTestPath);
    // Test /src/main/java resolves as the default package
    final Package result = moduleService.resolvePackage(testPath);
    assertEquals("", result.getPackageName());
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Package(org.guvnor.common.services.project.model.Package) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 25 with KieModuleService

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());
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Package(org.guvnor.common.services.project.model.Package) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Aggregations

KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)75 CreationalContext (javax.enterprise.context.spi.CreationalContext)66 Bean (javax.enterprise.inject.spi.Bean)66 Test (org.junit.Test)66 Path (org.uberfire.backend.vfs.Path)59 URL (java.net.URL)58 Package (org.guvnor.common.services.project.model.Package)49 Module (org.guvnor.common.services.project.model.Module)16 Before (org.junit.Before)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 Answer (org.mockito.stubbing.Answer)3 Path (org.uberfire.java.nio.file.Path)3 Set (java.util.Set)2 POM (org.guvnor.common.services.project.model.POM)2 FolderItem (org.kie.workbench.common.screens.explorer.model.FolderItem)2 FolderListing (org.kie.workbench.common.screens.explorer.model.FolderListing)2 ActiveOptions (org.kie.workbench.common.screens.explorer.service.ActiveOptions)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1