@Test public void testApplyForIncrementalBatchChangesBuild() { when(localModule.getModule()).thenReturn(project); when(buildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES.name()); Map<String, String> resourceChanges = new HashMap<>(); resourceChanges.put(LocalBuildConfig.RESOURCE_CHANGE + RESOURCE_URI_1, "ADD"); resourceChanges.put(LocalBuildConfig.RESOURCE_CHANGE + RESOURCE_URI_2, "ADD,UPDATE"); resourceChanges.put(LocalBuildConfig.RESOURCE_CHANGE + RESOURCE_URI_3, "ADD,UPDATE,DELETE"); when(buildConfig.getResourceChanges()).thenReturn(resourceChanges); Optional<BuildConfig> result = executor.apply(localModule, buildConfig); assertTrue(result.isPresent()); assertEquals(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES, ((LocalBuildConfigInternal) result.get()).getBuildType()); assertHasAllChanges(((LocalBuildConfigInternal) result.get()).getResourceChanges().get(resource1VFSPath), ResourceChangeType.ADD); assertHasAllChanges(((LocalBuildConfigInternal) result.get()).getResourceChanges().get(resource2VFSPath), ResourceChangeType.ADD, ResourceChangeType.UPDATE); assertHasAllChanges(((LocalBuildConfigInternal) result.get()).getResourceChanges().get(resource3VFSPath), ResourceChangeType.ADD, ResourceChangeType.UPDATE, ResourceChangeType.DELETE); }
@Override public int hashCode() { int result = module != null ? module.hashCode() : 0; result = 31 * result + (buildType != null ? buildType.hashCode() : 0); result = 31 * result + (resource != null ? resource.hashCode() : 0); result = 31 * result + (resourceChanges != null ? resourceChanges.hashCode() : 0); result = 31 * result + (deploymentType != null ? deploymentType.hashCode() : 0); result = 31 * result + (suppressHandlers ? 1 : 0); return result; } }
verifyLocalProjectConfigWasInvoked(); verifyLocalBuildConfigExecutorWasInvoked(module, LocalBuildConfig.BuildType.FULL_BUILD_AND_DEPLOY.name(), deploymentType.name(), Boolean.toString(suppressHandlers));
buildRequest.getModule().getRootPath().toURI()); put(LocalBuildConfig.BUILD_TYPE, buildRequest.getBuildType().name()); if (buildRequest.isSingleResource()) { put(LocalBuildConfig.RESOURCE,
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(); }
@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(); }
@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(); }
private void testApplyForModuleFullBuildAndDeploy(LocalBuildConfig.DeploymentType deploymentType, boolean suppressHandlers) { when(localModule.getModule()).thenReturn(project); when(buildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.FULL_BUILD_AND_DEPLOY.name()); when(buildConfig.getDeploymentType()).thenReturn(deploymentType.name()); when(buildConfig.getSuppressHandlers()).thenReturn(Boolean.toString(suppressHandlers)); Optional<BuildConfig> result = executor.apply(localModule, buildConfig); assertTrue(result.isPresent()); assertEquals(project, ((LocalBuildConfigInternal) result.get()).getModule()); assertEquals(LocalBuildConfig.BuildType.FULL_BUILD_AND_DEPLOY, ((LocalBuildConfigInternal) result.get()).getBuildType()); assertEquals(deploymentType, ((LocalBuildConfigInternal) result.get()).getDeploymentType()); assertEquals(suppressHandlers, ((LocalBuildConfigInternal) result.get()).isSuppressHandlers()); } }
@Test public void testIncrementalBuildResourceChanges() { Map<Path, Collection<ResourceChange>> resourceChanges = createResourceChanges(changes); when(buildRequest.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES); when(buildRequest.isSingleResource()).thenReturn(false); when(buildRequest.getResourceChanges()).thenReturn(resourceChanges); // the pipeline should be invoked with this input. input = createBatchChangesInput(ROOT_PATH_URI, LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES.name(), changes); preparePipeline(input); LocalBinaryConfig result = pipelineInvoker.invokeLocalBuildPipeLine(buildRequest); verifyPipelineInvocation(localBinaryConfig, result); }
private void verifyLocalBuildConfigExecutorWasInvoked(KieModule module, ResourceChangeRequest... changes) { verify(localBuildConfigExecutor, times(1)).apply(localModuleCaptor.capture(), localBuildConfigCaptor.capture()); assertEquals(module, localModuleCaptor.getValue().getModule()); assertEquals(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES.name(), localBuildConfigCaptor.getValue().getBuildType()); for (ResourceChangeRequest change : changes) { assertNotNull(localBuildConfigCaptor.getValue().getResourceChanges().get(LocalBuildConfig.RESOURCE_CHANGE + change.getUri())); assertEquals(change.getChanges(), localBuildConfigCaptor.getValue().getResourceChanges().get(LocalBuildConfig.RESOURCE_CHANGE + change.getUri())); } }
private void testIncrementalBuildResourceRequest(LocalBuildConfig.BuildType buildType, Path resource) { when(buildRequest.getBuildType()).thenReturn(buildType); when(buildRequest.getResource()).thenReturn(resource); when(buildRequest.isSingleResource()).thenReturn(true); // the pipeline should be invoked with this input. input = createIncrementalBuildInput(ROOT_PATH_URI, RESOURCE_URI_1, buildType.name()); preparePipeline(input); LocalBinaryConfig result = pipelineInvoker.invokeLocalBuildPipeLine(buildRequest); verifyPipelineInvocation(localBinaryConfig, result); }
private LocalBuildConfig.BuildType decodeBuildType(String value) { return LocalBuildConfig.BuildType.valueOf(value); }
private void testApplyForIncrementalResourceBuild(LocalBuildConfig.BuildType buildType, String resourceURI) { when(localModule.getModule()).thenReturn(project); when(buildConfig.getBuildType()).thenReturn(buildType.name()); when(buildConfig.getResource()).thenReturn(resourceURI); Optional<BuildConfig> result = executor.apply(localModule, buildConfig); assertTrue(result.isPresent()); assertEquals(buildType, ((LocalBuildConfigInternal) result.get()).getBuildType()); assertEquals(project, ((LocalBuildConfigInternal) result.get()).getModule()); assertEquals(RESOURCE_URI_1, ((LocalBuildConfigInternal) result.get()).getResource().toURI()); }
/** * @return the Pipeline input for a project full build. */ public static Input createFullBuildInput( String rootPathUri ) { Input input = new Input(); input.put( LocalSourceConfig.ROOT_PATH, rootPathUri ); input.put( LocalBuildConfig.BUILD_TYPE, LocalBuildConfig.BuildType.FULL_BUILD.name( ) ); return input; }
@Test public void testApplyForModuleFullBuild() { when(localModule.getModule()).thenReturn(project); when(buildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.FULL_BUILD.name()); Optional<BuildConfig> result = executor.apply(localModule, buildConfig); assertTrue(result.isPresent()); assertEquals(LocalBuildConfig.BuildType.FULL_BUILD, ((LocalBuildConfigInternal) result.get()).getBuildType()); assertEquals(project, ((LocalBuildConfigInternal) result.get()).getModule()); }
/** * @return the Pipeline input for a full build and deploy. */ public static Input createFullBuildAndDeployInput( String rootPathUri, String deploymentType, boolean suppressHandlers ) { Input input = new Input( ); input.put( LocalSourceConfig.ROOT_PATH, rootPathUri ); input.put( LocalBuildConfig.BUILD_TYPE, LocalBuildConfig.BuildType.FULL_BUILD_AND_DEPLOY.name( ) ); input.put( LocalBuildConfig.DEPLOYMENT_TYPE, deploymentType ); input.put( LocalBuildConfig.SUPPRESS_HANDLERS, Boolean.toString( suppressHandlers ) ); return input; }