Search in sources :

Example 1 with PluginConfiguration

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

the class SCMTest method shouldGetSCMTypeCorrectly.

@Test
public void shouldGetSCMTypeCorrectly() {
    SCM scm = SCMMother.create("scm-id");
    assertThat(scm.getSCMType(), is("pluggable_material_plugin"));
    scm.setPluginConfiguration(new PluginConfiguration("plugin-id-2", "1"));
    assertThat(scm.getSCMType(), is("pluggable_material_plugin_id_2"));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 2 with PluginConfiguration

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

the class TaskViewService method allPluginTasks.

private List<PluggableTask> allPluginTasks() {
    final ArrayList<PluggableTask> tasks = new ArrayList<>();
    for (final String pluginId : PluggableTaskConfigStore.store().pluginIds()) {
        GoPluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptorFor(pluginId);
        TaskPreference taskPreference = PluggableTaskConfigStore.store().preferenceFor(pluginId);
        if (pluginDescriptor != null && taskPreference != null) {
            tasks.add(new PluggableTask(new PluginConfiguration(pluginId, pluginDescriptor.version()), getConfiguration(taskPreference.getConfig())));
        }
    }
    return tasks;
}
Also used : ArrayList(java.util.ArrayList) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)

Example 3 with PluginConfiguration

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

the class PluggableScmServiceTest method shouldCheckConnectionToSCM.

@Test
public void shouldCheckConnectionToSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    Result expectedResult = new Result();
    expectedResult.withSuccessMessages(Arrays.asList("message"));
    when(scmExtension.checkConnectionToSCM(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(expectedResult);
    Result gotResult = pluggableScmService.checkConnection(modifiedSCM);
    verify(scmExtension).checkConnectionToSCM(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class));
    assertSame(expectedResult, gotResult);
}
Also used : 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) Result(com.thoughtworks.go.plugin.api.response.Result) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Example 4 with PluginConfiguration

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

the class PluggableTaskServiceTest method shouldPassValidationIfAllRequiredFieldsHaveValues.

@Test
public void shouldPassValidationIfAllRequiredFieldsHaveValues() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
    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);
    pluggableTaskService.validate(modifiedTask);
    final List<ValidationError> validationErrors = validationResult.getErrors();
    assertTrue(validationErrors.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) 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 5 with PluginConfiguration

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

the class TaskViewServiceTest method shouldGetViewModelsForPluggedInTasks_ButOnlyForExistingPlugins.

@Test
public void shouldGetViewModelsForPluggedInTasks_ButOnlyForExistingPlugins() throws Exception {
    String plugin1 = "task-plugin-1";
    String plugin2 = "task-plugin-2";
    when(pluginManager.getPluginDescriptorFor(plugin1)).thenReturn(new GoPluginDescriptor(plugin1, "1", null, null, null, false));
    when(pluginManager.getPluginDescriptorFor(plugin2)).thenReturn(new GoPluginDescriptor(plugin2, "1", null, null, null, false));
    storeTaskPreferences(plugin1, "key_1", "key_2");
    storeTaskPreferences(plugin2, "key_3", "key_4");
    when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(ExecTask.class, PluggableTask.class));
    PluggableTask expectedPluggableTaskForPlugin1 = new PluggableTask(new PluginConfiguration(plugin1, "1"), new Configuration(create("key_1"), create("key_2")));
    PluggableTask expectedPluggableTaskForPlugin2 = new PluggableTask(new PluginConfiguration(plugin2, "1"), new Configuration(create("key_3"), create("key_4")));
    when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(viewModel(new ExecTask()));
    when(registry.getViewModelFor(expectedPluggableTaskForPlugin1, "new")).thenReturn(viewModel(expectedPluggableTaskForPlugin1));
    when(registry.getViewModelFor(expectedPluggableTaskForPlugin2, "new")).thenReturn(viewModel(expectedPluggableTaskForPlugin2));
    List<PluggableViewModel> viewModels = taskViewService.getTaskViewModels();
    assertThat(viewModels.size(), is(3));
    assertThat(viewModels.get(0).getModel(), instanceOf(ExecTask.class));
    assertThat(viewModels.get(1).getModel(), instanceOf(PluggableTask.class));
    assertThat(viewModels.get(2).getModel(), instanceOf(PluggableTask.class));
    assertThat(viewModels.get(1).getModel(), is(expectedPluggableTaskForPlugin1));
    assertThat(viewModels.get(2).getModel(), is(expectedPluggableTaskForPlugin2));
    verify(registry).getViewModelFor(expectedPluggableTaskForPlugin1, "new");
    verify(registry).getViewModelFor(expectedPluggableTaskForPlugin2, "new");
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) ExecTask(com.thoughtworks.go.config.ExecTask) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) 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