Search in sources :

Example 91 with CaseInsensitiveString

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"));
    }
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 92 with CaseInsensitiveString

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));
}
Also used : HashMap(java.util.HashMap) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 93 with CaseInsensitiveString

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));
}
Also used : HashMap(java.util.HashMap) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 94 with CaseInsensitiveString

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"))));
}
Also used : HashMap(java.util.HashMap) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 95 with CaseInsensitiveString

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"))));
}
Also used : HashMap(java.util.HashMap) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)392 Test (org.junit.Test)277 Username (com.thoughtworks.go.server.domain.Username)80 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)65 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)57 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)50 Modification (com.thoughtworks.go.domain.materials.Modification)44 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Before (org.junit.Before)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 HashMap (java.util.HashMap)26 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ArrayList (java.util.ArrayList)19 Pipeline (com.thoughtworks.go.domain.Pipeline)18