Search in sources :

Example 26 with ConfigurationProperty

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

the class MaterialsMother method pluggableSCMMaterial.

public static PluggableSCMMaterial pluggableSCMMaterial() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", false, "v2");
    return pluggableSCMMaterial("scm-id", "scm-name", k1, k2);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty)

Example 27 with ConfigurationProperty

use of com.thoughtworks.go.domain.config.ConfigurationProperty 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)

Example 28 with ConfigurationProperty

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

the class PluginProfileCommandTest method shouldValidateIfSecurityAuthConfigIdIsNull.

@Test
public void shouldValidateIfSecurityAuthConfigIdIsNull() {
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig(null, "some-plugin", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
    cruiseConfig.server().security().securityAuthConfigs().add(securityAuthConfig);
    PluginProfileCommand command = new StubSecurityAuthConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
    thrown.expectMessage("some foo object id cannot be null.");
    command.isValid(cruiseConfig);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.Test)

Example 29 with ConfigurationProperty

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

the class ElasticAgentProfileCreateCommandTest method shouldInvokePluginValidationsBeforeSave.

@Test
public void shouldInvokePluginValidationsBeforeSave() throws Exception {
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("key", "error"));
    when(extension.validate(eq("aws"), Matchers.<Map<String, String>>any())).thenReturn(validationResult);
    ElasticProfile newProfile = new ElasticProfile("foo", "aws", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("val")));
    PluginProfileCommand command = new ElasticAgentProfileCreateCommand(mock(GoConfigService.class), newProfile, extension, null, new HttpLocalizedOperationResult());
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    thrown.expect(PluginProfileNotFoundException.class);
    thrown.expectMessage("Elastic agent profile `foo` does not exist.");
    command.isValid(cruiseConfig);
    command.update(cruiseConfig);
    assertThat(newProfile.first().errors().size(), is(1));
    assertThat(newProfile.first().errors().asString(), is("error"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Test(org.junit.Test)

Example 30 with ConfigurationProperty

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

the class ErrorCollectorTest method shouldCollectErrorsWithLabel.

@Test
public void shouldCollectErrorsWithLabel() throws Exception {
    PackageRepository packageRepository = new PackageRepository();
    packageRepository.addError("name", "name is mandatory field");
    packageRepository.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name"), new ConfigurationValue("value")));
    packageRepository.getConfiguration().get(0).getConfigurationKey().addError("name", "url is mandatory field");
    HashMap<String, List<String>> errorsMap = new HashMap<>();
    ErrorCollector.collectFieldErrors(errorsMap, "package_repository", packageRepository);
    List<String> nameErrors = new ArrayList<>();
    nameErrors.add("name is mandatory field");
    assertThat(errorsMap.get("package_repository[name]"), is(nameErrors));
    List<String> urlErrors = new ArrayList<>();
    urlErrors.add("url is mandatory field");
    assertThat(errorsMap.get("package_repository[configuration][0][configurationKey][name]"), is(urlErrors));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)74 Test (org.junit.Test)41 Configuration (com.thoughtworks.go.domain.config.Configuration)28 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)27 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)27 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)20 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)16 Property (com.thoughtworks.go.plugin.api.config.Property)12 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)10 GoCipher (com.thoughtworks.go.security.GoCipher)9 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)8 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)5 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)5 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)4 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 ArrayList (java.util.ArrayList)4