use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class MaterialServiceTest method shouldGetLatestModificationForPackageMaterial.
@Test
public void shouldGetLatestModificationForPackageMaterial() {
PackageMaterial material = new PackageMaterial();
PackageDefinition packageDefinition = create("id", "package", new Configuration(), PackageRepositoryMother.create("id", "name", "plugin-id", "plugin-version", new Configuration()));
material.setPackageDefinition(packageDefinition);
when(packageRepositoryExtension.getLatestRevision(eq("plugin-id"), any(PackageConfiguration.class), any(RepositoryConfiguration.class))).thenReturn(new PackageRevision("blah-123", new Date(), "user"));
List<Modification> modifications = materialService.latestModification(material, null, null);
assertThat(modifications.get(0).getRevision(), is("blah-123"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class MaterialServiceTest method shouldGetModificationSinceAGivenRevision.
@Test
public void shouldGetModificationSinceAGivenRevision() {
PackageMaterial material = new PackageMaterial();
PackageDefinition packageDefinition = create("id", "package", new Configuration(), PackageRepositoryMother.create("id", "name", "plugin-id", "plugin-version", new Configuration()));
material.setPackageDefinition(packageDefinition);
when(packageRepositoryExtension.latestModificationSince(eq("plugin-id"), any(PackageConfiguration.class), any(RepositoryConfiguration.class), any(PackageRevision.class))).thenReturn(new PackageRevision("new-revision-456", new Date(), "user"));
List<Modification> modifications = materialService.modificationsSince(material, null, new PackageMaterialRevision("revision-124", new Date()), null);
assertThat(modifications.get(0).getRevision(), is("new-revision-456"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterial.
@Test
public 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);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crPluggableScmMaterial, context);
assertThat(pluggableSCMMaterialConfig.getName().toLower(), is("name"));
assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(myscm));
assertThat(pluggableSCMMaterialConfig.getScmId(), is("scmid"));
assertThat(pluggableSCMMaterialConfig.getFolder(), is("directory"));
assertThat(pluggableSCMMaterialConfig.getFilterAsString(), is("filter"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenPluggableScmMaterial.
@Test
public 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);
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", null);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crConfigMaterial, context);
assertThat(pluggableSCMMaterialConfig.getName().toLower(), is("example"));
assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(myscm));
assertThat(pluggableSCMMaterialConfig.getScmId(), is("scmid"));
assertThat(pluggableSCMMaterialConfig.getFolder(), is("dest1"));
assertThat(pluggableSCMMaterialConfig.getFilterAsString(), is(""));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class ConfigConverterTest method shouldFailToConvertConfigMaterialWhenPluggableScmMaterialWithWhitelist.
@Test
public void shouldFailToConvertConfigMaterialWhenPluggableScmMaterialWithWhitelist() {
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);
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", new CRFilter(filter, true));
try {
configConverter.toMaterialConfig(crConfigMaterial, context);
fail("should have thrown");
} catch (ConfigConvertionException ex) {
assertThat(ex.getMessage(), is("Plugable SCMs do not support whitelisting"));
}
}
Aggregations