Search in sources :

Example 6 with Task

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(), "")));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) FetchTask(com.thoughtworks.go.config.FetchTask) AntTask(com.thoughtworks.go.config.AntTask) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskViewModel(com.thoughtworks.go.presentation.TaskViewModel) ExecTask(com.thoughtworks.go.config.ExecTask) AntTask(com.thoughtworks.go.config.AntTask) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) Test(org.junit.Test)

Example 7 with Task

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());
        }
    }
}
Also used : Task(com.thoughtworks.go.domain.Task)

Example 8 with Task

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);
}
Also used : Task(com.thoughtworks.go.domain.Task) Map(java.util.Map)

Example 9 with 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;
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) Tasks(com.thoughtworks.go.config.Tasks) Builder(com.thoughtworks.go.domain.builder.Builder) ExecTask(com.thoughtworks.go.config.ExecTask) ArrayList(java.util.ArrayList)

Example 10 with Task

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"));
}
Also used : Task(com.thoughtworks.go.domain.Task) BuildTask(com.thoughtworks.go.config.BuildTask) Element(org.jdom2.Element) PluggableViewModelFactory(com.thoughtworks.go.plugins.presentation.PluggableViewModelFactory) URL(java.net.URL) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

Task (com.thoughtworks.go.domain.Task)15 Test (org.junit.Test)9 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)8 ExecTask (com.thoughtworks.go.config.ExecTask)6 AntTask (com.thoughtworks.go.config.AntTask)5 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)5 FetchTask (com.thoughtworks.go.config.FetchTask)5 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)4 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)4 KillAllChildProcessTask (com.thoughtworks.go.domain.KillAllChildProcessTask)2 NullTask (com.thoughtworks.go.domain.NullTask)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Cloner (com.rits.cloning.Cloner)1 BuildTask (com.thoughtworks.go.config.BuildTask)1 Tasks (com.thoughtworks.go.config.Tasks)1 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 Builder (com.thoughtworks.go.domain.builder.Builder)1