use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class DFSCycleDetectorTest method shouldThrowExceptionWhenCycleDependencyFound.
@Test
public void shouldThrowExceptionWhenCycleDependencyFound() throws Exception {
when(state.getDependencyMaterials(new CaseInsensitiveString("a"))).thenReturn(new Node(new Node.DependencyNode(new CaseInsensitiveString("b"), new CaseInsensitiveString("stage"))));
when(state.getDependencyMaterials(new CaseInsensitiveString("b"))).thenReturn(new Node(new Node.DependencyNode(new CaseInsensitiveString("c"), new CaseInsensitiveString("stage"))));
when(state.getDependencyMaterials(new CaseInsensitiveString("c"))).thenReturn(new Node(new Node.DependencyNode(new CaseInsensitiveString("a"), new CaseInsensitiveString("stage"))));
when(state.hasPipeline(new CaseInsensitiveString("a"))).thenReturn(true);
when(state.hasPipeline(new CaseInsensitiveString("b"))).thenReturn(true);
when(state.hasPipeline(new CaseInsensitiveString("c"))).thenReturn(true);
try {
project.topoSort(new CaseInsensitiveString("a"), state);
} catch (Exception e) {
assertThat(e.getMessage(), is("Circular dependency: a <- c <- b <- a"));
}
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PluggableSCMMaterialConfigTest method shouldAddErrorIfSCMNameUniquenessValidationFails.
@Test
public void shouldAddErrorIfSCMNameUniquenessValidationFails() throws Exception {
Map<CaseInsensitiveString, AbstractMaterialConfig> nameToMaterialMap = new HashMap<>();
PluggableSCMMaterialConfig existingMaterial = new PluggableSCMMaterialConfig("scm-id");
nameToMaterialMap.put(new CaseInsensitiveString("scm-id"), existingMaterial);
nameToMaterialMap.put(new CaseInsensitiveString("foo"), new GitMaterialConfig("url"));
pluggableSCMMaterialConfig.validateNameUniqueness(nameToMaterialMap);
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Duplicate SCM material detected!"));
assertThat(existingMaterial.errors().getAll().size(), is(1));
assertThat(existingMaterial.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Duplicate SCM material detected!"));
assertThat(nameToMaterialMap.size(), is(2));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PluggableSCMMaterialConfigTest method shouldPassMaterialUniquenessIfIfNoDuplicateSCMFound.
@Test
public void shouldPassMaterialUniquenessIfIfNoDuplicateSCMFound() throws Exception {
Map<CaseInsensitiveString, AbstractMaterialConfig> nameToMaterialMap = new HashMap<>();
nameToMaterialMap.put(new CaseInsensitiveString("scm-id-new"), new PluggableSCMMaterialConfig("scm-id-new"));
nameToMaterialMap.put(new CaseInsensitiveString("foo"), new GitMaterialConfig("url"));
pluggableSCMMaterialConfig.validateNameUniqueness(nameToMaterialMap);
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(0));
assertThat(nameToMaterialMap.size(), is(3));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class GitMaterialConfigTest method shouldSetConfigAttributes.
@Test
public void shouldSetConfigAttributes() {
GitMaterialConfig gitMaterialConfig = new GitMaterialConfig("");
Map<String, String> map = new HashMap<>();
map.put(GitMaterialConfig.URL, "url");
map.put(GitMaterialConfig.BRANCH, "some-branch");
map.put(GitMaterialConfig.SHALLOW_CLONE, "true");
map.put(ScmMaterialConfig.FOLDER, "folder");
map.put(ScmMaterialConfig.AUTO_UPDATE, null);
map.put(ScmMaterialConfig.FILTER, "/root,/**/*.help");
map.put(AbstractMaterialConfig.MATERIAL_NAME, "material-name");
gitMaterialConfig.setConfigAttributes(map);
assertThat(gitMaterialConfig.getUrl(), is("url"));
assertThat(gitMaterialConfig.getFolder(), is("folder"));
assertThat(gitMaterialConfig.getBranch(), is("some-branch"));
assertThat(gitMaterialConfig.getName(), is(new CaseInsensitiveString("material-name")));
assertThat(gitMaterialConfig.isAutoUpdate(), is(false));
assertThat(gitMaterialConfig.isShallowClone(), is(true));
assertThat(gitMaterialConfig.filter(), is(new Filter(new IgnoredFiles("/root"), new IgnoredFiles("/**/*.help"))));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class HgMaterialConfigTest method shouldSetConfigAttributes.
@Test
public void shouldSetConfigAttributes() {
HgMaterialConfig hgMaterialConfig = new HgMaterialConfig("", null);
Map<String, String> map = new HashMap<>();
map.put(HgMaterialConfig.URL, "url");
map.put(ScmMaterialConfig.FOLDER, "folder");
map.put(ScmMaterialConfig.AUTO_UPDATE, "0");
map.put(ScmMaterialConfig.FILTER, "/root,/**/*.help");
map.put(AbstractMaterialConfig.MATERIAL_NAME, "material-name");
hgMaterialConfig.setConfigAttributes(map);
assertThat(hgMaterialConfig.getUrl(), is("url"));
assertThat(hgMaterialConfig.getFolder(), is("folder"));
assertThat(hgMaterialConfig.getName(), is(new CaseInsensitiveString("material-name")));
assertThat(hgMaterialConfig.isAutoUpdate(), is(false));
assertThat(hgMaterialConfig.filter(), is(new Filter(new IgnoredFiles("/root"), new IgnoredFiles("/**/*.help"))));
}
Aggregations