Search in sources :

Example 46 with Configuration

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"));
    }
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 47 with Configuration

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);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration)

Example 48 with Configuration

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));
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 49 with Configuration

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")));
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) TransactionStatus(org.springframework.transaction.TransactionStatus) Matchers.containsString(org.hamcrest.Matchers.containsString) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) TransactionCallback(org.springframework.transaction.support.TransactionCallback) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) Test(org.junit.Test)

Example 50 with Configuration

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()));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Configuration(com.thoughtworks.go.domain.config.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PluggableSCMMaterialInstance(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)136 Test (org.junit.Test)114 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)97 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)29 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)20 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)17 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)17 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)15 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)14 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)12 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)11 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)11 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)10 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)9