Search in sources :

Example 36 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class CruiseConfigTestBase method canFindMaterialConfigForUnderGivenPipelineWithMaterialFingerprint.

@Test
public void canFindMaterialConfigForUnderGivenPipelineWithMaterialFingerprint() {
    MaterialConfig fullClone = new GitMaterialConfig("url", "master", false);
    PipelineConfig one = PipelineConfigMother.pipelineConfig("one", fullClone, new JobConfigs(new JobConfig("job")));
    cruiseConfig.addPipeline("group-1", one);
    MaterialConfig shallowClone = new GitMaterialConfig("url", "master", true);
    PipelineConfig two = PipelineConfigMother.pipelineConfig("two", shallowClone, new JobConfigs(new JobConfig("job")));
    cruiseConfig.addPipeline("group-2", two);
    MaterialConfig others = new GitMaterialConfig("bar", "master", true);
    PipelineConfig three = PipelineConfigMother.pipelineConfig("three", others, new JobConfigs(new JobConfig("job")));
    cruiseConfig.addPipeline("group-3", three);
    String fingerprint = new GitMaterialConfig("url", "master").getFingerprint();
    assertThat(((GitMaterialConfig) cruiseConfig.materialConfigFor(one.name(), fingerprint)).isShallowClone(), is(false));
    assertThat(((GitMaterialConfig) cruiseConfig.materialConfigFor(two.name(), fingerprint)).isShallowClone(), is(true));
    assertThat(cruiseConfig.materialConfigFor(three.name(), fingerprint), is(nullValue()));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 37 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method hasSameMaterial_shouldReturnTrueWhenFingerprintEquals_AndDestinationDirectoriesAreDifferent.

@Test
public void hasSameMaterial_shouldReturnTrueWhenFingerprintEquals_AndDestinationDirectoriesAreDifferent() {
    MaterialConfig configRepo = new GitMaterialConfig("url", "branch");
    GitMaterialConfig someRepo = new GitMaterialConfig("url", "branch");
    someRepo.setFolder("someFolder");
    ConfigRepoConfig config = new ConfigRepoConfig(configRepo, "myplugin");
    assertThat(config.hasSameMaterial(someRepo), is(true));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.Test)

Example 38 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method hasMaterialWithFingerprint_shouldReturnFalseWhenFingerprintNotEquals.

@Test
public void hasMaterialWithFingerprint_shouldReturnFalseWhenFingerprintNotEquals() {
    MaterialConfig configRepo = new GitMaterialConfig("url", "branch");
    GitMaterialConfig someRepo = new GitMaterialConfig("url", "branch1");
    ConfigRepoConfig config = new ConfigRepoConfig(configRepo, "myplugin");
    assertThat(config.hasMaterialWithFingerprint(someRepo.getFingerprint()), is(false));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.Test)

Example 39 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlLoaderTest method shouldDeserializeGroupXml.

@Test
public void shouldDeserializeGroupXml() throws Exception {
    String partialXml = "<pipelines group=\"group_name\">\n" + "  <pipeline name=\"new_name\">\n" + "    <materials>\n" + "      <svn url=\"file:///tmp/foo\" />\n" + "    </materials>\n" + "    <stage name=\"stage_name\">\n" + "      <jobs>\n" + "        <job name=\"job_name\" />\n" + "      </jobs>\n" + "    </stage>\n" + "  </pipeline>\n" + "</pipelines>";
    PipelineConfigs pipelineConfigs = xmlLoader.fromXmlPartial(partialXml, BasicPipelineConfigs.class);
    PipelineConfig pipeline = pipelineConfigs.findBy(new CaseInsensitiveString("new_name"));
    assertThat(pipeline, is(notNullValue()));
    assertThat(pipeline.materialConfigs().size(), is(1));
    MaterialConfig material = pipeline.materialConfigs().get(0);
    assertThat(material, is(Matchers.instanceOf(SvnMaterialConfig.class)));
    assertThat(material.getUriForDisplay(), is("file:///tmp/foo"));
    assertThat(pipeline.size(), is(1));
    assertThat(pipeline.get(0).getJobs().size(), is(1));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Test(org.junit.Test)

Example 40 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class AbstractMaterialConfigTest method shouldNotUseNameFieldButInsteadUseTheNameMethodToCheckIfTheMaterialNameIsUsedInThePipelineLabel.

@Test
public 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), is(true));
    assertThat(dependency.isUsedInLabelTemplate(pipelineConfig), is(true));
    assertThat(aPackage.isUsedInLabelTemplate(pipelineConfig), is(true));
    assertThat(aPluggableSCM.isUsedInLabelTemplate(pipelineConfig), is(true));
    verify(hg).getName();
    verify(dependency).getName();
    verify(aPackage).getName();
    verify(aPluggableSCM).getName();
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) Test(org.junit.Test)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)133 Test (org.junit.Test)81 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)72 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)61 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)46 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)42 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)33 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)32 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)32 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)29 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)29 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)13 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)13 Filter (com.thoughtworks.go.config.materials.Filter)11 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)10 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)10 Material (com.thoughtworks.go.domain.materials.Material)9