use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenPluggableScmMaterial.
@Test
void shouldConvertConfigMaterialWhenPluggableScmMaterial() {
SCM myscm = new SCM("scmid", new PluginConfiguration(), new Configuration());
SCMs scms = new SCMs(myscm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
PluggableSCMMaterialConfig configRepoMaterial = new PluggableSCMMaterialConfig(new CaseInsensitiveString("scmid"), myscm, null, null, false);
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", null);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crConfigMaterial, context, scms);
assertThat(pluggableSCMMaterialConfig.getName().toLower()).isEqualTo("example");
assertThat(pluggableSCMMaterialConfig.getSCMConfig()).isEqualTo(myscm);
assertThat(pluggableSCMMaterialConfig.getScmId()).isEqualTo("scmid");
assertThat(pluggableSCMMaterialConfig.getFolder()).isEqualTo("dest1");
assertThat(pluggableSCMMaterialConfig.getFilterAsString()).isEqualTo("");
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterial.
@Test
void shouldConvertPluggableScmMaterial() {
SCM myscm = new SCM("scmid", new PluginConfiguration(), new Configuration());
SCMs scms = new SCMs(myscm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
CRPluggableScmMaterial crPluggableScmMaterial = new CRPluggableScmMaterial("name", "scmid", "directory", filter, true);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crPluggableScmMaterial, context, scms);
assertThat(pluggableSCMMaterialConfig.getFilterAsString()).isEqualTo("filter");
assertTrue(pluggableSCMMaterialConfig.isInvertFilter());
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterialWithANewSCMDefinitionWithoutAnSCMID.
@Test
void shouldConvertPluggableScmMaterialWithANewSCMDefinitionWithoutAnSCMID() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(new SCMs());
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
CRPluggableScmMaterial crPluggableScmMaterial = new CRPluggableScmMaterial("name", null, "directory", filter, false);
crPluggableScmMaterial.setPluginConfiguration(new CRPluginConfiguration("plugin_id", "1.0"));
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crPluggableScmMaterial, context, new SCMs());
assertThat(pluggableSCMMaterialConfig.getScmId()).isNotNull();
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterialConfig.
@Test
void shouldConvertPluggableScmMaterialConfig() {
SCM myscm = new SCM("scmid", new PluginConfiguration(), new Configuration());
SCMs scms = new SCMs(myscm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(new CaseInsensitiveString("name"), myscm, "directory", Filter.create("filter"), false);
CRPluggableScmMaterial crPluggableScmMaterial = (CRPluggableScmMaterial) configConverter.materialToCRMaterial(pluggableSCMMaterialConfig);
assertThat(crPluggableScmMaterial.getName()).isEqualTo("name");
assertThat(crPluggableScmMaterial.getScmId()).isEqualTo("scmid");
assertThat(crPluggableScmMaterial.getDestination()).isEqualTo("directory");
assertThat(crPluggableScmMaterial.getFilterList()).contains("filter");
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterialWithADuplicateSCMFingerPrintShouldUseWhatAlreadyExists.
@Test
void shouldConvertPluggableScmMaterialWithADuplicateSCMFingerPrintShouldUseWhatAlreadyExists() {
Configuration config = new Configuration();
config.addNewConfigurationWithValue("url", "url", false);
SCM scm = new SCM("scmid", new PluginConfiguration("plugin_id", "1.0"), config);
scm.setName("noName");
SCMs scms = new SCMs(scm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
CRPluggableScmMaterial crPluggableScmMaterial = new CRPluggableScmMaterial("name", "scmid", "directory", filter, false);
crPluggableScmMaterial.setPluginConfiguration(new CRPluginConfiguration("plugin_id", "1.0"));
crPluggableScmMaterial.getConfiguration().add(new CRConfigurationProperty("url", "url"));
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crPluggableScmMaterial, context, scms);
assertThat(pluggableSCMMaterialConfig.getSCMConfig()).isEqualTo(scm);
}
Aggregations