Search in sources :

Example 16 with BuildResults

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

the class BuildServiceImplTest method testBuild.

@Test
public void testBuild() {
    when(buildServiceHelper.localBuild(module)).thenReturn(buildResults);
    BuildResults result = buildService.build(module);
    assertEquals(buildResults, result);
}
Also used : BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) Test(org.junit.Test)

Example 17 with BuildResults

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

the class ModuleDataModelConcurrencyTest method testConcurrentResourceUpdates.

@Test
public void testConcurrentResourceUpdates() throws URISyntaxException {
    final URL pomUrl = this.getClass().getResource("/DataModelBackendTest1/pom.xml");
    final org.uberfire.java.nio.file.Path nioPomPath = ioService.get(pomUrl.toURI());
    final Path pomPath = paths.convert(nioPomPath);
    final URL resourceUrl = this.getClass().getResource("/DataModelBackendTest1/src/main/resources/empty.rdrl");
    final org.uberfire.java.nio.file.Path nioResourcePath = ioService.get(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
    final int THREADS = 200;
    final Result result = new Result();
    ExecutorService es = Executors.newCachedThreadPool();
    for (int i = 0; i < THREADS; i++) {
        final int operation = (i % 3);
        switch(operation) {
            case 0:
                es.execute(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            logger.debug("[Thread: " + Thread.currentThread().getName() + "] Request to update POM received");
                            invalidateCaches(module, pomPath);
                            buildChangeListener.updateResource(pomPath);
                            logger.debug("[Thread: " + Thread.currentThread().getName() + "] POM update completed");
                        } catch (Throwable e) {
                            result.setFailed(true);
                            result.setMessage(e.getMessage());
                            ExceptionUtils.printRootCauseStackTrace(e);
                        }
                    }
                });
                break;
            case 1:
                es.execute(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            logger.debug("[Thread: " + Thread.currentThread().getName() + "] Request to update Resource received");
                            invalidateCaches(module, resourcePath);
                            buildChangeListener.addResource(resourcePath);
                            logger.debug("[Thread: " + Thread.currentThread().getName() + "] Resource update completed");
                        } catch (Throwable e) {
                            result.setFailed(true);
                            result.setMessage(e.getMessage());
                            ExceptionUtils.printRootCauseStackTrace(e);
                        }
                    }
                });
                break;
            case 2:
                es.execute(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            logger.debug("[Thread: " + Thread.currentThread().getName() + "] Request for DataModel received");
                            dataModelService.getDataModel(resourcePath);
                            logger.debug("[Thread: " + Thread.currentThread().getName() + "] DataModel request completed");
                        } catch (Throwable e) {
                            result.setFailed(true);
                            result.setMessage(e.getMessage());
                            ExceptionUtils.printRootCauseStackTrace(e);
                        }
                    }
                });
        }
    }
    es.shutdown();
    try {
        es.awaitTermination(5, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
    }
    if (result.isFailed()) {
        fail(result.getMessage());
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) URL(java.net.URL) ExecutorService(java.util.concurrent.ExecutorService) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 18 with BuildResults

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

the class BuilderKieScannerWarningIntegrationTest method testBuilderKieScannerWarning.

@Test
public // https://bugzilla.redhat.com/show_bug.cgi?id=1161577
void testBuilderKieScannerWarning() throws URISyntaxException {
    final URL resourceUrl = this.getClass().getResource("/BuilderKieScannerRepo/src/main/resources/update.drl");
    final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
    final Path resourcePath = paths.convert(nioResourcePath);
    // Build and look for warnings..
    final KieModule module = moduleService.resolveModule(resourcePath);
    final BuildResults buildResults = buildService.build(module);
    assertNotNull(buildResults);
    assertEquals(0, buildResults.getErrorMessages().size());
    assertEquals(1, buildResults.getInformationMessages().size());
}
Also used : Path(org.uberfire.backend.vfs.Path) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) URL(java.net.URL) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 19 with BuildResults

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

the class BuildExecutorTest method testBuildAndDeployCommandFail.

@Test
public void testBuildAndDeployCommandFail() {
    BuildMessage message = mock(BuildMessage.class);
    List<BuildMessage> messages = new ArrayList<>();
    messages.add(message);
    BuildResults results = mock(BuildResults.class);
    when(results.getErrorMessages()).thenReturn(messages);
    when(buildServiceMock.buildAndDeploy(any(KieModule.class), any(DeploymentMode.class))).thenReturn(results);
    buildExecutor.triggerBuildAndDeploy();
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
    verifyBusyShowHideAnyString(1, 1, ProjectEditorResources.CONSTANTS.Building());
}
Also used : BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) ArrayList(java.util.ArrayList) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 20 with BuildResults

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

the class BuildExecutorTest method testBuildCommandFail.

@Test
public void testBuildCommandFail() {
    BuildMessage message = mock(BuildMessage.class);
    List<BuildMessage> messages = new ArrayList<>();
    messages.add(message);
    BuildResults results = mock(BuildResults.class);
    when(results.getErrorMessages()).thenReturn(messages);
    when(buildServiceMock.build(any(KieModule.class))).thenReturn(results);
    buildExecutor.triggerBuild();
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
    verifyBusyShowHideAnyString(1, 1, ProjectEditorResources.CONSTANTS.Building());
}
Also used : BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) ArrayList(java.util.ArrayList) 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