Search in sources :

Example 21 with IncrementalBuildResults

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

the class BuildPipelineTest method testIncrementalBuildResourceChangesExecution.

@Test
public void testIncrementalBuildResourceChangesExecution() {
    when(buildHelper.applyBatchResourceChanges(eq(module), any(Map.class))).thenReturn(incrementalBuildResults);
    // prepare the pipeline input.
    Input input = createBatchChangesInput(ROOT_PATH_URI, LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES.name(), changes);
    // execute the pipeline and verify the result.
    pipelineInitializer.getExecutor().execute(input, pipe, (Consumer<LocalBinaryConfig>) localBinaryConfig -> {
        assertEquals(incrementalBuildResults, localBinaryConfig.getIncrementalBuildResults());
    }, pipelineEventListener);
    // verify that all stages were properly invoked.
    verifyLocalSourceConfigWasInvoked();
    verifyLocalProjectConfigWasInvoked();
    verifyLocalBuildConfigExecutorWasInvoked(module, changes);
    verifyLocalBuildExecConfigExecutorWasInvoked(module, changes);
    // verify the pipeline events where properly raised.
    verifyPipelineEvents();
}
Also used : Builder(org.kie.workbench.common.services.backend.builder.core.Builder) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) Stage(org.guvnor.ala.pipeline.Stage) Mock(org.mockito.Mock) ConfigExecutor(org.guvnor.ala.pipeline.ConfigExecutor) RunWith(org.junit.runner.RunWith) InMemoryPipelineRegistry(org.guvnor.ala.registry.inmemory.InMemoryPipelineRegistry) ArrayList(java.util.ArrayList) BeforePipelineExecutionEvent(org.guvnor.ala.pipeline.events.BeforePipelineExecutionEvent) Paths(org.uberfire.backend.server.util.Paths) Pipeline(org.guvnor.ala.pipeline.Pipeline) ArgumentCaptor(org.mockito.ArgumentCaptor) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) AfterPipelineExecutionEvent(org.guvnor.ala.pipeline.events.AfterPipelineExecutionEvent) ResourceChange(org.uberfire.workbench.events.ResourceChange) Source(org.guvnor.ala.source.Source) AfterStageExecutionEvent(org.guvnor.ala.pipeline.events.AfterStageExecutionEvent) Path(org.uberfire.backend.vfs.Path) Before(org.junit.Before) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) PipelineRegistry(org.guvnor.ala.registry.PipelineRegistry) Input(org.guvnor.ala.pipeline.Input) Collection(java.util.Collection) Test(org.junit.Test) BuildHelper(org.kie.workbench.common.services.backend.builder.core.BuildHelper) KieModule(org.kie.workbench.common.services.shared.project.KieModule) PipelineEventListener(org.guvnor.ala.pipeline.events.PipelineEventListener) Consumer(java.util.function.Consumer) BeforeStageExecutionEvent(org.guvnor.ala.pipeline.events.BeforeStageExecutionEvent) Mockito(org.mockito.Mockito) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Assert(org.junit.Assert) Input(org.guvnor.ala.pipeline.Input) Map(java.util.Map) Test(org.junit.Test)

Example 22 with IncrementalBuildResults

use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults 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 23 with IncrementalBuildResults

use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults 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)

Example 24 with IncrementalBuildResults

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

the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testNonPackageResourceUpdated.

@Test
public void testNonPackageResourceUpdated() throws Exception {
    // This tests changes to a resource that is neither pom.xml nor kmodule.xml nor within a Package
    final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
    final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
    final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
    final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/project.imports");
    final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
    final Path resourcePath = paths.convert(nioResourcePath);
    // Perform incremental build (Without a full Build first)
    buildChangeListener.updateResource(resourcePath);
    final BuildResults buildResults = buildResultsObserver.getBuildResults();
    assertNull(buildResults);
    final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
    assertNull(incrementalBuildResults);
}
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) Bean(javax.enterprise.inject.spi.Bean) CreationalContext(javax.enterprise.context.spi.CreationalContext) Test(org.junit.Test)

Example 25 with IncrementalBuildResults

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

the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testResourceUpdated.

@Test
public void testResourceUpdated() throws Exception {
    final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
    final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
    final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
    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);
    // Perform incremental build (Without a full Build first)
    buildChangeListener.updateResource(resourcePath);
    waitForBuildResults(buildResultsObserver);
    final BuildResults buildResults = buildResultsObserver.getBuildResults();
    assertNotNull(buildResults);
    assertEquals(0, buildResults.getErrorMessages().size());
    assertEquals(1, buildResults.getInformationMessages().size());
    final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
    assertNull(incrementalBuildResults);
}
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) Bean(javax.enterprise.inject.spi.Bean) CreationalContext(javax.enterprise.context.spi.CreationalContext) Test(org.junit.Test)

Aggregations

IncrementalBuildResults (org.guvnor.common.services.project.builder.model.IncrementalBuildResults)27 Test (org.junit.Test)19 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)14 Path (org.uberfire.backend.vfs.Path)14 URL (java.net.URL)12 KieModule (org.kie.workbench.common.services.shared.project.KieModule)11 CreationalContext (javax.enterprise.context.spi.CreationalContext)6 Bean (javax.enterprise.inject.spi.Bean)6 Collection (java.util.Collection)5 ResourceChange (org.uberfire.workbench.events.ResourceChange)5 Consumer (java.util.function.Consumer)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ContextNotActiveException (javax.enterprise.context.ContextNotActiveException)3 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)3 Builder (org.kie.workbench.common.services.backend.builder.core.Builder)3 List (java.util.List)2 ConfigExecutor (org.guvnor.ala.pipeline.ConfigExecutor)2 Input (org.guvnor.ala.pipeline.Input)2