Search in sources :

Example 1 with HgUrlArgument

use of com.thoughtworks.go.util.command.HgUrlArgument in project gocd by gocd.

the class HgMaterialConfig method setConfigAttributes.

@Override
public void setConfigAttributes(Object attributes) {
    if (attributes == null) {
        return;
    }
    super.setConfigAttributes(attributes);
    Map map = (Map) attributes;
    if (map.containsKey(URL)) {
        this.url = new HgUrlArgument((String) map.get(URL));
    }
    if (map.containsKey("userName")) {
        this.userName = (String) map.get("userName");
    }
    if (map.containsKey(PASSWORD_CHANGED) && "1".equals(map.get(PASSWORD_CHANGED))) {
        String passwordToSet = (String) map.get(PASSWORD);
        resetPassword(passwordToSet);
    }
    if (map.containsKey(BRANCH)) {
        setBranchAttribute((String) map.get(BRANCH));
    }
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) Map(java.util.Map)

Example 2 with HgUrlArgument

use of com.thoughtworks.go.util.command.HgUrlArgument in project gocd by gocd.

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithDestination.

@Test
void shouldConvertConfigMaterialWhenConfigRepoIsHgWithDestination() {
    // these parameters would be configured inside xml config-repo section
    HgMaterialConfig configRepoMaterial = hg(new HgUrlArgument("url"), null, null, null, true, new Filter(new IgnoredFiles("ignore")), false, "folder", new CaseInsensitiveString("name"));
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", null);
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context, new SCMs());
    assertThat(materialConfig.getName().toLower()).as("shouldSetMaterialNameAsInConfigRepoSourceCode").isEqualTo("example");
    assertThat(materialConfig.getFolder()).as("shouldUseFolderFromConfigRepoWhenSpecified").isEqualTo("dest1");
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
    assertThat(hgMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(hgMaterialConfig.getFilterAsString()).isEqualTo("ignore");
    assertThat(hgMaterialConfig.getUrl()).isEqualTo("url");
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) 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) Test(org.junit.jupiter.api.Test)

Example 3 with HgUrlArgument

use of com.thoughtworks.go.util.command.HgUrlArgument in project gocd by gocd.

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHg.

@Test
void shouldConvertConfigMaterialWhenConfigRepoIsHg() {
    // these parameters would be configured inside xml config-repo section
    HgMaterialConfig configRepoMaterial = hg(new HgUrlArgument("url"), null, null, null, true, new Filter(new IgnoredFiles("ignore")), false, "folder", new CaseInsensitiveString("name"));
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", null, null);
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context, new SCMs());
    assertThat(materialConfig.getName().toLower()).as("shouldSetMaterialNameAsInConfigRepoSourceCode").isEqualTo("example");
    assertThat(materialConfig.getFolder()).as("shouldUseFolderFromXMLWhenConfigRepoHasNone").isEqualTo("folder");
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
    assertThat(hgMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(hgMaterialConfig.getFilterAsString()).isEqualTo("ignore");
    assertThat(hgMaterialConfig.getUrl()).isEqualTo("url");
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) 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) Test(org.junit.jupiter.api.Test)

Aggregations

HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)3 Filter (com.thoughtworks.go.config.materials.Filter)2 IgnoredFiles (com.thoughtworks.go.config.materials.IgnoredFiles)2 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)2 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)2 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)2 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)2 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)2 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)2 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)2 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)2 SCMs (com.thoughtworks.go.domain.scm.SCMs)2 Test (org.junit.jupiter.api.Test)2 Map (java.util.Map)1