Search in sources :

Example 1 with TaskViewModel

use of com.thoughtworks.go.presentation.TaskViewModel 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) 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 2 with TaskViewModel

use of com.thoughtworks.go.presentation.TaskViewModel 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) 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 3 with TaskViewModel

use of com.thoughtworks.go.presentation.TaskViewModel 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 4 with TaskViewModel

use of com.thoughtworks.go.presentation.TaskViewModel in project gocd by gocd.

the class ConfigElementImplementationRegistryTest method shouldCreateTaskViewModelForPlugins.

@Test
public void shouldCreateTaskViewModelForPlugins() 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);
    PluginExec execInstance = new PluginExec();
    TaskViewModel stubbedViewModel = new TaskViewModel(execInstance, "my/view");
    when(factory.viewModelFor(execInstance, "new")).thenReturn(stubbedViewModel);
    ConfigurationExtension execTask = new ConfigurationExtension<>(new PluginNamespace(execCtx, new URL("file:///exec")), exec);
    when(pluginExtns.configTagImplementations()).thenReturn(Arrays.asList(execTask));
    ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(pluginExtns);
    assertThat(registry.getViewModelFor(execInstance, "new"), is(stubbedViewModel));
}
Also used : TaskViewModel(com.thoughtworks.go.presentation.TaskViewModel) URL(java.net.URL) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)4 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)3 Test (org.junit.Test)3 AntTask (com.thoughtworks.go.config.AntTask)2 ExecTask (com.thoughtworks.go.config.ExecTask)2 FetchTask (com.thoughtworks.go.config.FetchTask)2 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)2 Task (com.thoughtworks.go.domain.Task)2 PluggableTaskViewModel (com.thoughtworks.go.presentation.PluggableTaskViewModel)1 URL (java.net.URL)1 BundleContext (org.osgi.framework.BundleContext)1