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;
}
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"));
}
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));
}
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();
}
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));
}
Aggregations