Search in sources :

Example 76 with PluginConfiguration

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

the class PackageRepositoryServiceTest method shouldAddErrorWhenPluginIdIsInvalid.

@Test
void shouldAddErrorWhenPluginIdIsInvalid() {
    PackageRepository packageRepository = new PackageRepository();
    packageRepository.setPluginConfiguration(new PluginConfiguration("missing-plugin", "1.0"));
    service.performPluginValidationsFor(packageRepository);
    assertThat(packageRepository.getPluginConfiguration().errors().getAllOn(PluginConfiguration.ID)).isEqualTo(Arrays.asList("Invalid plugin id"));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Example 77 with PluginConfiguration

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

the class PluggableScmServiceTest method shouldHandleIncorrectKeyForValidateSCM.

@Test
public void shouldHandleIncorrectKeyForValidateSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("NON-EXISTENT-KEY", "error message"));
    when(scmExtension.isSCMConfigurationValid(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(validationResult);
    pluggableScmService.validate(modifiedSCM);
    assertTrue(modifiedSCM.errors().isEmpty());
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) SCM(com.thoughtworks.go.domain.scm.SCM) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 78 with PluginConfiguration

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

the class PluggableTaskServiceTest method isValidShouldValidateThePluggableTask.

@Test
public void isValidShouldValidateThePluggableTask() {
    PluggableTask pluggableTask = mock(PluggableTask.class);
    PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin_id", "version");
    when(pluggableTask.isValid()).thenReturn(true);
    when(pluggableTask.toTaskConfig()).thenReturn(new TaskConfig());
    when(pluggableTask.getPluginConfiguration()).thenReturn(pluginConfiguration);
    when(taskExtension.validate(any(String.class), any(TaskConfig.class))).thenReturn(new ValidationResult());
    assertTrue(pluggableTaskService.isValid(pluggableTask));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.jupiter.api.Test)

Example 79 with PluginConfiguration

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

the class PluggableTaskServiceTest method isValidShouldMapPluginValidationErrorsToPluggableTaskForMissingConfigurations.

@Test
public void isValidShouldMapPluginValidationErrorsToPluggableTaskForMissingConfigurations() {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin_id", "version");
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("source", "source is mandatory"));
    PluggableTask pluggableTask = mock(PluggableTask.class);
    when(pluggableTask.isValid()).thenReturn(true);
    when(pluggableTask.toTaskConfig()).thenReturn(new TaskConfig());
    when(pluggableTask.getPluginConfiguration()).thenReturn(pluginConfiguration);
    when(pluggableTask.getConfiguration()).thenReturn(new Configuration());
    when(taskExtension.validate(any(String.class), any(TaskConfig.class))).thenReturn(validationResult);
    assertFalse(pluggableTaskService.isValid(pluggableTask));
    verify(pluggableTask).addError("source", "source is mandatory");
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) 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.jupiter.api.Test)

Example 80 with PluginConfiguration

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

the class PartialConfigServiceIntegrationTest method shouldSaveSCMs.

@Test
public void shouldSaveSCMs() {
    Configuration config = new Configuration();
    config.addNewConfigurationWithValue("url", "url", false);
    PluginConfiguration pluginConfig = new PluginConfiguration("plugin.id", "1.0");
    RepoConfigOrigin origin = new RepoConfigOrigin(repoConfig1, "124");
    PartialConfig scmPartial = PartialConfigMother.withSCM("scm_id", "name", pluginConfig, config, origin);
    partialConfigService.onSuccessPartialConfig(repoConfig1, scmPartial);
    SCMs scms = goConfigDao.loadConfigHolder().config.getSCMs();
    SCM expectedSCM = new SCM("scm_id", pluginConfig, config);
    expectedSCM.setOrigins(origin);
    expectedSCM.setName("name");
    assertThat(scms.size(), is(1));
    assertThat(scms.first(), is(expectedSCM));
    assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), scmPartial), is(true));
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.jupiter.api.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