use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class PipelineConfigErrorCopier method copyErrors.
static void copyErrors(PipelineConfig from, PipelineConfig to) {
copy(from, to);
copyCollectionErrors(from.materialConfigs(), to.materialConfigs());
copyCollectionErrors(from.getVariables(), to.getVariables());
copyCollectionErrors(from.getParams(), to.getParams());
copy(from.getTrackingTool(), to.getTrackingTool());
copy(from.getTimer(), to.getTimer());
for (StageConfig toStage : to.getStages()) {
StageConfig fromStage = from.findBy(toStage.name());
copy(fromStage, toStage);
copyCollectionErrors(fromStage.getVariables(), toStage.getVariables());
copy(fromStage.getApproval(), toStage.getApproval());
copyCollectionErrors(fromStage.getApproval().getAuthConfig(), toStage.getApproval().getAuthConfig());
for (JobConfig toJob : toStage.getJobs()) {
JobConfig fromJob = fromStage.jobConfigByConfigName(toJob.name());
copy(fromJob, toJob);
copyCollectionErrors(fromJob.getTasks(), toJob.getTasks());
copyCollectionErrors(fromJob.artifactConfigs(), toJob.artifactConfigs());
copyCollectionErrors(fromJob.getTabs(), toJob.getTabs());
copyCollectionErrors(fromJob.getProperties(), toJob.getProperties());
copyCollectionErrors(fromJob.getVariables(), toJob.getVariables());
Tasks toTasks = toJob.getTasks();
Tasks fromTasks = fromJob.getTasks();
copyCollectionErrors(fromTasks, toTasks);
for (int i = 0; i < toTasks.size(); i++) {
Task fromTask = fromTasks.get(i);
Task toTask = toTasks.get(i);
copy(fromTask, toTask);
copyCollectionErrors(fromTask.getConditions(), toTask.getConditions());
if (toTask instanceof ExecTask) {
copyCollectionErrors(((ExecTask) fromTask).getArgList(), ((ExecTask) toTask).getArgList());
}
}
}
}
}
use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class BuilderFactoryTest method shouldFailIfCalledWithSomeRandomTypeOfTask.
@Test
public void shouldFailIfCalledWithSomeRandomTypeOfTask() {
Task task = someRandomNonStandardTask();
try {
Pipeline pipeline = PipelineMother.pipeline("pipeline1", StageMother.custom("stage1"));
builderFactory.builderFor(task, pipeline, pipelineResolver);
} catch (RuntimeException e) {
assertThat(e.getMessage(), is("Unexpected type of task: " + task.getClass()));
}
}
use of com.thoughtworks.go.domain.Task in project gocd by gocd.
the class TaskViewServiceTest method shouldNotGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOff.
@Test
public void shouldNotGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOff() {
List<Class<? extends Task>> taskClasses = taskImplementations();
taskClasses.add(FetchPluggableArtifactTask.class);
when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(false);
when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
when(registry.getViewModelFor(new FetchPluggableArtifactTask(), "new")).thenReturn(viewModel(new FetchPluggableArtifactTask()));
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) new TaskViewModel(new ExecTask(), "")));
assertThat(taskViewModels.indexOf(viewModel(new FetchPluggableArtifactTask())), is(-1));
}
use of com.thoughtworks.go.domain.Task 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.domain.Task in project gocd by gocd.
the class TaskViewServiceTest method shouldThrowAnExceptionIfTheTaskOfGivenTypeIsNotFound.
@Test
public void shouldThrowAnExceptionIfTheTaskOfGivenTypeIsNotFound() {
ConfigElementImplementationRegistry registry = this.registry;
List<Class<? extends Task>> taskClasses = new ArrayList<>();
taskClasses.add(AntTask.class);
when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
TaskViewService service = new TaskViewService(registry, mock(PluginManager.class));
try {
service.taskInstanceFor("Unknown");
fail("Should have failed since the given task is not available in the registry");
} catch (RuntimeException e) {
assertThat(e.getMessage(), is("Could not find any task of type: Unknown"));
}
}
Aggregations