use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldClearExistingAndSetHgConfigAttributesForMaterial.
@Test
public void shouldClearExistingAndSetHgConfigAttributesForMaterial() {
MaterialConfigs materialConfigs = new MaterialConfigs();
materialConfigs.add(new HgMaterialConfig("", null));
materialConfigs.add(new SvnMaterialConfig("", "", "", false));
Map<String, String> hashMap = new HashMap<>();
hashMap.put(HgMaterialConfig.URL, "foo");
Map<String, Object> attributeMap = new HashMap<>();
attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, HgMaterialConfig.TYPE);
attributeMap.put(HgMaterialConfig.TYPE, hashMap);
materialConfigs.setConfigAttributes(attributeMap);
assertThat(materialConfigs.size(), is(1));
assertThat(materialConfigs.first(), is(new HgMaterialConfig("foo", null)));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldFailIfMultipleMaterialsDoNotHaveDestinationFolderSet.
@Test
public void shouldFailIfMultipleMaterialsDoNotHaveDestinationFolderSet() {
HgMaterialConfig materialConfigOne = new HgMaterialConfig("http://url1", null);
materialConfigOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder"));
HgMaterialConfig materialConfigTwo = new HgMaterialConfig("http://url2", null);
PluggableSCMMaterialConfig materialConfigThree = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id"), null, null);
CruiseConfig config = GoConfigMother.configWithPipelines("one");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs((new MaterialConfigs(materialConfigOne, materialConfigTwo, materialConfigThree)));
pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
assertThat(pipelineOne.materialConfigs().get(0).errors().isEmpty(), is(true));
assertThat(pipelineOne.materialConfigs().get(1).errors().on(ScmMaterialConfig.FOLDER), is("Destination directory is required when specifying multiple scm materials"));
assertThat(pipelineOne.materialConfigs().get(2).errors().on(PluggableSCMMaterialConfig.FOLDER), is("Destination directory is required when specifying multiple scm materials"));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldNotThrowUpOnMaterialIfAutoUpdateValuesAreCorrect.
@Test
public void shouldNotThrowUpOnMaterialIfAutoUpdateValuesAreCorrect() throws Exception {
HgMaterialConfig materialOne = new HgMaterialConfig("http://url1", null);
materialOne.setAutoUpdate(true);
HgMaterialConfig materialTwo = new HgMaterialConfig("http://url1", null);
materialTwo.setAutoUpdate(true);
CruiseConfig config = GoConfigMother.configWithPipelines("one", "two", "three");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne));
PipelineConfig pipelineTwo = config.pipelineConfigByName(new CaseInsensitiveString("two"));
pipelineTwo.setMaterialConfigs(new MaterialConfigs(materialTwo));
pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
assertThat(pipelineOne.materialConfigs().get(0).errors().isEmpty(), is(true));
assertThat(pipelineTwo.materialConfigs().get(0).errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldFailIfAllScmMaterialsInAPipelineHaveSameFolders.
@Test
public void shouldFailIfAllScmMaterialsInAPipelineHaveSameFolders() throws IOException {
HgMaterialConfig materialOne = new HgMaterialConfig("http://url1", null);
materialOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder1"));
HgMaterialConfig materialTwo = new HgMaterialConfig("http://url2", null);
materialTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder1"));
PluggableSCMMaterialConfig materialThree = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id"), "folder1", null);
CruiseConfig config = GoConfigMother.configWithPipelines("one");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne, materialTwo, materialThree));
pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
String conflictingDirMessage = "Invalid Destination Directory. Every material needs a different destination directory and the directories should not be nested.";
assertThat(pipelineOne.materialConfigs().get(0).errors().on(ScmMaterialConfig.FOLDER), is(conflictingDirMessage));
assertThat(pipelineOne.materialConfigs().get(1).errors().on(ScmMaterialConfig.FOLDER), is(conflictingDirMessage));
assertThat(pipelineOne.materialConfigs().get(2).errors().on(PluggableSCMMaterialConfig.FOLDER), is(conflictingDirMessage));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldNotFailIfMultipleMaterialsHaveUniqueDestinationFolderSet.
@Test
public void shouldNotFailIfMultipleMaterialsHaveUniqueDestinationFolderSet() {
HgMaterialConfig materialOne = new HgMaterialConfig("http://url1", null);
materialOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder"));
HgMaterialConfig materialTwo = new HgMaterialConfig("http://url2", null);
materialTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder2"));
CruiseConfig config = GoConfigMother.configWithPipelines("one");
PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne, materialTwo));
pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
assertThat(pipelineOne.materialConfigs().get(0).errors().isEmpty(), is(true));
assertThat(pipelineOne.materialConfigs().get(1).errors().isEmpty(), is(true));
}
Aggregations