Search in sources :

Example 1 with FetchTask

use of com.thoughtworks.go.config.FetchTask 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 FetchTask

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

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

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

the class FetchTaskRepresenter method fetchTaskFromJson.

private static AbstractFetchTask fetchTaskFromJson(JsonReader jsonReader) {
    FetchTask fetchTask = new FetchTask();
    if (jsonReader == null) {
        return fetchTask;
    }
    setBaseTask(jsonReader, fetchTask);
    Optional<Boolean> isSourceAFileValue = jsonReader.optBoolean("is_source_a_file");
    Boolean isSourceAFile = isSourceAFileValue.orElse(false);
    if (isSourceAFile) {
        jsonReader.readStringIfPresent("source", fetchTask::setSrcfile);
    } else {
        jsonReader.readStringIfPresent("source", fetchTask::setSrcdir);
    }
    jsonReader.readStringIfPresent("destination", fetchTask::setDest);
    return fetchTask;
}
Also used : AbstractFetchTask(com.thoughtworks.go.config.AbstractFetchTask) FetchTask(com.thoughtworks.go.config.FetchTask)

Example 5 with FetchTask

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

the class FetchTaskRepresenter method fetchTaskFromJson.

private static AbstractFetchTask fetchTaskFromJson(JsonReader jsonReader) {
    FetchTask fetchTask = new FetchTask();
    if (jsonReader == null) {
        return fetchTask;
    }
    setBaseTask(jsonReader, fetchTask);
    Optional<Boolean> isSourceAFileValue = jsonReader.optBoolean("is_source_a_file");
    Boolean isSourceAFile = isSourceAFileValue.orElse(false);
    if (isSourceAFile) {
        jsonReader.readStringIfPresent("source", fetchTask::setSrcfile);
    } else {
        jsonReader.readStringIfPresent("source", fetchTask::setSrcdir);
    }
    jsonReader.readStringIfPresent("destination", fetchTask::setDest);
    return fetchTask;
}
Also used : AbstractFetchTask(com.thoughtworks.go.config.AbstractFetchTask) FetchTask(com.thoughtworks.go.config.FetchTask)

Aggregations

FetchTask (com.thoughtworks.go.config.FetchTask)6 AbstractFetchTask (com.thoughtworks.go.config.AbstractFetchTask)3 AntTask (com.thoughtworks.go.config.AntTask)3 ExecTask (com.thoughtworks.go.config.ExecTask)3 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)3 Test (org.junit.Test)3 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)1