Search in sources :

Example 1 with TfsMaterialConfig

use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldNotThrowUpWhenTfsWorkspaceIsNotSpecified.

@Test
public void shouldNotThrowUpWhenTfsWorkspaceIsNotSpecified() {
    CruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("tfs_pipeline");
    PipelineConfig tfs_pipeline = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("tfs_pipeline"));
    tfs_pipeline.materialConfigs().clear();
    tfs_pipeline.addMaterialConfig(new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://tfs.com"), "username", "CORPORATE", "password", "$/project_path"));
    try {
        xmlWriter.write(cruiseConfig, output, false);
    } catch (Exception e) {
        fail("should not fail as workspace name is not mandatory anymore " + e);
    }
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ExpectedException(org.junit.rules.ExpectedException) JDOMParseException(org.jdom2.input.JDOMParseException) Test(org.junit.Test)

Example 2 with TfsMaterialConfig

use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.

the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.

@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
    final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
    svnMaterialConfig.setAutoUpdate(false);
    final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
    svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
    final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
    hgMaterialConfig.setAutoUpdate(false);
    final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
    gitMaterialConfig.setAutoUpdate(false);
    final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
    tfsMaterialConfig.setAutoUpdate(false);
    final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
    p4MaterialConfig.setAutoUpdate(false);
    final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
    final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
    pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
    final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
    final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
    assertThat(materials.size(), is(6));
    assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
    assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GoCipher(com.thoughtworks.go.security.GoCipher) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) 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) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 3 with TfsMaterialConfig

use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldSetTfsConfigAttributesForMaterial.

@Test
public void shouldSetTfsConfigAttributesForMaterial() {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    Map<String, String> tfsAttrMap = new HashMap<>();
    tfsAttrMap.put(TfsMaterialConfig.URL, "foo");
    tfsAttrMap.put(TfsMaterialConfig.USERNAME, "bar");
    tfsAttrMap.put(TfsMaterialConfig.PASSWORD, "baz");
    tfsAttrMap.put(TfsMaterialConfig.PROJECT_PATH, "to_hell");
    tfsAttrMap.put(TfsMaterialConfig.MATERIAL_NAME, "crapy_material");
    tfsAttrMap.put(TfsMaterialConfig.DOMAIN, "CORPORATE");
    Map<String, Object> attributeMap = new HashMap<>();
    attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, TfsMaterialConfig.TYPE);
    attributeMap.put(TfsMaterialConfig.TYPE, tfsAttrMap);
    materialConfigs.setConfigAttributes(attributeMap);
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("foo"), "bar", "CORPORATE", "baz", "to_hell");
    tfsMaterialConfig.setName(new CaseInsensitiveString("crapy_material"));
    assertThat(materialConfigs.first(), is(tfsMaterialConfig));
    assertThat(tfsMaterialConfig.getPassword(), is("baz"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) HashMap(java.util.HashMap) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with TfsMaterialConfig

use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldValidateTree.

@Test
public void shouldValidateTree() {
    GitMaterialConfig git = new GitMaterialConfig();
    git.setName(new CaseInsensitiveString("mat-name"));
    SvnMaterialConfig svn = new SvnMaterialConfig("url", true);
    svn.setName(new CaseInsensitiveString("mat-name"));
    P4MaterialConfig p4 = new P4MaterialConfig();
    TfsMaterialConfig tfs = new TfsMaterialConfig();
    HgMaterialConfig hg = new HgMaterialConfig();
    MaterialConfigs materialConfigs = new MaterialConfigs(git, svn, p4, tfs, hg);
    PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("p1"), new MaterialConfigs(svn));
    materialConfigs.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig)), pipelineConfig));
    assertThat(git.errors().on(GitMaterialConfig.MATERIAL_NAME), contains("You have defined multiple materials called 'mat-name'"));
    assertThat(git.errors().on(GitMaterialConfig.URL), is("URL cannot be blank"));
    assertThat(svn.errors().on(SvnMaterialConfig.MATERIAL_NAME), contains("You have defined multiple materials called 'mat-name'"));
    assertThat(p4.errors().on(P4MaterialConfig.VIEW), contains("P4 view cannot be empty."));
    assertThat(tfs.errors().on(TfsMaterialConfig.URL), contains("URL cannot be blank"));
    assertThat(hg.errors().on(HgMaterialConfig.URL), is("URL cannot be blank"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 5 with TfsMaterialConfig

use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.

the class MaterialConfigsMother method tfsMaterialConfig.

public static TfsMaterialConfig tfsMaterialConfig() {
    Filter filter = new Filter(new IgnoredFiles("**/*.html"), new IgnoredFiles("**/foobar/"));
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "some_domain", "passwd", "walk_this_path");
    tfsMaterialConfig.setFilter(filter);
    tfsMaterialConfig.setName(new CaseInsensitiveString("tfs-material"));
    tfsMaterialConfig.setFolder("dest-folder");
    return tfsMaterialConfig;
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)14 Test (org.junit.Test)12 GoCipher (com.thoughtworks.go.security.GoCipher)8 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)5 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)5 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)1 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)1 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)1 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 File (java.io.File)1 HashMap (java.util.HashMap)1