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()));
}
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]"));
}
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]"));
}
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")));
}
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)));
}
Aggregations