use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class SCMMaterialSourceTest method shouldRefreshMaterialCacheOnSCMChange.
@Test
public void shouldRefreshMaterialCacheOnSCMChange() {
GitMaterialConfig gitMaterial = new GitMaterialConfig();
gitMaterial.setUrl("http://github.com/gocd/gocd");
ArgumentCaptor<EntityConfigChangedListener> captor = ArgumentCaptor.forClass(EntityConfigChangedListener.class);
doNothing().when(goConfigService).register(captor.capture());
when(goConfigService.getSchedulableSCMMaterials()).thenReturn(emptySet()).thenReturn(singleton(gitMaterial));
source = new SCMMaterialSource(goConfigService, systemEnvironment, new MaterialConfigConverter(), materialUpdateService);
source.initialize();
EntityConfigChangedListener entityConfigChangedListener = captor.getAllValues().get(1);
assertTrue(entityConfigChangedListener.shouldCareAbout(new SCM()));
assertThat(source.materialsForUpdate().size(), is(0));
entityConfigChangedListener.onEntityConfigChange(new SCM());
Set<Material> materials = source.materialsForUpdate();
assertThat(materials.size(), is(1));
assertThat(materials.iterator().next().getFingerprint(), is(gitMaterial.getFingerprint()));
}
use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class DatabaseAccessHelper method rescheduleTestPipeline.
public Pipeline rescheduleTestPipeline(String pipelineName, String stageName, String userName) throws SQLException {
String[] jobConfigNames = new String[] {};
PipelineConfig pipelineConfig = configurePipeline(pipelineName, stageName, jobConfigNames);
BuildCause buildCause = BuildCause.createManualForced(modifyOneFile(new MaterialConfigConverter().toMaterials(pipelineConfig.materialConfigs()), ModificationsMother.currentRevision()), Username.ANONYMOUS);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, buildCause, new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
return savePipelineWithStagesAndMaterials(pipeline);
}
use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class DatabaseAccessHelper method newPipelineWithFirstStageFailed.
public Pipeline newPipelineWithFirstStageFailed(PipelineConfig config) throws SQLException {
Pipeline pipeline = instanceFactory.createPipelineInstance(config, BuildCause.createManualForced(modifyOneFile(new MaterialConfigConverter().toMaterials(config.materialConfigs()), ModificationsMother.currentRevision()), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
savePipelineWithStagesAndMaterials(pipeline);
failStage(pipeline.getFirstStage());
return pipeline;
}
Aggregations