use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class RoleConfigurationValidatorTest method shouldAddConfigurationAndMapErrorsInAbsenceOfConfiguration.
@Test
public void shouldAddConfigurationAndMapErrorsInAbsenceOfConfiguration() throws Exception {
ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
PluginRoleConfig roleConfig = new PluginRoleConfig("admin", "auth_id", property);
ValidationResult result = new ValidationResult();
result.addError(new ValidationError("password", "password is required"));
when(extension.validateRoleConfiguration("pluginId", Collections.singletonMap("username", "view"))).thenReturn(result);
validator.validate(roleConfig, "pluginId");
assertTrue(roleConfig.hasErrors());
assertThat(roleConfig.getProperty("password").errors().get("password").get(0), is("password is required"));
assertNull(roleConfig.getProperty("password").getValue());
}
Aggregations