Search in sources :

Example 6 with PluggableViewModel

use of com.thoughtworks.go.plugins.presentation.PluggableViewModel 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)

Example 7 with PluggableViewModel

use of com.thoughtworks.go.plugins.presentation.PluggableViewModel 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 8 with PluggableViewModel

use of com.thoughtworks.go.plugins.presentation.PluggableViewModel in project gocd by gocd.

the class ConfigElementImplementationRegistrarTest method assertReturnsAppropriateViewModelForInbuiltTasks.

private void assertReturnsAppropriateViewModelForInbuiltTasks(ConfigElementImplementationRegistry registry, Task task, final String taskType) {
    for (String actionName : new String[] { "new", "edit" }) {
        PluggableViewModel viewModelFor = registry.getViewModelFor(task, actionName);
        assertThat(viewModelFor, is(new TaskViewModel(task, String.format("admin/tasks/%s/%s", taskType, actionName))));
    }
}
Also used : PluggableTaskViewModel(com.thoughtworks.go.presentation.PluggableTaskViewModel) TaskViewModel(com.thoughtworks.go.presentation.TaskViewModel) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel)

Example 9 with PluggableViewModel

use of com.thoughtworks.go.plugins.presentation.PluggableViewModel in project gocd by gocd.

the class TaskViewServiceTest method shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn.

@Test
public void shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn() {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    taskClasses.add(FetchPluggableArtifactTask.class);
    when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(true);
    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(4));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new FetchPluggableArtifactTask(), "")));
}
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

PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)9 ExecTask (com.thoughtworks.go.config.ExecTask)8 Test (org.junit.Test)8 AntTask (com.thoughtworks.go.config.AntTask)7 FetchTask (com.thoughtworks.go.config.FetchTask)7 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)5 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)5 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)4 Task (com.thoughtworks.go.domain.Task)4 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1 Configuration (com.thoughtworks.go.domain.config.Configuration)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)1 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)1 PluggableTaskViewModel (com.thoughtworks.go.presentation.PluggableTaskViewModel)1