use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method shouldReturnMissingPluginTaskViewIfPluginIsMissing.
@Test
public void shouldReturnMissingPluginTaskViewIfPluginIsMissing() {
String pluginId = "pluginId";
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(new PluggableTask(new PluginConfiguration(pluginId, "1"), new Configuration()), "edit");
assertThat(viewModel.getParameters().get("template"), is(String.format("Associated plugin '%s' not found. Please contact the Go admin to install the plugin.", pluginId)));
assertThat(viewModel.getTypeForDisplay(), is(pluginId));
assertThat(viewModel instanceof MissingPluggableTaskViewModel, is(true));
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method typeForDisplayAndTemplateOfViewModelShouldBeGotFromThePlugin.
@Test
public void typeForDisplayAndTemplateOfViewModelShouldBeGotFromThePlugin() throws Exception {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(pluggableTask, "new");
assertThat(viewModel.getTypeForDisplay(), is("First plugin"));
assertThat(viewModel.getParameters().get("template"), is("<input type='text' ng-model='abc'></input>"));
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PipelineConfigServiceTest method updatePipelineConfigShouldValidateAllPluggableTasks.
@Test
public void updatePipelineConfigShouldValidateAllPluggableTasks() {
PluggableTask xUnit = mock(PluggableTask.class);
PluggableTask docker = mock(PluggableTask.class);
JobConfig job1 = JobConfigMother.job();
JobConfig job2 = JobConfigMother.job();
job1.addTask(xUnit);
job2.addTask(docker);
PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("P1", new StageConfig(new CaseInsensitiveString("S1"), new JobConfigs(job1)), new StageConfig(new CaseInsensitiveString("S2"), new JobConfigs(job2)));
pipelineConfigService.updatePipelineConfig(null, pipeline, null, null);
verify(pluggableTaskService).isValid(xUnit);
verify(pluggableTaskService).isValid(docker);
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask 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.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskBuilderTest method shouldPublishErrorMessageIfPluginThrowsAnException.
@Test
public void shouldPublishErrorMessageIfPluginThrowsAnException() throws CruiseControlException {
PluggableTask task = mock(PluggableTask.class);
when(task.getPluginConfiguration()).thenReturn(new PluginConfiguration());
PluggableTaskBuilder taskBuilder = new PluggableTaskBuilder(runIfConfigs, cancelBuilder, pluggableTask, TEST_PLUGIN_ID, "test-directory") {
@Override
protected ExecutionResult executeTask(Task task, DefaultGoPublisher publisher, EnvironmentVariableContext environmentVariableContext, String consoleLogCharset) {
throw new RuntimeException("err");
}
};
try {
taskBuilder.build(goPublisher, variableContext, taskExtension, null, null, "utf-8");
fail("expected exception to be thrown");
} catch (Exception e) {
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(goPublisher).taggedConsumeLine(eq(DefaultGoPublisher.ERR), captor.capture());
String error = "Error: err";
assertThat(captor.getValue(), is(error));
assertThat(e.getMessage(), is(new RuntimeException("err").toString()));
}
}
Aggregations