public BuildResults buildAndDeploy(final Module module, final boolean suppressHandlers) { return buildAndDeploy(module, suppressHandlers, DeploymentMode.VALIDATED); }
public BuildResults buildAndDeploy(final Module module, final boolean suppressHandlers, final DeploymentMode mode) { deploymentVerifier.verifyWithException(module, mode); return doBuildAndDeploy(module, suppressHandlers); }
buildResult = buildHelper.build(localBuildConfigInternal.getModule()); result = Optional.of(new LocalBuildBinaryImpl(buildResult.getBuilder(), buildResult.getBuildResults())); break; case INCREMENTAL_ADD_RESOURCE: result = Optional.of(new LocalBuildBinaryImpl( buildHelper.addPackageResource(localBuildConfigInternal.getResource()))); break; case INCREMENTAL_UPDATE_RESOURCE: result = Optional.of(new LocalBuildBinaryImpl( buildHelper.updatePackageResource(localBuildConfigInternal.getResource()))); break; case INCREMENTAL_DELETE_RESOURCE: result = Optional.of(new LocalBuildBinaryImpl( buildHelper.deletePackageResource(localBuildConfigInternal.getResource()))); break; case INCREMENTAL_BATCH_CHANGES: result = Optional.of( new LocalBuildBinaryImpl(buildHelper.applyBatchResourceChanges( localBuildConfigInternal.getModule(), localBuildConfigInternal.getResourceChanges()))); result = Optional.of( new LocalBuildBinaryImpl( buildHelper.buildAndDeploy(localBuildConfigInternal.getModule(), localBuildConfigInternal.isSuppressHandlers(), toDeploymentMode(localBuildConfigInternal.getDeploymentType()))));
try { final BuildResults results = build(module).getBuildResults(); StringBuffer message = new StringBuffer(); message.append("Build of module '" + module.getModuleName() + "' (requested by " + getIdentifier() + ") completed.\n"); message.append(" Build: " + (results.getErrorMessages().isEmpty() ? "SUCCESSFUL" : "FAILURE")); return buildExceptionResults(e, module.getPom().getGav());
@Test public void testUpdatePackageResourceThatDoesNotUpdateTheCache() throws Exception { final Path path = path(); buildHelper.build(moduleService.resolveModule(path)); buildHelper.updatePackageResource(path); assertTrue(cachedFileSystemDoesNotChange()); }
@Test public void testApplyForModuleFullBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.FULL_BUILD); when(internalBuildConfig.getModule()).thenReturn(module); when(buildHelper.build(module)).thenReturn(buildResult); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(builder, result.get().getBuilder()); assertEquals(buildResults, result.get().getBuildResults()); verify(buildHelper, times(1)).build(module); }
@Test public void testApplyForIncrementalResourceDeleteBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_DELETE_RESOURCE); when(internalBuildConfig.getResource()).thenReturn(path); when(buildHelper.deletePackageResource(path)).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).deletePackageResource(path); }
@Test public void testApplyForIncrementalResourceUpdateBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_UPDATE_RESOURCE); when(internalBuildConfig.getResource()).thenReturn(path); when(buildHelper.updatePackageResource(path)).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).updatePackageResource(path); }
@Test public void testApplyForIncrementalResourceAddBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_ADD_RESOURCE); when(internalBuildConfig.getResource()).thenReturn(path); when(buildHelper.addPackageResource(path)).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).addPackageResource(path); }
@Test public void testApplyForIncrementalBatchChangesBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES); when(internalBuildConfig.getModule()).thenReturn(module); when(buildHelper.applyBatchResourceChanges(eq(module), anyMap())).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).applyBatchResourceChanges(eq(module), anyMap()); }
public BuildResult build(final Module module) { try { cache.invalidateCache(module); Builder builder = cache.assertBuilder(module); final BuildResults results = builder.build(); BuildMessage infoMsg = new BuildMessage(); infoMsg.setLevel(Level.INFO); infoMsg.setText(buildResultMessage(module, results).toString()); results.addBuildMessage(0, infoMsg); return new BuildResult(builder, results); } catch (Exception e) { logger.error(e.getMessage(), e); return new BuildResult(null, buildExceptionResults(e, module.getPom().getGav())); } }
@Before public void setUp() throws Exception { testFileSystem = new TestFileSystem(); moduleService = testFileSystem.getReference(KieModuleService.class); pomService = testFileSystem.getReference(POMService.class); cache = testFileSystem.getReference(LRUBuilderCache.class); deploymentVerifier = new DeploymentVerifier(repositoryResolver, moduleRepositoriesService); buildHelper = spy(new BuildHelper(pomService, m2RepoService, moduleService, deploymentVerifier, cache, handlers, identity)); when(identity.get()).thenReturn(user); when(user.getIdentifier()).thenReturn("test-user"); URL rootUrl = this.getClass().getResource("/BuildHelperTest"); rootPath = Paths.convert(testFileSystem.fileSystemProvider.getPath(rootUrl.toURI())); rootUrl = this.getClass().getResource("/BuildHelperTestSnapshot"); snapshotRootPath = Paths.convert(testFileSystem.fileSystemProvider.getPath(rootUrl.toURI())); Iterator<PostBuildHandler> mockIterator = mock(Iterator.class); when(handlers.iterator()).thenReturn(mockIterator); when(mockIterator.hasNext()).thenReturn(false); }
@Test public void testBuildThatDoesNotUpdateTheCache() throws Exception { final Path path = path(); buildHelper.build(moduleService.resolveModule(path)); assertTrue(cachedFileSystemDoesNotChange()); }
@Test public void testIncrementalBuildResourceDeleteExecution() { Path resourcePath = Paths.convert(getNioPath(RESOURCE_URI_1)); when(moduleService.resolveModule(resourcePath)).thenReturn(module); when(buildHelper.deletePackageResource(resourcePath)).thenReturn(incrementalBuildResults); doTestIncrementalBuildResourceExecution(module, RESOURCE_URI_1, LocalBuildConfig.BuildType.INCREMENTAL_DELETE_RESOURCE); }
@Test public void testIncrementalBuildResourceUpdateExecution() { Path resourcePath = Paths.convert(getNioPath(RESOURCE_URI_1)); when(moduleService.resolveModule(resourcePath)).thenReturn(module); when(buildHelper.updatePackageResource(resourcePath)).thenReturn(incrementalBuildResults); doTestIncrementalBuildResourceExecution(module, RESOURCE_URI_1, LocalBuildConfig.BuildType.INCREMENTAL_UPDATE_RESOURCE); }
@Test public void testIncrementalBuildResourceAddExecution() { Path resourcePath = Paths.convert(getNioPath(RESOURCE_URI_1)); when(moduleService.resolveModule(resourcePath)).thenReturn(module); when(buildHelper.addPackageResource(resourcePath)).thenReturn(incrementalBuildResults); doTestIncrementalBuildResourceExecution(module, RESOURCE_URI_1, LocalBuildConfig.BuildType.INCREMENTAL_ADD_RESOURCE); }
@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(); }
public BuildResults buildAndDeploy(final Module module) { return buildAndDeploy(module, DeploymentMode.VALIDATED); }
@Test public void testFullBuildExecution() { when(buildHelper.build(module)).thenReturn(buildResult); // prepare the pipeline input. input = createFullBuildInput(ROOT_PATH_URI); // execute the pipeline and verify the result. pipelineInitializer.getExecutor().execute(input, pipe, (Consumer<LocalBinaryConfig>) localBinaryConfig -> { assertEquals(buildResults, localBinaryConfig.getBuildResults()); assertEquals(builder, localBinaryConfig.getBuilder()); }, pipelineEventListener); // verify that all stages were properly invoked. verifyLocalSourceConfigWasInvoked(); verifyLocalProjectConfigWasInvoked(); verifyLocalBuildConfigExecutorWasInvoked(module, LocalBuildConfig.BuildType.FULL_BUILD.name()); verifyLocalBuildExecConfigExecutorWasInvoked(module, LocalBuildConfig.BuildType.FULL_BUILD); verifyPipelineEvents(); }
public BuildResults buildAndDeploy(final Module module, final DeploymentMode mode) { deploymentVerifier.verifyWithException(module, mode); return doBuildAndDeploy(module, false); }