Search in sources :

Example 46 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class SCMsTest method shouldDetermineIfAddingAnSCMWouldCreateDuplication.

@Test
void shouldDetermineIfAddingAnSCMWouldCreateDuplication() {
    Configuration config = new Configuration();
    config.addNewConfigurationWithValue("url", "url", false);
    PluginConfiguration pluginConfig = new PluginConfiguration("plugin_id", "1.0");
    SCM scm1 = new SCM("scmid", pluginConfig, config);
    scm1.setName("noName");
    SCMs scms = new SCMs(scm1);
    SCM scm2 = new SCM("scmid", new PluginConfiguration(), new Configuration());
    SCM scm3 = new SCM("id", pluginConfig, config);
    SCM scm4 = new SCM("something", new PluginConfiguration(), new Configuration());
    scm4.setName("noName");
    SCM scm5 = new SCM("arbitrary", new PluginConfiguration(), new Configuration());
    scm5.setName("aRandomName");
    assertThat(scms.canAdd(scm2)).isFalse();
    assertThat(scms.canAdd(scm3)).isFalse();
    assertThat(scms.canAdd(scm4)).isFalse();
    assertThat(scms.canAdd(scm5)).isTrue();
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 47 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class SCMMother method create.

public static SCM create(String id, String name, String pluginId, String pluginVersion, Configuration configuration) {
    SCM scm = new SCM();
    scm.setId(id);
    scm.setName(name);
    scm.setPluginConfiguration(new PluginConfiguration(pluginId, pluginVersion));
    scm.setConfiguration(configuration);
    return scm;
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration)

Example 48 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration 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)

Example 49 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class PackageRepositoryTest method createPackageRepository.

private PackageRepository createPackageRepository(String pluginId, String version, String id, String name, Configuration configuration, Packages packages) {
    PackageRepository packageRepository = new PackageRepository();
    packageRepository.setConfiguration(configuration);
    packageRepository.setPackages(packages);
    packageRepository.setPluginConfiguration(new PluginConfiguration(pluginId, version));
    packageRepository.setId(id);
    packageRepository.setName(name);
    return packageRepository;
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration)

Example 50 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.

the class PluggableTaskServiceTest method shouldValidateMandatoryFields.

@Test
public void shouldValidateMandatoryFields() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    PluggableTask modifiedTask = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    when(taskExtension.validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class))).thenReturn(validationResult);
    when(localizer.localize("MANDATORY_CONFIGURATION_FIELD")).thenReturn("MANDATORY_CONFIGURATION_FIELD");
    pluggableTaskService.validate(modifiedTask);
    final List<ValidationError> validationErrors = validationResult.getErrors();
    assertFalse(validationErrors.isEmpty());
    final ValidationError validationError = validationErrors.stream().filter(new Predicate<ValidationError>() {

        @Override
        public boolean test(ValidationError item) {
            return ((ValidationError) item).getKey().equals("KEY1");
        }
    }).findFirst().orElse(null);
    assertNotNull(validationError);
    assertThat(validationError.getMessage(), is("MANDATORY_CONFIGURATION_FIELD"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)88 Configuration (com.thoughtworks.go.domain.config.Configuration)63 Test (org.junit.jupiter.api.Test)61 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)29 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)23 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)13 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)9 Test (org.junit.Test)9 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 Map (java.util.Map)8 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)6 HashMap (java.util.HashMap)5 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 Result (com.thoughtworks.go.plugin.api.response.Result)4 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 AntTask (com.thoughtworks.go.config.AntTask)3