Search in sources :

Example 1 with MaterialConfigConverter

use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.

the class ModificationsMother method modifyNoFiles.

public static BuildCause modifyNoFiles(PipelineConfig config) {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    for (Material material : new MaterialConfigConverter().toMaterials(config.materialConfigs())) {
        ArrayList<Modification> list = new ArrayList<>();
        list.add(new Modification("no-user", "comment", "dummy-email", new Date(), "Dummy Modification" + UUID.randomUUID().toString()));
        materialRevisions.addRevision(material, list);
    }
    return BuildCause.createWithModifications(materialRevisions, "");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter)

Example 2 with MaterialConfigConverter

use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.

the class SCMMaterialSourceTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    goConfigService = mock(GoConfigService.class);
    systemEnvironment = new SystemEnvironment();
    serverHealthService = mock(ServerHealthService.class);
    materialConfigConverter = mock(MaterialConfigConverter.class);
    materialUpdateService = mock(MaterialUpdateService.class);
    source = new SCMMaterialSource(goConfigService, systemEnvironment, materialConfigConverter, materialUpdateService);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with MaterialConfigConverter

use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.

the class SCMMaterialSourceTest method shouldRefreshMaterialCacheOnPackageRepositoryChange.

@Test
public void shouldRefreshMaterialCacheOnPackageRepositoryChange() {
    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 PackageRepository()));
    assertThat(source.materialsForUpdate().size(), is(0));
    entityConfigChangedListener.onEntityConfigChange(new PackageRepository());
    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) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Material(com.thoughtworks.go.domain.materials.Material) EntityConfigChangedListener(com.thoughtworks.go.listener.EntityConfigChangedListener) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) Test(org.junit.jupiter.api.Test)

Example 4 with MaterialConfigConverter

use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.

the class DatabaseAccessHelper method newPipelineWithFirstStagePassed.

public Pipeline newPipelineWithFirstStagePassed(PipelineConfig config) throws SQLException {
    Pipeline pipeline = instanceFactory.createPipelineInstance(config, BuildCause.createManualForced(modifyOneFile(new MaterialConfigConverter().toMaterials(config.materialConfigs()), ModificationsMother.nextRevision()), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
    saveMaterialsWIthPassedStages(pipeline);
    return pipeline;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter)

Example 5 with MaterialConfigConverter

use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.

the class DatabaseAccessHelper method newPipelineWithFirstStageScheduled.

public Pipeline newPipelineWithFirstStageScheduled(PipelineConfig config) throws SQLException {
    Pipeline pipeline = instanceFactory.createPipelineInstance(config, BuildCause.createManualForced(modifyOneFile(new MaterialConfigConverter().toMaterials(config.materialConfigs()), ModificationsMother.nextRevision()), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
    savePipelineWithStagesAndMaterials(pipeline);
    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