use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithWhitelist.
@Test
void shouldConvertConfigMaterialWhenConfigRepoIsHgWithWhitelist() {
// this url would be configured inside xml config-repo section
HgMaterialConfig configRepoMaterial = hg("url", "folder");
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial(null, null, new CRFilter(filter, true));
MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context, new SCMs());
assertThat(materialConfig.getName()).as("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode").isNull();
HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
assertThat(hgMaterialConfig.getAutoUpdate()).isTrue();
assertThat(hgMaterialConfig.getFilterAsString()).isEqualTo("filter");
assertThat(hgMaterialConfig.getUrl()).isEqualTo("url");
assertThat(hgMaterialConfig.filter()).isEqualTo(new Filter(new IgnoredFiles("filter")));
assertThat(hgMaterialConfig.isInvertFilter()).isTrue();
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithEmptyFilter.
@Test
void shouldConvertConfigMaterialWhenConfigRepoIsHgWithEmptyFilter() {
// this url would be configured inside xml config-repo section
HgMaterialConfig configRepoMaterial = hg("url", "folder");
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial(null, null, new CRFilter(new ArrayList<>(), true));
MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context, new SCMs());
assertThat(materialConfig.getName()).as("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode").isNull();
HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
assertThat(hgMaterialConfig.getAutoUpdate()).isTrue();
assertThat(hgMaterialConfig.getFilterAsString()).isEqualTo("");
assertThat(hgMaterialConfig.getUrl()).isEqualTo("url");
assertThat(hgMaterialConfig.filter()).isEqualTo(new Filter());
assertThat(hgMaterialConfig.isInvertFilter()).isFalse();
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldBeAbleToListAllSCMMaterialConfigs.
@Test
public void shouldBeAbleToListAllSCMMaterialConfigs() {
BasicCruiseConfig config = mock(BasicCruiseConfig.class);
DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
HashSet<MaterialConfig> materialConfigs = new HashSet<>(Arrays.asList(dependencyMaterialConfig, svnMaterialConfig, pluggableSCMMaterialConfig));
when(goConfigService.getCurrentConfig()).thenReturn(config);
when(config.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos()).thenReturn(materialConfigs);
Set<MaterialConfig> schedulableDependencyMaterials = goConfigService.getSchedulableSCMMaterials();
assertThat(schedulableDependencyMaterials.size(), is(2));
assertTrue(schedulableDependencyMaterials.contains(svnMaterialConfig));
assertTrue(schedulableDependencyMaterials.contains(pluggableSCMMaterialConfig));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldFindMaterialConfigBasedOnFingerprint.
@Test
public void shouldFindMaterialConfigBasedOnFingerprint() throws Exception {
SvnMaterialConfig expected = svn("repo", null, null, false);
cruiseConfig = configWith(GoConfigMother.createPipelineConfigWithMaterialConfig(expected));
when(goConfigDao.load()).thenReturn(cruiseConfig);
MaterialConfig actual = goConfigService.materialForPipelineWithFingerprint("pipeline", expected.getFingerprint());
assertThat(actual, is(expected));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigFileHelper method addMaterialToPipeline.
public PipelineConfig addMaterialToPipeline(String pipelineName, MaterialConfig materialConfig) {
CruiseConfig config = loadForEdit();
PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
for (MaterialConfig materialConfig1 : new MaterialConfig[] { materialConfig }) {
pipelineConfig.addMaterialConfig(materialConfig1);
}
writeConfigFile(config);
return pipelineConfig;
}
Aggregations