Search in sources :

Example 36 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class GitMaterialRepresenter method fromJSON.

@Override
public GitMaterialConfig fromJSON(JsonReader jsonReader, ConfigHelperOptions options) {
    GitMaterialConfig gitMaterialConfig = new GitMaterialConfig();
    jsonReader.readStringIfPresent("url", gitMaterialConfig::setUrl);
    super.fromJSON(jsonReader, gitMaterialConfig, options);
    jsonReader.optString("branch").ifPresent(branch -> {
        if (StringUtils.isNotBlank(branch)) {
            gitMaterialConfig.setBranch(branch);
        } else {
            gitMaterialConfig.setBranch("master");
        }
    });
    jsonReader.readStringIfPresent("submodule_folder", gitMaterialConfig::setSubmoduleFolder);
    jsonReader.optBoolean("shallow_clone").ifPresent(gitMaterialConfig::setShallowClone);
    return gitMaterialConfig;
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig)

Example 37 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldValidateTree.

@Test
public void shouldValidateTree() {
    GitMaterialConfig git = git();
    git.setName(new CaseInsensitiveString("mat-name"));
    SvnMaterialConfig svn = svn("url", true);
    svn.setName(new CaseInsensitiveString("mat-name"));
    P4MaterialConfig p4 = p4();
    TfsMaterialConfig tfs = tfs();
    HgMaterialConfig hg = hg();
    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.jupiter.api.Test)

Example 38 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldSetGitConfigAttributesForMaterial.

@Test
public void shouldSetGitConfigAttributesForMaterial() {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    Map<String, String> hashMap = new HashMap<>();
    hashMap.put(GitMaterialConfig.URL, "foo");
    hashMap.put(GitMaterialConfig.BRANCH, "master");
    HashMap<String, Object> attributeMap = new HashMap<>();
    attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, GitMaterialConfig.TYPE);
    attributeMap.put(GitMaterialConfig.TYPE, hashMap);
    materialConfigs.setConfigAttributes(attributeMap);
    assertThat(materialConfigs.size(), is(1));
    GitMaterialConfig expected = git("foo");
    expected.setConfigAttributes(Collections.singletonMap(GitMaterialConfig.BRANCH, "master"));
    assertThat(materialConfigs.first(), is(expected));
}
Also used : HashMap(java.util.HashMap) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 39 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertGitMaterialConfigToCRGitMaterial.

@Test
void shouldConvertGitMaterialConfigToCRGitMaterial() {
    GitMaterialConfig gitMaterialConfig = git("url", "branch", true);
    gitMaterialConfig.setName(new CaseInsensitiveString("name"));
    gitMaterialConfig.setFolder("folder");
    gitMaterialConfig.setAutoUpdate(true);
    gitMaterialConfig.setInvertFilter(false);
    gitMaterialConfig.setFilter(Filter.create("filter"));
    CRGitMaterial crGitMaterial = (CRGitMaterial) configConverter.materialToCRMaterial(gitMaterialConfig);
    assertThat(crGitMaterial.getName()).isEqualTo("name");
    assertThat(crGitMaterial.getDestination()).isEqualTo("folder");
    assertThat(crGitMaterial.isAutoUpdate()).isTrue();
    assertThat(crGitMaterial.isWhitelist()).isFalse();
    assertThat(crGitMaterial.getFilterList()).contains("filter");
    assertThat(crGitMaterial.getUrl()).isEqualTo("url");
    assertThat(crGitMaterial.getBranch()).isEqualTo("branch");
    assertThat(crGitMaterial.isShallowClone()).isTrue();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 40 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class GoConfigRepoConfigDataSourceTest method shouldMaintainAListOfConfigReposWhichHaveChangedSinceLastParse.

@Test
public void shouldMaintainAListOfConfigReposWhichHaveChangedSinceLastParse() {
    GitMaterialConfig material = git("http://my.git");
    ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
    GoConfigWatchList goConfigWatchList = mock(GoConfigWatchList.class);
    repoConfigDataSource = new GoConfigRepoConfigDataSource(goConfigWatchList, configPluginService, serverHealthService, configRepoService, goConfigService);
    when(goConfigWatchList.getConfigRepoForMaterial(material)).thenReturn(configRepoConfig);
    repoConfigDataSource.onConfigRepoConfigChange(configRepoConfig);
    assertTrue(repoConfigDataSource.hasConfigRepoConfigChangedSinceLastUpdate(material));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) Test(org.junit.jupiter.api.Test)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7