Search in sources :

Example 51 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method shouldSavePackageMaterialInstance.

@Test
public void shouldSavePackageMaterialInstance() {
    PackageMaterial material = new PackageMaterial();
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
    material.setPackageDefinition(PackageDefinitionMother.create("p-id", "name", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2")), repository));
    PackageMaterialInstance savedMaterialInstance = (PackageMaterialInstance) repo.findOrCreateFrom(material);
    assertThat(savedMaterialInstance.getId() > 0, is(true));
    assertThat(savedMaterialInstance.getFingerprint(), is(material.getFingerprint()));
    assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PackageMaterial.class).getPackageDefinition().getConfiguration(), is(material.getPackageDefinition().getConfiguration()));
    assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PackageMaterial.class).getPackageDefinition().getRepository().getPluginConfiguration().getId(), is(material.getPackageDefinition().getRepository().getPluginConfiguration().getId()));
    assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PackageMaterial.class).getPackageDefinition().getRepository().getConfiguration(), is(material.getPackageDefinition().getRepository().getConfiguration()));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) PackageMaterialInstance(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance) Test(org.junit.Test)

Example 52 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PackageDefinitionTest method shouldConvertKeysToLowercaseInGetConfigForDisplay.

@Test
public void shouldConvertKeysToLowercaseInGetConfigForDisplay() throws Exception {
    RepositoryMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "some-plugin", "version", new Configuration(create("rk1", false, "rv1")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pack_key_1", false, "pack_value_1"), create("PACK_KEY_2", false, "PACK_VALUE_2"), create("pacK_KeY3", false, "pacKValue_3")), repository);
    packageDefinition.setRepository(repository);
    assertThat(packageDefinition.getConfigForDisplay(), is("Repository: [rk1=rv1] - Package: [pack_key_1=pack_value_1, pack_key_2=PACK_VALUE_2, pack_key3=pacKValue_3]"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 53 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PackageDefinitionTest method shouldNotDisplayEmptyValuesInGetConfigForDisplay.

@Test
public void shouldNotDisplayEmptyValuesInGetConfigForDisplay() throws Exception {
    RepositoryMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "some-plugin", "version", new Configuration(create("rk1", false, "rv1")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pk1", false, ""), create("pk2", false, "pack_value_2"), create("pk3", false, null)), repository);
    packageDefinition.setRepository(repository);
    assertThat(packageDefinition.getConfigForDisplay(), is("Repository: [rk1=rv1] - Package: [pk2=pack_value_2]"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 54 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PackageDefinitionTest method shouldNotConsiderPropertiesMarkedAsNotPartOfIdentity_GetFingerprint.

@Test
public void shouldNotConsiderPropertiesMarkedAsNotPartOfIdentity_GetFingerprint() {
    String pluginId = "plugin-id";
    PackageConfigurations repositoryConfigurations = new PackageConfigurations();
    repositoryConfigurations.add(new PackageConfiguration("rk1", "rv1").with(PackageConfiguration.PART_OF_IDENTITY, true));
    repositoryConfigurations.add(new PackageConfiguration("rk2", "rv2").with(PackageConfiguration.PART_OF_IDENTITY, false));
    RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, repositoryConfigurations);
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.add(new PackageConfiguration("pk1", "pv1").with(PackageConfiguration.PART_OF_IDENTITY, false));
    packageConfigurations.add(new PackageConfiguration("pk2", "pv2").with(PackageConfiguration.PART_OF_IDENTITY, true));
    PackageMetadataStore.getInstance().addMetadataFor(pluginId, packageConfigurations);
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", pluginId, "version", new Configuration(create("rk1", false, "rv1"), create("rk2", false, "rv2")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pk1", false, "pv1"), create("pk2", false, "pv2")), repository);
    String fingerprint = packageDefinition.getFingerprint(AbstractMaterial.FINGERPRINT_DELIMITER);
    assertThat(fingerprint, is(CachedDigestUtils.sha256Hex("plugin-id=plugin-id<|>pk2=pv2<|>rk1=rv1")));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 55 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PackageDefinitionTest method shouldCheckForEqualityOfPackageDefinition.

@Test
public void shouldCheckForEqualityOfPackageDefinition() {
    Configuration configuration = new Configuration();
    PackageDefinition packageDefinition = new PackageDefinition("id", "name", configuration);
    assertThat(packageDefinition, is(new PackageDefinition("id", "name", configuration)));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) 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