use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PackageRepositoryServiceTest method shouldAddErrorWhenPluginIdIsInvalid.
@Test
void shouldAddErrorWhenPluginIdIsInvalid() {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setPluginConfiguration(new PluginConfiguration("missing-plugin", "1.0"));
service.performPluginValidationsFor(packageRepository);
assertThat(packageRepository.getPluginConfiguration().errors().getAllOn(PluginConfiguration.ID)).isEqualTo(Arrays.asList("Invalid plugin id"));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableScmServiceTest method shouldHandleIncorrectKeyForValidateSCM.
@Test
public void shouldHandleIncorrectKeyForValidateSCM() {
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("NON-EXISTENT-KEY", "error message"));
when(scmExtension.isSCMConfigurationValid(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(validationResult);
pluggableScmService.validate(modifiedSCM);
assertTrue(modifiedSCM.errors().isEmpty());
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskServiceTest method isValidShouldValidateThePluggableTask.
@Test
public void isValidShouldValidateThePluggableTask() {
PluggableTask pluggableTask = mock(PluggableTask.class);
PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin_id", "version");
when(pluggableTask.isValid()).thenReturn(true);
when(pluggableTask.toTaskConfig()).thenReturn(new TaskConfig());
when(pluggableTask.getPluginConfiguration()).thenReturn(pluginConfiguration);
when(taskExtension.validate(any(String.class), any(TaskConfig.class))).thenReturn(new ValidationResult());
assertTrue(pluggableTaskService.isValid(pluggableTask));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskServiceTest method isValidShouldMapPluginValidationErrorsToPluggableTaskForMissingConfigurations.
@Test
public void isValidShouldMapPluginValidationErrorsToPluggableTaskForMissingConfigurations() {
PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin_id", "version");
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("source", "source is mandatory"));
PluggableTask pluggableTask = mock(PluggableTask.class);
when(pluggableTask.isValid()).thenReturn(true);
when(pluggableTask.toTaskConfig()).thenReturn(new TaskConfig());
when(pluggableTask.getPluginConfiguration()).thenReturn(pluginConfiguration);
when(pluggableTask.getConfiguration()).thenReturn(new Configuration());
when(taskExtension.validate(any(String.class), any(TaskConfig.class))).thenReturn(validationResult);
assertFalse(pluggableTaskService.isValid(pluggableTask));
verify(pluggableTask).addError("source", "source is mandatory");
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PartialConfigServiceIntegrationTest method shouldSaveSCMs.
@Test
public void shouldSaveSCMs() {
Configuration config = new Configuration();
config.addNewConfigurationWithValue("url", "url", false);
PluginConfiguration pluginConfig = new PluginConfiguration("plugin.id", "1.0");
RepoConfigOrigin origin = new RepoConfigOrigin(repoConfig1, "124");
PartialConfig scmPartial = PartialConfigMother.withSCM("scm_id", "name", pluginConfig, config, origin);
partialConfigService.onSuccessPartialConfig(repoConfig1, scmPartial);
SCMs scms = goConfigDao.loadConfigHolder().config.getSCMs();
SCM expectedSCM = new SCM("scm_id", pluginConfig, config);
expectedSCM.setOrigins(origin);
expectedSCM.setName("name");
assertThat(scms.size(), is(1));
assertThat(scms.first(), is(expectedSCM));
assertThat(cacheContainsPartial(cachedGoPartials.lastKnownPartials(), scmPartial), is(true));
}
Aggregations