use of com.thoughtworks.go.config.ExecTask 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.ExecTask in project gocd by gocd.
the class ExecTaskTest method shouldUseConfiguredWorkingDirectory.
@Test
public void shouldUseConfiguredWorkingDirectory() throws Exception {
File absoluteFile = new File("test").getAbsoluteFile();
ExecTask task = new ExecTask("command", "arguments", absoluteFile.getAbsolutePath());
assertThat(task.workingDirectory(), Matchers.is(absoluteFile.getPath()));
}
use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.
the class ExecTaskTest method shouldSupportMultipleArgs.
@Test
public void shouldSupportMultipleArgs() throws Exception {
String xml = "<exec command='ls'>\n" + " <arg>arg1</arg>\n" + " <arg>arg2</arg>\n" + "</exec>";
ExecTask execTask = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).fromXmlPartial(xml, ExecTask.class);
assertThat(execTask.getArgList(), is(new Arguments(new Argument("arg1"), new Argument("arg2"))));
}
use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.
the class BuilderMother method createBuildersAssumingAllExecTasks.
public static List<Builder> createBuildersAssumingAllExecTasks(CruiseConfig config, String pipelineName, String stageName, String jobName) {
Tasks tasks = config.jobConfigByName(pipelineName, stageName, jobName, true).getTasks();
ArrayList<Builder> builders = new ArrayList<>();
for (Task task : tasks) {
builders.add(builderFor((ExecTask) task));
}
return builders;
}
use of com.thoughtworks.go.config.ExecTask 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