use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class TaskViewServiceTest method shouldGetViewModelsForBuiltinTasks.
@Test
public void shouldGetViewModelsForBuiltinTasks() {
List<Class<? extends Task>> taskClasses = taskImplementations();
when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
when(registry.getViewModelFor(new AntTask(), "new")).thenReturn(viewModel(new AntTask()));
when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(new TaskViewModel(new ExecTask(), ""));
List<PluggableViewModel> taskViewModels = taskViewService.getTaskViewModels();
assertThat(taskViewModels.size(), is(3));
assertThat(taskViewModels, hasItem((PluggableViewModel) viewModel(new AntTask())));
assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
}
use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class PipelineTemplateConfig method validateFetchTasks.
private void validateFetchTasks(JobConfig jobConfig, PipelineConfigSaveValidationContext contextForTasks) {
for (Task task : jobConfig.getTasks()) {
if (task instanceof FetchTask) {
task.validate(contextForTasks);
this.errors().addAll(task.errors());
}
}
}
use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class Tasks method setConfigAttributes.
public void setConfigAttributes(Object attributes, TaskFactory taskFactory) {
clear();
if (attributes == null) {
return;
}
if (taskFactory == null)
throw new IllegalArgumentException("ConfigContext cannot be null");
Map attributeMap = (Map) attributes;
String taskType = (String) attributeMap.get(TASK_OPTIONS);
Task task = taskFactory.taskInstanceFor(taskType);
task.setConfigAttributes(attributeMap.get(taskType), taskFactory);
add(task);
}
use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class BuilderMother method createBuildersAssumingAllExecTasks.
public static List<Builder> createBuildersAssumingAllExecTasks(CruiseConfig config, String pipelineName, String stageName, String jobName) {
Tasks tasks = config.jobConfigByName(pipelineName, stageName, jobName, true).getTasks();
ArrayList<Builder> builders = new ArrayList<>();
for (Task task : tasks) {
builders.add(builderFor((ExecTask) task));
}
return builders;
}
use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class ConfigElementImplementationRegistryTest method registerAllConfigTagImplementationsProvidedByPlugins.
@Test
public void registerAllConfigTagImplementationsProvidedByPlugins() throws MalformedURLException {
BundleContext execCtx = PluginTestUtil.bundleCtxWithHeaders(DataStructureUtils.m(PluginNamespace.XSD_NAMESPACE_PREFIX, "exec", PluginNamespace.XSD_NAMESPACE_URI, "uri-exec"));
PluggableViewModelFactory<PluginExec> factory = mock(PluggableViewModelFactory.class);
ConfigTypeExtension exec = new TestTaskConfigTypeExtension<>(PluginExec.class, factory);
ConfigurationExtension execTag = new ConfigurationExtension<>(new PluginNamespace(execCtx, new URL("file:///exec")), exec);
BundleContext antCtx = PluginTestUtil.bundleCtxWithHeaders(DataStructureUtils.m(PluginNamespace.XSD_NAMESPACE_PREFIX, "ant", PluginNamespace.XSD_NAMESPACE_URI, "uri-ant"));
ConfigTypeExtension ant = new TestTaskConfigTypeExtension<>(PluginAnt.class, mock(PluggableViewModelFactory.class));
ConfigurationExtension antTag = new ConfigurationExtension<>(new PluginNamespace(antCtx, new URL("file:///ant")), ant);
when(pluginExtns.configTagImplementations()).thenReturn(Arrays.asList(execTag, antTag));
ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(pluginExtns);
assertThat(registry.xsds(), containsString("uri-exec file:/exec"));
assertThat(registry.xsds(), containsString("uri-ant file:/ant"));
List<Class<? extends Task>> implementationTypes = registry.implementersOf(Task.class);
assertThat(implementationTypes.contains(PluginExec.class), is(true));
assertThat(implementationTypes.contains(PluginAnt.class), is(true));
Element mock = mock(Element.class);
registry.registerNamespacesInto(mock);
verify(mock).addNamespaceDeclaration(Namespace.getNamespace("exec", "uri-exec"));
verify(mock).addNamespaceDeclaration(Namespace.getNamespace("ant", "uri-ant"));
}
Aggregations