Search in sources :

Example 26 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PackageMaterialSaveCommandTestBase method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    cruiseConfig = GoConfigMother.configWithPackageRepo("repo1");
    pipelineName = "test";
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName);
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    pipelineConfig.materialConfigs().add(0, new PackageMaterialConfig(null, "repo1-pkg-1", packageDefinition));
    pipelineGroup = "grp1";
    cruiseConfig.addPipeline(pipelineGroup, pipelineConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Before(org.junit.Before)

Example 27 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class AbstractMaterialConfigTest method shouldNotUseNameFieldButInsteadUseTheNameMethodToCheckIfTheMaterialNameIsUsedInThePipelineLabel.

@Test
void shouldNotUseNameFieldButInsteadUseTheNameMethodToCheckIfTheMaterialNameIsUsedInThePipelineLabel() throws Exception {
    PipelineConfig pipelineConfig = mock(PipelineConfig.class);
    when(pipelineConfig.getLabelTemplate()).thenReturn("${COUNT}-${hg}-${dep}-${pkg}-${scm}");
    MaterialConfig hg = mock(HgMaterialConfig.class);
    when(hg.getName()).thenReturn(new CaseInsensitiveString("hg"));
    when(hg.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
    MaterialConfig dependency = mock(DependencyMaterialConfig.class);
    when(dependency.getName()).thenReturn(new CaseInsensitiveString("dep"));
    when(dependency.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
    MaterialConfig aPackage = mock(PackageMaterialConfig.class);
    when(aPackage.getName()).thenReturn(new CaseInsensitiveString("pkg"));
    when(aPackage.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
    MaterialConfig aPluggableSCM = mock(PluggableSCMMaterialConfig.class);
    when(aPluggableSCM.getName()).thenReturn(new CaseInsensitiveString("scm"));
    when(aPluggableSCM.isUsedInLabelTemplate(pipelineConfig)).thenCallRealMethod();
    assertThat(hg.isUsedInLabelTemplate(pipelineConfig)).isTrue();
    assertThat(dependency.isUsedInLabelTemplate(pipelineConfig)).isTrue();
    assertThat(aPackage.isUsedInLabelTemplate(pipelineConfig)).isTrue();
    assertThat(aPluggableSCM.isUsedInLabelTemplate(pipelineConfig)).isTrue();
    verify(hg).getName();
    verify(dependency).getName();
    verify(aPackage).getName();
    verify(aPluggableSCM).getName();
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 28 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials.

@Test
public void shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials() throws SQLException {
    String p4view = "//depot/... //localhost/...";
    Materials p4Materials = MaterialsMother.p4Materials(p4view);
    P4Material p4Material = (P4Material) p4Materials.first();
    p4Material.setUseTickets(true);
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(p4Materials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materials = pipelineFromDB.getMaterials();
    assertThat(materials.get(0), is(p4Material));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) Test(org.junit.jupiter.api.Test)

Example 29 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveDependencyMaterials.

@Test
public void shouldStoreAndRetrieveDependencyMaterials() throws SQLException {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(dependencyMaterial.config()));
    MaterialRevisions materialRevisions = new MaterialRevisions();
    materialRevisions.addRevision(DependencyMaterialRevision.create("pipeline-name", -12, "1234", "stage-name", 1).convert(dependencyMaterial, new Date()));
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    final Materials materials = pipelineFromDB.getMaterials();
    assertThat(materials.get(0), is(dependencyMaterial));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 30 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldSupportSubmoduleFolderInGitMaterials.

@Test
public void shouldSupportSubmoduleFolderInGitMaterials() throws Exception {
    Materials materials = MaterialsMother.gitMaterials("gitUrl", "submoduleFolder", null);
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    save(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materialsFromDB = pipelineFromDB.getMaterials();
    GitMaterial gitMaterial = (GitMaterial) materialsFromDB.get(0);
    assertThat(gitMaterial.getSubmoduleFolder(), is("submoduleFolder"));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.jupiter.api.Test)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)285 Test (org.junit.jupiter.api.Test)185 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)142 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)52 TimeProvider (com.thoughtworks.go.util.TimeProvider)33 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)24 Test (org.junit.Test)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)19 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 Materials (com.thoughtworks.go.config.materials.Materials)14 Date (java.util.Date)14 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)13 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)13 StageConfig (com.thoughtworks.go.config.StageConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 Pipeline (com.thoughtworks.go.domain.Pipeline)12 Modification (com.thoughtworks.go.domain.materials.Modification)12