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))));
}
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()));
}
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));
}
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(), "")));
}
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))));
}
Aggregations