private void preparePipeline(Input input) { doAnswer(new Answer<Void>() { public Void answer(InvocationOnMock invocation) { Consumer consumer = (Consumer) invocation.getArguments()[2]; consumer.accept(localBinaryConfig); return null; } }).when(pipelineExecutor).execute(eq(input), eq(pipeline), any(Consumer.class)); }
private void verifyPipelineInvocation(LocalBinaryConfig expectedResult, LocalBinaryConfig result) { assertEquals(expectedResult, result); verify(pipelineExecutor, times(1)).execute(eq(input), eq(pipeline), any(Consumer.class)); } }
public void execute(final PipelineExecutor executor, final Pipeline pipeline, final Input input) { this.executorService.execute(new ProvisionRunnable(() -> { startedEvent.fire(new CaseProvisioningStartedEvent()); executor.execute(input, pipeline, (WildflyRuntime b) -> { final String context = "/" + FilenameUtils.getBaseName(b.getId()); completedEvent.fire(new CaseProvisioningCompletedEvent(context)); LOGGER.info("jBPM Case Management Showcase app provisioning completed."); }); })); }
public void execute(final PipelineExecutor executor, final Pipeline pipeline, final Input input) { this.executorService.execute(new ProvisionRunnable(() -> { startedEvent.fire(new CaseProvisioningStartedEvent()); executor.execute(input, pipeline, (WildflyRuntime b) -> { final String context = "/" + FilenameUtils.getBaseName(b.getId()); completedEvent.fire(new CaseProvisioningCompletedEvent(context)); LOGGER.info("jBPM Case Management Showcase app provisioning completed."); }); })); }
@Test public void testExecuteSync() { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS); assertEquals(TASK_ID, result); //verify the task to execute was properly initialized. verify(taskManagerHelper, times(1)).createTask(taskDef); //verify the pipeline was properly executed. verify(pipelineExecutor, times(1)).execute(eq(taskDef.getInput()), eq(pipeline), any(Consumer.class), eq(taskManager.localListener)); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertEquals(PIPELINE_ID, pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); }
@Test public void testExecuteSync() { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS); assertEquals(TASK_ID, result); //verify the task to execute was properly initialized. verify(taskManagerHelper, times(1)).createTask(taskDef); //verify the pipeline was properly executed. verify(pipelineExecutor, times(1)).execute(eq(taskDef.getInput()), eq(pipeline), any(Consumer.class), eq(taskManager.localListener)); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertEquals(PIPELINE_ID, pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); }
/** * Executes a task in asynchronous mode. * @param task the task for execute. * @return the taskId of the task. */ private synchronized void startAsyncTask(final PipelineExecutorTask task) { final Future<?> future = executor.submit(() -> { final Pipeline pipeline = pipelineRegistry.getPipelineByName(task.getTaskDef().getPipeline()); try { pipelineExecutor.execute(task.getTaskDef().getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); } catch (Exception e) { logger.error("An error was produced during pipeline execution for PipelineExecutorTask: " + task.getId(), e); } finally { removeTaskEntry(task.getId()); removeFutureTask(task.getId()); } }); storeFutureTask(task.getId(), future); }
/** * Executes a task in asynchronous mode. * @param task the task for execute. * @return the taskId of the task. */ private synchronized void startAsyncTask(final PipelineExecutorTask task) { final Future<?> future = executor.submit(() -> { final Pipeline pipeline = pipelineRegistry.getPipelineByName(task.getTaskDef().getPipeline()); try { pipelineExecutor.execute(task.getTaskDef().getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); } catch (Exception e) { logger.error("An error was produced during pipeline execution for PipelineExecutorTask: " + task.getId(), e); } finally { removeTaskEntry(task.getId()); removeFutureTask(task.getId()); } }); storeFutureTask(task.getId(), future); }
/** * Executes a task definition in synchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the executed task. */ private String executeSync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newSyncEntry(task)); final Pipeline pipeline = pipelineRegistry.getPipelineByName(taskDef.getPipeline()); pipelineExecutor.execute(taskDef.getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); removeTaskEntry(task.getId()); updateExecutorRegistry(task); return task.getId(); }
/** * Executes a task definition in synchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the executed task. */ private String executeSync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newSyncEntry(task)); final Pipeline pipeline = pipelineRegistry.getPipelineByName(taskDef.getPipeline()); pipelineExecutor.execute(taskDef.getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); removeTaskEntry(task.getId()); updateExecutorRegistry(task); return task.getId(); }
@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(); }
executor.execute(input, pipe, consumer);
executor.execute(new Input() {
pipelineInitializer.getExecutor().execute(input, pipe, (Consumer<LocalBinaryConfig>) localBinaryConfig -> {
@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(); }
executor.execute(new Input() {
new DockerProvisioningConfigExecutor(), dockerRuntimeExecExecutor)); executor.execute(new Input() {
new DockerProvisioningConfigExecutor(), dockerRuntimeExecExecutor)); executor.execute(new Input() {
private void doTestIncrementalBuildResourceExecution(KieModule module, String resourceUri, LocalBuildConfig.BuildType buildType) { // prepare the pipeline input. Input input = createIncrementalBuildInput(ROOT_PATH_URI, resourceUri, buildType.name()); // 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, resourceUri, buildType.name()); verifyLocalBuildExecConfigExecutorWasInvoked(module, Paths.convert(getNioPath(resourceUri)), buildType); // verify the pipeline events where properly raised. verifyPipelineEvents(); }