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