use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class SCMsTest method shouldDetermineIfAddingAnSCMWouldCreateDuplication.
@Test
void shouldDetermineIfAddingAnSCMWouldCreateDuplication() {
Configuration config = new Configuration();
config.addNewConfigurationWithValue("url", "url", false);
PluginConfiguration pluginConfig = new PluginConfiguration("plugin_id", "1.0");
SCM scm1 = new SCM("scmid", pluginConfig, config);
scm1.setName("noName");
SCMs scms = new SCMs(scm1);
SCM scm2 = new SCM("scmid", new PluginConfiguration(), new Configuration());
SCM scm3 = new SCM("id", pluginConfig, config);
SCM scm4 = new SCM("something", new PluginConfiguration(), new Configuration());
scm4.setName("noName");
SCM scm5 = new SCM("arbitrary", new PluginConfiguration(), new Configuration());
scm5.setName("aRandomName");
assertThat(scms.canAdd(scm2)).isFalse();
assertThat(scms.canAdd(scm3)).isFalse();
assertThat(scms.canAdd(scm4)).isFalse();
assertThat(scms.canAdd(scm5)).isTrue();
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class SCMMother method create.
public static SCM create(String id, String name, String pluginId, String pluginVersion, Configuration configuration) {
SCM scm = new SCM();
scm.setId(id);
scm.setName(name);
scm.setPluginConfiguration(new PluginConfiguration(pluginId, pluginVersion));
scm.setConfiguration(configuration);
return scm;
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class ConfigConverterTest method shouldFailToConvertConfigMaterialWhenPluggableScmMaterialWithWhitelist.
@Test
public void shouldFailToConvertConfigMaterialWhenPluggableScmMaterialWithWhitelist() {
SCM myscm = new SCM("scmid", new PluginConfiguration(), new Configuration());
SCMs scms = new SCMs(myscm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
PluggableSCMMaterialConfig configRepoMaterial = new PluggableSCMMaterialConfig(new CaseInsensitiveString("scmid"), myscm, null, null);
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", new CRFilter(filter, true));
try {
configConverter.toMaterialConfig(crConfigMaterial, context);
fail("should have thrown");
} catch (ConfigConvertionException ex) {
assertThat(ex.getMessage(), is("Plugable SCMs do not support whitelisting"));
}
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PackageRepositoryTest method createPackageRepository.
private PackageRepository createPackageRepository(String pluginId, String version, String id, String name, Configuration configuration, Packages packages) {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setConfiguration(configuration);
packageRepository.setPackages(packages);
packageRepository.setPluginConfiguration(new PluginConfiguration(pluginId, version));
packageRepository.setId(id);
packageRepository.setName(name);
return packageRepository;
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskServiceTest method shouldValidateMandatoryFields.
@Test
public void shouldValidateMandatoryFields() {
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
PluggableTask modifiedTask = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
ValidationResult validationResult = new ValidationResult();
when(taskExtension.validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class))).thenReturn(validationResult);
when(localizer.localize("MANDATORY_CONFIGURATION_FIELD")).thenReturn("MANDATORY_CONFIGURATION_FIELD");
pluggableTaskService.validate(modifiedTask);
final List<ValidationError> validationErrors = validationResult.getErrors();
assertFalse(validationErrors.isEmpty());
final ValidationError validationError = validationErrors.stream().filter(new Predicate<ValidationError>() {
@Override
public boolean test(ValidationError item) {
return ((ValidationError) item).getKey().equals("KEY1");
}
}).findFirst().orElse(null);
assertNotNull(validationError);
assertThat(validationError.getMessage(), is("MANDATORY_CONFIGURATION_FIELD"));
}
Aggregations