Search in sources :

Example 1 with RuleAwarePluginProfile

use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.

the class ConfigRepoConfigTest method newPluginProfile.

@Override
protected RuleAwarePluginProfile newPluginProfile(String id, String pluginId, ConfigurationProperty... configurationProperties) {
    RuleAwarePluginProfile profile = new ConfigRepoConfig().setId(id).setPluginId(pluginId);
    profile.addConfigurations(Arrays.asList(configurationProperties));
    ((ConfigRepoConfig) profile).setRepo(new GitMaterialConfig());
    return profile;
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) RuleAwarePluginProfile(com.thoughtworks.go.config.rules.RuleAwarePluginProfile)

Example 2 with RuleAwarePluginProfile

use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.

the class AbstractRuleAwarePluginProfileTest method shouldValidateConfigPropertyNameUniqueness.

@Test
public void shouldValidateConfigPropertyNameUniqueness() throws Exception {
    ConfigurationProperty prop1 = ConfigurationPropertyMother.create("USERNAME");
    ConfigurationProperty prop2 = ConfigurationPropertyMother.create("USERNAME");
    RuleAwarePluginProfile profile = newPluginProfile("docker.unit-test", "cd.go.elastic-agent.docker", prop1, prop2);
    profile.validate(getValidationContext(profile));
    assertThat(profile.errors().size()).isEqualTo(0);
    ConfigurationProperty configProp1 = profile.getConfiguration().get(0);
    ConfigurationProperty configProp2 = profile.getConfiguration().get(1);
    assertThat(configProp1.errors().size()).isEqualTo(1);
    assertThat(configProp2.errors().size()).isEqualTo(1);
    assertThat(configProp1.errors().on("configurationKey")).isEqualTo(format("Duplicate key 'USERNAME' found for %s 'docker.unit-test'", getObjectDescription()));
    assertThat(configProp2.errors().on("configurationKey")).isEqualTo(format("Duplicate key 'USERNAME' found for %s 'docker.unit-test'", getObjectDescription()));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) RuleAwarePluginProfile(com.thoughtworks.go.config.rules.RuleAwarePluginProfile) Test(org.junit.jupiter.api.Test)

Example 3 with RuleAwarePluginProfile

use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.

the class AbstractRuleAwarePluginProfileTest method shouldNotAllowNullPluginIdOrProfileId.

@Test
public void shouldNotAllowNullPluginIdOrProfileId() throws Exception {
    RuleAwarePluginProfile profile = newPluginProfile(null, null);
    profile.validate(getValidationContext(profile));
    assertThat(profile.errors().size()).isEqualTo(2);
    assertThat(profile.errors().on("pluginId")).isEqualTo(format("%s cannot have a blank plugin id.", getObjectDescription()));
    assertThat(profile.errors().on("id")).isEqualTo(format("%s cannot have a blank id.", getObjectDescription()));
}
Also used : RuleAwarePluginProfile(com.thoughtworks.go.config.rules.RuleAwarePluginProfile) Test(org.junit.jupiter.api.Test)

Example 4 with RuleAwarePluginProfile

use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.

the class AbstractRuleAwarePluginProfileTest method shouldValidatePluginIdPattern.

@Test
public void shouldValidatePluginIdPattern() throws Exception {
    RuleAwarePluginProfile profile = newPluginProfile("!123", "docker");
    profile.validate(getValidationContext(profile));
    assertThat(profile.errors().size()).isEqualTo(1);
    assertThat(profile.errors().on("id")).isEqualTo("Invalid id '!123'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters.");
}
Also used : RuleAwarePluginProfile(com.thoughtworks.go.config.rules.RuleAwarePluginProfile) Test(org.junit.jupiter.api.Test)

Aggregations

RuleAwarePluginProfile (com.thoughtworks.go.config.rules.RuleAwarePluginProfile)4 Test (org.junit.jupiter.api.Test)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)1