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"));
}
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;
}
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);
}
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());
}
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");
}
Aggregations