Search in sources :

Example 86 with CreationalContext

use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.

the class BuilderTestBase method getReference.

protected <T> T getReference(Class<T> clazz) {
    Bean bean = (Bean) beanManager.getBeans(clazz).iterator().next();
    CreationalContext cc = beanManager.createCreationalContext(bean);
    return (T) beanManager.getReference(bean, clazz, cc);
}
Also used : CreationalContext(javax.enterprise.context.spi.CreationalContext) Bean(javax.enterprise.inject.spi.Bean)

Example 87 with CreationalContext

use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.

the class BuilderTestBase method setUpGuvnorM2Repo.

protected void setUpGuvnorM2Repo() {
    Bean m2RepoServiceBean = (Bean) beanManager.getBeans(ExtendedM2RepoService.class).iterator().next();
    CreationalContext cc = beanManager.createCreationalContext(m2RepoServiceBean);
    ExtendedM2RepoService m2RepoService = (ExtendedM2RepoService) beanManager.getReference(m2RepoServiceBean, ExtendedM2RepoService.class, cc);
    String m2RepoURL = m2RepoService.getRepositoryURL();
    // Deploy a 1.0 version of guvnor-m2repo-dependency-example1-snapshot kjar
    GAV gav = new GAV("org.kie.workbench.common.services.builder.tests", "dependency-test1", "1.0");
    InputStream is = this.getClass().getResourceAsStream("/dependency-test1-1.0.jar");
    m2RepoService.deployJarInternal(is, gav);
    // Deploy a SNAPSHOT version of guvnor-m2repo-dependency-example1-snapshot kjar
    GAV gav2 = new GAV("org.kie.workbench.common.services.builder.tests", "dependency-test1-snapshot", "1.0-SNAPSHOT");
    InputStream is2 = this.getClass().getResourceAsStream("/dependency-test1-snapshot-1.0-SNAPSHOT.jar");
    m2RepoService.deployJarInternal(is2, gav2);
}
Also used : CreationalContext(javax.enterprise.context.spi.CreationalContext) InputStream(java.io.InputStream) GAV(org.guvnor.common.services.project.model.GAV) Bean(javax.enterprise.inject.spi.Bean) ExtendedM2RepoService(org.guvnor.m2repo.backend.server.ExtendedM2RepoService)

Example 88 with CreationalContext

use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.

the class ModuleImplResolveModuleValidTest method testResolveModuleWithRootPath.

@Test
public void testResolveModuleWithRootPath() 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 the Module's root
    final Module result = moduleService.resolveModule(rootPath);
    assertEquals(rootPath.toURI(), result.getRootPath().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 89 with CreationalContext

use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.

the class ModuleImplResolveModuleValidTest method testResolveModuleWithResourcesFile.

@Test
public void testResolveModuleWithResourcesFile() 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);
    final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/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 child folder resolves to the Module's root
    final Module result = moduleService.resolveModule(testPath);
    assertEquals(rootPath.toURI(), result.getRootPath().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 90 with CreationalContext

use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.

the class ModuleImplResolveModuleValidTest method testResolveModuleWithGlobalFile.

@Test
public void testResolveModuleWithGlobalFile() 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);
    final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/global/themes.json");
    final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
    final Path testPath = paths.convert(nioTestPath);
    // Test a child folder resolves to the Module's root
    final Module result = moduleService.resolveModule(testPath);
    assertEquals(rootPath.toURI(), result.getRootPath().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) CreationalContext(javax.enterprise.context.spi.CreationalContext) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Aggregations

CreationalContext (javax.enterprise.context.spi.CreationalContext)129 Bean (javax.enterprise.inject.spi.Bean)110 Test (org.junit.Test)83 URL (java.net.URL)67 Path (org.uberfire.backend.vfs.Path)67 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)66 Package (org.guvnor.common.services.project.model.Package)43 Module (org.guvnor.common.services.project.model.Module)13 BeanManager (javax.enterprise.inject.spi.BeanManager)10 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)6 IncrementalBuildResults (org.guvnor.common.services.project.builder.model.IncrementalBuildResults)6 Before (org.junit.Before)6 ArrayList (java.util.ArrayList)4 Context (javax.enterprise.context.spi.Context)4 InjectionTarget (javax.enterprise.inject.spi.InjectionTarget)4 WebBeansContext (org.apache.webbeans.config.WebBeansContext)4 Annotation (java.lang.annotation.Annotation)3 Method (java.lang.reflect.Method)3 Type (java.lang.reflect.Type)3 HashMap (java.util.HashMap)3