use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class SCMTest method shouldThrowUpOnSetConfigAttributesIfPluginIsNotAvailable.
@Test
public void shouldThrowUpOnSetConfigAttributesIfPluginIsNotAvailable() throws Exception {
try {
Map<String, String> attributeMap = DataStructureUtils.m(SCM.SCM_ID, "scm-id", SCM.NAME, "scm-name", SCM.AUTO_UPDATE, "false", "url", "http://localhost");
SCM scm = new SCM(null, new PluginConfiguration("plugin-id", "1"), new Configuration());
scm.setConfigAttributes(attributeMap);
fail("should have thrown exception");
} catch (Exception e) {
assertThat(e, instanceOf(RuntimeException.class));
assertThat(e.getMessage(), is("metadata unavailable for plugin: plugin-id"));
}
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class XmlPartialConfigProvider method getFiles.
public File[] getFiles(File configRepoCheckoutDirectory, PartialConfigLoadContext context) {
String pattern = defaultPattern;
Configuration configuration = context.configuration();
if (configuration != null) {
ConfigurationProperty explicitPattern = configuration.getProperty("pattern");
if (explicitPattern != null) {
pattern = explicitPattern.getValue();
}
}
return getFiles(configRepoCheckoutDirectory, pattern);
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPackageMaterial.
@Test
public void shouldConvertPackageMaterial() {
PackageRepositories repositories = new PackageRepositories();
PackageRepository packageRepository = new PackageRepository();
PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
packageRepository.addPackage(definition);
repositories.add(packageRepository);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setPackageRepositories(repositories);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
CRPackageMaterial crPackageMaterial = new CRPackageMaterial("name", "package-id");
PackageMaterialConfig packageMaterialConfig = (PackageMaterialConfig) configConverter.toMaterialConfig(crPackageMaterial, context);
assertThat(packageMaterialConfig.getName().toLower(), is("name"));
assertThat(packageMaterialConfig.getPackageId(), is("package-id"));
assertThat(packageMaterialConfig.getPackageDefinition(), is(definition));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class ScheduledPipelineLoaderIntegrationTest method shouldUpdatePackageMaterialConfigurationOfMaterialsOnPipeline.
@Test
public void shouldUpdatePackageMaterialConfigurationOfMaterialsOnPipeline() throws Exception {
String jobName = "job-one";
PipelineConfig pipelineConfig = setupPipelineWithPackageMaterial("pipeline_with_pluggable_scm_mat", "stage", jobName);
final Pipeline previousSuccessfulBuildWithOlderPackageConfig = simulateSuccessfulPipelineRun(pipelineConfig);
PipelineConfig updatedPipelineConfig = configHelper.updatePipeline(pipelineConfig.name(), new GoConfigFileHelper.Updater<PipelineConfig>() {
@Override
public void update(PipelineConfig config) {
PackageMaterialConfig materialConfig = (PackageMaterialConfig) config.materialConfigs().first();
materialConfig.getPackageDefinition().getConfiguration().getProperty("package-key2").setConfigurationValue(new ConfigurationValue("package-updated-value"));
materialConfig.getPackageDefinition().getRepository().getConfiguration().getProperty("repo-key2").setConfigurationValue(new ConfigurationValue("repo-updated-value"));
}
});
final long jobId = rerunJob(jobName, pipelineConfig, previousSuccessfulBuildWithOlderPackageConfig);
Pipeline loadedPipeline = (Pipeline) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
return loader.pipelineWithPasswordAwareBuildCauseByBuildId(jobId);
}
});
MaterialRevisions revisions = loadedPipeline.getBuildCause().getMaterialRevisions();
PackageMaterial updatedMaterial = (PackageMaterial) revisions.findRevisionFor(updatedPipelineConfig.materialConfigs().first()).getMaterial();
Configuration updatedConfiguration = updatedMaterial.getPackageDefinition().getConfiguration();
assertThat(updatedConfiguration.size(), is(2));
assertThat(updatedConfiguration.getProperty("package-key2").getConfigurationValue(), is(new ConfigurationValue("package-updated-value")));
assertThat(updatedMaterial.getPackageDefinition().getRepository().getConfiguration().size(), is(2));
assertThat(updatedMaterial.getPackageDefinition().getRepository().getConfiguration().getProperty("repo-key2").getConfigurationValue(), is(new ConfigurationValue("repo-updated-value")));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldSavePluggableSCMMaterialInstance.
@Test
public void shouldSavePluggableSCMMaterialInstance() {
PluggableSCMMaterial material = new PluggableSCMMaterial();
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", true, "v2");
material.setSCMConfig(SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(k1, k2)));
PluggableSCMMaterialInstance savedMaterialInstance = (PluggableSCMMaterialInstance) repo.findOrCreateFrom(material);
assertThat(savedMaterialInstance.getId() > 0, is(true));
assertThat(savedMaterialInstance.getFingerprint(), is(material.getFingerprint()));
assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PluggableSCMMaterial.class).getScmConfig().getConfiguration(), is(material.getScmConfig().getConfiguration()));
assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PluggableSCMMaterial.class).getScmConfig().getPluginConfiguration().getId(), is(material.getScmConfig().getPluginConfiguration().getId()));
}
Aggregations