use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskServiceTest method shouldValidateTask.
@Test
public void shouldValidateTask() {
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
PluggableTask modifiedTask = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("KEY1", "error message"));
when(taskExtension.validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class))).thenReturn(validationResult);
pluggableTaskService.validate(modifiedTask);
assertThat(modifiedTask.getConfiguration().getProperty("KEY1").errors().isEmpty(), is(false));
assertThat(modifiedTask.getConfiguration().getProperty("KEY1").errors().firstError(), is("error message"));
verify(taskExtension).validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class MergeCruiseConfigTest method shouldHaveValidationErrorsForDuplicateValidSCMs.
@Test
public void shouldHaveValidationErrorsForDuplicateValidSCMs() {
BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2");
ConfigRepoConfig repoConfig1 = ConfigRepoConfig.createConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url1"), "plugin", "id-1");
ConfigRepoConfig repoConfig2 = ConfigRepoConfig.createConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url2"), "plugin", "id-2");
cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig1, repoConfig2));
PartialConfig partialConfigInRepo1 = PartialConfigMother.withSCM("scmid", "name", new PluginConfiguration("plugin_id", "1"), new Configuration(), new FileConfigOrigin());
RepoConfigOrigin configOrigin = new RepoConfigOrigin(repoConfig2, "repo2_r1");
PartialConfig partialConfigInRepo2 = PartialConfigMother.withSCM("scmid", "name", new PluginConfiguration("plugin_id", "1"), new Configuration(), configOrigin);
cruiseConfig.merge(new ArrayList<>(Arrays.asList(partialConfigInRepo2, partialConfigInRepo1)), false);
assertThat(cruiseConfig.getSCMs().size(), is(2));
assertThat(cruiseConfig.validateAfterPreprocess().size(), is(2));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class MergeCruiseConfigTest method shouldOnlyMergeLocalSCMsWhenEditIsTrue.
@Test
public void shouldOnlyMergeLocalSCMsWhenEditIsTrue() {
BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2");
ConfigRepoConfig repoConfig1 = ConfigRepoConfig.createConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url1"), "plugin", "id-1");
cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig1));
RepoConfigOrigin configOrigin = new RepoConfigOrigin(repoConfig1, "repo1_r1");
PartialConfig completeSCM = PartialConfigMother.withSCM("scmid", "name", new PluginConfiguration("plugin_id", "1"), new Configuration(), configOrigin);
PartialConfig localSCM = PartialConfigMother.withSCM("local_id", "local", new PluginConfiguration("plugin_id2", "1"), new Configuration(), new FileConfigOrigin());
cruiseConfig.merge(new ArrayList<>(Arrays.asList(localSCM, completeSCM)), true);
assertThat(cruiseConfig.getSCMs().size(), is(1));
assertThat(cruiseConfig.getSCMs().contains(localSCM.getScms().first()), is(true));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfOnCancelTasksHasErrors.
@Test
public void validateTreeShouldVerifyIfOnCancelTasksHasErrors() {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
pluggableTask.onCancelConfig = mock(OnCancelConfig.class);
com.thoughtworks.go.domain.Task cancelTask = mock(com.thoughtworks.go.domain.Task.class);
when(pluggableTask.onCancelConfig.getTask()).thenReturn(cancelTask);
when(cancelTask.hasCancelTask()).thenReturn(false);
when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(false);
assertFalse(pluggableTask.validateTree(null));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method isValidShouldVerifyIfPluginIdIsValid.
@Test
public void isValidShouldVerifyIfPluginIdIsValid() {
PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
Configuration configuration = new Configuration();
PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
pluggableTask.isValid();
assertThat(pluggableTask.errors().get("pluggable_task").get(0), is("Could not find plugin for given pluggable id:[does_not_exist]."));
}
Aggregations