Search in sources :

Example 91 with Configuration

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"));
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) PackageConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 92 with Configuration

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"));
}
Also used : PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) PackageConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 93 with Configuration

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"));
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 94 with Configuration

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(""));
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 95 with Configuration

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"));
    }
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)136 Test (org.junit.Test)114 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)97 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)29 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)20 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)17 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)17 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)15 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)14 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)12 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)11 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)11 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)10 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)9