Search in sources :

Example 26 with BuildResults

use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.

the class BuilderTest method testBuilderKModuleHasDependency.

@Test
public void testBuilderKModuleHasDependency() throws Exception {
    URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Test(org.junit.Test)

Example 27 with BuildResults

use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.

the class BuilderTest method testBuilderKModuleHasDependencyMetaData.

@Test
public void testBuilderKModuleHasDependencyMetaData() throws Exception {
    URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
    final KieModuleMetaData metaData = KieModuleMetaData.Factory.newKieModuleMetaData(builder.getKieModule());
    // Check packages
    final Set<String> packageNames = new HashSet<>();
    final Iterator<String> packageNameIterator = metaData.getPackages().iterator();
    while (packageNameIterator.hasNext()) {
        packageNames.add(packageNameIterator.next());
    }
    assertEquals(2, packageNames.size());
    assertTrue(packageNames.contains("defaultpkg"));
    assertTrue(packageNames.contains("org.kie.workbench.common.services.builder.tests.test1"));
    // Check classes
    final String packageName = "org.kie.workbench.common.services.builder.tests.test1";
    assertEquals(1, metaData.getClasses(packageName).size());
    final String className = metaData.getClasses(packageName).iterator().next();
    assertEquals("Bean", className);
    // Check metadata
    final Class clazz = metaData.getClass(packageName, className);
    final TypeMetaInfo typeMetaInfo = metaData.getTypeMetaInfo(clazz);
    assertNotNull(typeMetaInfo);
    assertFalse(typeMetaInfo.isEvent());
}
Also used : BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) URL(java.net.URL) KieModuleMetaData(org.kie.scanner.KieModuleMetaData) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) TypeMetaInfo(org.drools.core.rule.TypeMetaInfo) Module(org.guvnor.common.services.project.model.Module) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 28 with BuildResults

use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.

the class BuilderTest method testKModuleContainsXLS.

@Test
public void testKModuleContainsXLS() throws Exception {
    URL url = this.getClass().getResource("/ExampleWithExcel");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Test(org.junit.Test)

Example 29 with BuildResults

use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.

the class ResourceChangeIncrementalBuilderTest method testResourceAdded.

@Test
public void testResourceAdded() throws Exception {
    final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/add.drl");
    final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
    final Path resourcePath = paths.convert(nioResourcePath);
    // Force full build before attempting incremental changes
    final KieModule module = moduleService.resolveModule(resourcePath);
    final BuildResults buildResults = buildService.build(module);
    assertNotNull(buildResults);
    assertEquals(0, buildResults.getErrorMessages().size());
    assertEquals(1, buildResults.getInformationMessages().size());
    // Perform incremental build
    buildChangeListener.addResource(resourcePath);
    waitForIncrementalBuildResults(buildResultsObserver);
    final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
    assertNotNull(incrementalBuildResults);
    assertEquals(0, incrementalBuildResults.getAddedMessages().size());
    assertEquals(0, incrementalBuildResults.getRemovedMessages().size());
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) URL(java.net.URL) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 30 with BuildResults

use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.

the class ResourceChangeIncrementalBuilderTest method testResourceUpdated.

@Test
public void testResourceUpdated() throws Exception {
    final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/update.drl");
    final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
    final Path resourcePath = paths.convert(nioResourcePath);
    // Force full build before attempting incremental changes
    final KieModule module = moduleService.resolveModule(resourcePath);
    final BuildResults buildResults = buildService.build(module);
    assertNotNull(buildResults);
    assertEquals(0, buildResults.getErrorMessages().size());
    assertEquals(1, buildResults.getInformationMessages().size());
    // Perform incremental build
    buildChangeListener.updateResource(resourcePath);
    waitForIncrementalBuildResults(buildResultsObserver);
    final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
    assertNotNull(incrementalBuildResults);
    assertEquals(0, incrementalBuildResults.getAddedMessages().size());
    assertEquals(0, incrementalBuildResults.getRemovedMessages().size());
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) URL(java.net.URL) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Aggregations

BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)36 Test (org.junit.Test)29 IncrementalBuildResults (org.guvnor.common.services.project.builder.model.IncrementalBuildResults)25 URL (java.net.URL)19 Path (org.uberfire.backend.vfs.Path)15 KieModule (org.kie.workbench.common.services.shared.project.KieModule)13 BuildMessage (org.guvnor.common.services.project.builder.model.BuildMessage)8 CreationalContext (javax.enterprise.context.spi.CreationalContext)6 Bean (javax.enterprise.inject.spi.Bean)6 Module (org.guvnor.common.services.project.model.Module)4 SimpleFileSystemProvider (org.uberfire.java.nio.fs.file.SimpleFileSystemProvider)4 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 ExecutorService (java.util.concurrent.ExecutorService)2 ContextNotActiveException (javax.enterprise.context.ContextNotActiveException)2 DeploymentMode (org.guvnor.common.services.project.service.DeploymentMode)2 KieModuleMetaData (org.kie.scanner.KieModuleMetaData)2 ResourceAdded (org.uberfire.workbench.events.ResourceAdded)2 ResourceChange (org.uberfire.workbench.events.ResourceChange)2