Search in sources :

Example 1 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class PipelineBeanTest method shouldReturnExecTasksWithParameters.

@Test
public void shouldReturnExecTasksWithParameters() {
    PipelineBean execBean = execBean("exec", "java", "-DDEBUG_MODE=true -Xms=1024 -jar agent.jar");
    ExecTask execTask = new ExecTask("java", "-DDEBUG_MODE=true -Xms=1024 -jar agent.jar", (String) null);
    assertThat(execBean.getTasks().get(0), is(execTask));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Test(org.junit.Test)

Example 2 with ExecTask

use of com.thoughtworks.go.config.ExecTask 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 3 with ExecTask

use of com.thoughtworks.go.config.ExecTask 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)

Example 4 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class TaskViewServiceTest method getOnCancelTaskViewModels_shouldUsePassedInTaskOnCancelIfAvailable.

@Test
public void getOnCancelTaskViewModels_shouldUsePassedInTaskOnCancelIfAvailable() {
    when(registry.implementersOf(Task.class)).thenReturn(taskImplementations());
    AntTask ant = new AntTask();
    FetchTask fetch = new FetchTask();
    AntTask given = new AntTask();
    ExecTask cancelExec = new ExecTask("ls", "-la", ".");
    given.setCancelTask(cancelExec);
    when(registry.getViewModelFor(ant, "new")).thenReturn(viewModel(ant));
    when(registry.getViewModelFor(fetch, "new")).thenReturn(viewModel(fetch));
    when(registry.getViewModelFor(cancelExec, "edit")).thenReturn(viewModel(cancelExec));
    List<PluggableViewModel<Task>> onCancelTaskViewModels = new TaskViewService(registry, mock(PluginManager.class)).getOnCancelTaskViewModels(given);
    assertThat(onCancelTaskViewModels, is(asList(viewModel(ant), viewModel(cancelExec), viewModel(fetch))));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) AntTask(com.thoughtworks.go.config.AntTask) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) FetchTask(com.thoughtworks.go.config.FetchTask) Test(org.junit.Test)

Example 5 with ExecTask

use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.

the class TaskViewServiceTest method shouldNotGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOff.

@Test
public void shouldNotGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOff() {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    taskClasses.add(FetchPluggableArtifactTask.class);
    when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(false);
    when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
    when(registry.getViewModelFor(new FetchPluggableArtifactTask(), "new")).thenReturn(viewModel(new FetchPluggableArtifactTask()));
    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) new TaskViewModel(new ExecTask(), "")));
    assertThat(taskViewModels.indexOf(viewModel(new FetchPluggableArtifactTask())), is(-1));
}
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) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) Test(org.junit.Test)

Aggregations

ExecTask (com.thoughtworks.go.config.ExecTask)22 Test (org.junit.Test)10 AntTask (com.thoughtworks.go.config.AntTask)9 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)8 FetchTask (com.thoughtworks.go.config.FetchTask)7 Test (org.junit.jupiter.api.Test)7 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)5 Task (com.thoughtworks.go.domain.Task)5 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)4 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)4 ArrayList (java.util.ArrayList)4 Builder (com.thoughtworks.go.domain.builder.Builder)3 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 Tasks (com.thoughtworks.go.config.Tasks)2 File (java.io.File)2 Argument (com.thoughtworks.go.config.Argument)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 ConfigCache (com.thoughtworks.go.config.ConfigCache)1 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)1 NantTask (com.thoughtworks.go.config.NantTask)1