Search in sources :

Example 1 with AntTask

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

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

the class TaskViewServiceTest method shouldGetTaskInstanceForAType.

@Test
public void shouldGetTaskInstanceForAType() throws Exception {
    ConfigElementImplementationRegistry registry = this.registry;
    when(registry.implementersOf(Task.class)).thenReturn(taskImplementations());
    TaskViewService taskViewService = new TaskViewService(registry, mock(PluginManager.class));
    assertThat(taskViewService.taskInstanceFor(new AntTask().getTaskType()), is(new AntTask()));
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) AntTask(com.thoughtworks.go.config.AntTask) Test(org.junit.Test)

Example 3 with AntTask

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

the class TaskViewServiceTest method shouldCreateTaskViewModelsGivenATask.

@Test
public void shouldCreateTaskViewModelsGivenATask() {
    when(registry.implementersOf(Task.class)).thenReturn(taskImplementations());
    ExecTask given = new ExecTask("mkdir", "foo", "work");
    AntTask ant = new AntTask();
    FetchTask fetch = new FetchTask();
    when(registry.getViewModelFor(ant, "new")).thenReturn(viewModel(ant));
    when(registry.getViewModelFor(fetch, "new")).thenReturn(viewModel(fetch));
    when(registry.getViewModelFor(given, "new")).thenReturn(viewModel(given));
    List<PluggableViewModel> viewModels = taskViewService.getTaskViewModelsWith(given);
    assertThat(viewModels.size(), is(3));
    assertThat(viewModels.contains(viewModel(ant)), is(true));
    assertThat(viewModels.contains(viewModel(fetch)), is(true));
    assertThat(viewModels.contains(viewModel(given)), is(true));
}
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 4 with AntTask

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

the class TaskViewServiceTest method shouldGetViewModelsOnlyForBuiltInTasks_WhenThereAreNoExistingPlugins.

@Test
public void shouldGetViewModelsOnlyForBuiltInTasks_WhenThereAreNoExistingPlugins() throws Exception {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    taskClasses.add(PluggableTask.class);
    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 5 with AntTask

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

the class TaskViewServiceTest method shouldGetListOfOnCancelTaskViewModels.

@Test
public void shouldGetListOfOnCancelTaskViewModels() {
    ConfigElementImplementationRegistry registry = this.registry;
    when(registry.implementersOf(Task.class)).thenReturn(taskImplementations());
    AntTask ant = new AntTask();
    FetchTask fetch = new FetchTask();
    ExecTask exec = new ExecTask();
    when(registry.getViewModelFor(ant, "new")).thenReturn(viewModel(ant));
    when(registry.getViewModelFor(fetch, "new")).thenReturn(viewModel(fetch));
    when(registry.getViewModelFor(exec, "new")).thenReturn(viewModel(exec));
    TaskViewService taskViewService = new TaskViewService(registry, mock(PluginManager.class));
    List<PluggableViewModel<Task>> onCancelTaskViewModels = taskViewService.getOnCancelTaskViewModels(new AntTask());
    assertThat(onCancelTaskViewModels, is(asList(viewModel(ant), viewModel(exec), viewModel(fetch))));
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) 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)

Aggregations

AntTask (com.thoughtworks.go.config.AntTask)14 ExecTask (com.thoughtworks.go.config.ExecTask)7 Test (org.junit.Test)6 FetchTask (com.thoughtworks.go.config.FetchTask)5 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)5 Test (org.junit.jupiter.api.Test)3 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)2 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)2 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)2 Task (com.thoughtworks.go.domain.Task)2 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)2 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)2 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 NantTask (com.thoughtworks.go.config.NantTask)1 RakeTask (com.thoughtworks.go.config.RakeTask)1 Tasks (com.thoughtworks.go.config.Tasks)1 Builder (com.thoughtworks.go.domain.builder.Builder)1 Configuration (com.thoughtworks.go.domain.config.Configuration)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1