use of com.thoughtworks.go.config.AntTask 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.config.AntTask in project gocd by gocd.
the class AntTaskRepresenter method fromJSON.
public static AntTask fromJSON(JsonReader jsonReader) {
AntTask antTask = new AntTask();
if (jsonReader == null) {
return antTask;
}
BaseTaskRepresenter.fromJSON(jsonReader, antTask);
jsonReader.readStringIfPresent("working_directory", antTask::setWorkingDirectory);
jsonReader.readStringIfPresent("build_file", antTask::setBuildFile);
jsonReader.readStringIfPresent("target", antTask::setTarget);
return antTask;
}
use of com.thoughtworks.go.config.AntTask in project gocd by gocd.
the class AntTaskBuilderTest method shouldReturnBuilderWithCancelBuilderIfOnCancelDefined.
@Test
void shouldReturnBuilderWithCancelBuilderIfOnCancelDefined() {
ExecTask cancelTask = new ExecTask();
Builder builderForCancelTask = execTaskBuilder.createBuilder(builderFactory, cancelTask, pipeline, resolver);
AntTask antTask = new AntTask();
antTask.setCancelTask(cancelTask);
when(builderFactory.builderFor(cancelTask, pipeline, resolver)).thenReturn(builderForCancelTask);
Builder expected = expectedBuilder(antTask, builderForCancelTask);
Builder actualBuilder = antTaskBuilder.createBuilder(builderFactory, antTask, pipeline, resolver);
assertThat(actualBuilder).isEqualTo(expected);
}
use of com.thoughtworks.go.config.AntTask in project gocd by gocd.
the class PluggableTaskTest method shouldReturnFalseWhenPluggableTaskIsComparedWithAnyOtherTask.
@Test
public void shouldReturnFalseWhenPluggableTaskIsComparedWithAnyOtherTask() {
PluginConfiguration pluginConfiguration = new PluginConfiguration("test-plugin-1", "1.0");
PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, new Configuration());
AntTask antTask = new AntTask();
assertFalse(pluggableTask.hasSameTypeAs(antTask));
}
use of com.thoughtworks.go.config.AntTask in project gocd by gocd.
the class PipelineBean method getTasks.
public Tasks getTasks() {
Tasks tasks = new Tasks();
if ("ant".equals(builder)) {
AntTask antTask = new AntTask();
antTask.setTarget(this.target);
antTask.setBuildFile(defaultString(StringUtils.isBlank(this.buildfile) ? "build.xml" : this.buildfile));
tasks.add(antTask);
} else if ("nant".equals(builder)) {
NantTask nantTask = new NantTask();
nantTask.setTarget(this.target);
nantTask.setBuildFile(defaultString(StringUtils.isBlank(this.buildfile) ? "default.build" : this.buildfile));
tasks.add(nantTask);
} else if ("rake".equals(builder)) {
RakeTask rakeTask = new RakeTask();
rakeTask.setTarget(this.target);
rakeTask.setBuildFile(StringUtils.isBlank(this.buildfile) ? null : this.buildfile);
tasks.add(rakeTask);
} else if ("exec".equals(builder)) {
String trimmedCommand = StringUtils.defaultString(this.command).trim();
String trimmedArguments = StringUtils.defaultString(this.arguments).trim();
ExecTask execTask = new ExecTask(trimmedCommand, trimmedArguments, (String) null);
tasks.add(execTask);
}
return tasks;
}
Aggregations