Search in sources :

Example 11 with MaterialConfigConverter

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()));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Material(com.thoughtworks.go.domain.materials.Material) EntityConfigChangedListener(com.thoughtworks.go.listener.EntityConfigChangedListener) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.jupiter.api.Test)

Example 12 with MaterialConfigConverter

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);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 13 with MaterialConfigConverter

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;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter)

Aggregations

MaterialConfigConverter (com.thoughtworks.go.server.service.MaterialConfigConverter)13 Material (com.thoughtworks.go.domain.materials.Material)7 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)4 EntityConfigChangedListener (com.thoughtworks.go.listener.EntityConfigChangedListener)4 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 Test (org.junit.jupiter.api.Test)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)1 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)1 SCM (com.thoughtworks.go.domain.scm.SCM)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 Database (com.thoughtworks.go.server.database.Database)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 MaterialExpansionService (com.thoughtworks.go.server.service.MaterialExpansionService)1