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()));
}
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));
}
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));
}
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));
}
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();
}
Aggregations