Search in sources :

Example 51 with PluginConfiguration

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

the class PluggableTaskServiceTest method shouldValidateTask.

@Test
public void shouldValidateTask() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    PluggableTask modifiedTask = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("KEY1", "error message"));
    when(taskExtension.validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class))).thenReturn(validationResult);
    pluggableTaskService.validate(modifiedTask);
    assertThat(modifiedTask.getConfiguration().getProperty("KEY1").errors().isEmpty(), is(false));
    assertThat(modifiedTask.getConfiguration().getProperty("KEY1").errors().firstError(), is("error message"));
    verify(taskExtension).validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class));
}
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)

Example 52 with PluginConfiguration

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

the class MergeCruiseConfigTest method shouldHaveValidationErrorsForDuplicateValidSCMs.

@Test
public void shouldHaveValidationErrorsForDuplicateValidSCMs() {
    BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2");
    ConfigRepoConfig repoConfig1 = ConfigRepoConfig.createConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url1"), "plugin", "id-1");
    ConfigRepoConfig repoConfig2 = ConfigRepoConfig.createConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url2"), "plugin", "id-2");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig1, repoConfig2));
    PartialConfig partialConfigInRepo1 = PartialConfigMother.withSCM("scmid", "name", new PluginConfiguration("plugin_id", "1"), new Configuration(), new FileConfigOrigin());
    RepoConfigOrigin configOrigin = new RepoConfigOrigin(repoConfig2, "repo2_r1");
    PartialConfig partialConfigInRepo2 = PartialConfigMother.withSCM("scmid", "name", new PluginConfiguration("plugin_id", "1"), new Configuration(), configOrigin);
    cruiseConfig.merge(new ArrayList<>(Arrays.asList(partialConfigInRepo2, partialConfigInRepo1)), false);
    assertThat(cruiseConfig.getSCMs().size(), is(2));
    assertThat(cruiseConfig.validateAfterPreprocess().size(), is(2));
}
Also used : 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 53 with PluginConfiguration

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

the class MergeCruiseConfigTest method shouldOnlyMergeLocalSCMsWhenEditIsTrue.

@Test
public void shouldOnlyMergeLocalSCMsWhenEditIsTrue() {
    BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2");
    ConfigRepoConfig repoConfig1 = ConfigRepoConfig.createConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url1"), "plugin", "id-1");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig1));
    RepoConfigOrigin configOrigin = new RepoConfigOrigin(repoConfig1, "repo1_r1");
    PartialConfig completeSCM = PartialConfigMother.withSCM("scmid", "name", new PluginConfiguration("plugin_id", "1"), new Configuration(), configOrigin);
    PartialConfig localSCM = PartialConfigMother.withSCM("local_id", "local", new PluginConfiguration("plugin_id2", "1"), new Configuration(), new FileConfigOrigin());
    cruiseConfig.merge(new ArrayList<>(Arrays.asList(localSCM, completeSCM)), true);
    assertThat(cruiseConfig.getSCMs().size(), is(1));
    assertThat(cruiseConfig.getSCMs().contains(localSCM.getScms().first()), is(true));
}
Also used : 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 54 with PluginConfiguration

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

the class PluggableTaskTest method validateTreeShouldVerifyIfOnCancelTasksHasErrors.

@Test
public void validateTreeShouldVerifyIfOnCancelTasksHasErrors() {
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
    pluggableTask.onCancelConfig = mock(OnCancelConfig.class);
    com.thoughtworks.go.domain.Task cancelTask = mock(com.thoughtworks.go.domain.Task.class);
    when(pluggableTask.onCancelConfig.getTask()).thenReturn(cancelTask);
    when(cancelTask.hasCancelTask()).thenReturn(false);
    when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(false);
    assertFalse(pluggableTask.validateTree(null));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig) Test(org.junit.jupiter.api.Test)

Example 55 with PluginConfiguration

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

the class PluggableTaskTest method isValidShouldVerifyIfPluginIdIsValid.

@Test
public void isValidShouldVerifyIfPluginIdIsValid() {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
    Configuration configuration = new Configuration();
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
    pluggableTask.isValid();
    assertThat(pluggableTask.errors().get("pluggable_task").get(0), is("Could not find plugin for given pluggable id:[does_not_exist]."));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) 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