use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ClusterProfileDTO method toDomainModel.
public ClusterProfile toDomainModel() {
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
this.properties.forEach((key, value) -> {
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value)));
});
ClusterProfile clusterProfile = new ClusterProfile(this.id, this.pluginId);
clusterProfile.addConfigurations(configurationProperties);
return clusterProfile;
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ClusterProfilesServiceIntegrationTest method shouldUpdateExistingClusterProfile.
@Test
public void shouldUpdateExistingClusterProfile() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
String clusterId = "cluster1";
String pluginid = "pluginid";
ClusterProfile clusterProfile = new ClusterProfile(clusterId, pluginid);
ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
ClusterProfile newClusterProfile = new ClusterProfile(clusterId, pluginid, property);
clusterProfilesService.create(clusterProfile, new Username("Bob"), new HttpLocalizedOperationResult());
assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(clusterProfile));
clusterProfilesService.update(newClusterProfile, new Username("Bob"), result);
assertThat(result.isSuccessful(), is(true));
assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(newClusterProfile));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileServiceIntegrationTest method shouldUpdateElasticAgentProfile.
@Test
public void shouldUpdateElasticAgentProfile() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
assertThat(elasticProfileService.getPluginProfiles()).hasSize(0);
elasticProfileService.create(username, elasticProfile, result);
assertThat(elasticProfileService.getPluginProfiles()).hasSize(1);
ElasticProfile existing = elasticProfileService.getPluginProfiles().get(0);
assertThat(existing.getConfigWithErrorsAsMap()).isEmpty();
elasticProfileService.update(username, entityHashingService.hashForEntity(this.elasticProfile), newElasticProfile, result);
ElasticProfile updated = elasticProfileService.getPluginProfiles().get(0);
assertThat(updated.getId()).isEqualTo(elasticProfileId);
assertThat(updated.get(0)).isEqualTo(new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileServiceIntegrationTest method setUp.
@BeforeEach
public void setUp() throws Exception {
pluginId = "aws";
clusterProfileId = "prod-cluster";
elasticProfileId = "id";
username = new Username("Bob");
configHelper = new GoConfigFileHelper();
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
clusterProfile = new ClusterProfile(clusterProfileId, pluginId);
elasticProfile = new ElasticProfile(elasticProfileId, clusterProfileId);
newElasticProfile = new ElasticProfile(elasticProfileId, clusterProfileId, new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
goConfigService.updateConfig(cruiseConfig -> {
BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig();
basicCruiseConfig.initializeServer();
ClusterProfiles clusterProfiles = new ClusterProfiles();
clusterProfiles.add(clusterProfile);
basicCruiseConfig.getElasticConfig().setClusterProfiles(clusterProfiles);
return basicCruiseConfig;
});
elasticProfileService.setProfileConfigurationValidator(validator);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class PluginRoleConfigTest method hasErrors_shouldBeTrueIfConfigurationPropertiesHasErrors.
@Test
public void hasErrors_shouldBeTrueIfConfigurationPropertiesHasErrors() throws Exception {
ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
PluginRoleConfig roleConfig = new PluginRoleConfig("admin", "auth_id", property);
property.addError("username", "username format is incorrect");
assertTrue(roleConfig.hasErrors());
assertTrue(roleConfig.errors().isEmpty());
}
Aggregations