use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfilesServiceIntegrationTest method shouldCreateANewClusterProfile.
@Test
public void shouldCreateANewClusterProfile() throws Exception {
String clusterId = "cluster1";
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
ClusterProfile clusterProfile = new ClusterProfile(clusterId, "pluginid");
assertThat(clusterProfilesService.getPluginProfiles().size(), is(0));
clusterProfilesService.create(clusterProfile, new Username("Bob"), result);
assertThat(result.isSuccessful(), is(true));
assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(clusterProfile));
}
use of com.thoughtworks.go.config.elastic.ClusterProfile 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.config.elastic.ClusterProfile in project gocd by gocd.
the class AddClusterProfileCommandTest method setUp.
@BeforeEach
void setUp() {
config = new BasicCruiseConfig();
clusterProfile = new ClusterProfile("cluster-id", "plugin-id");
username = new Username("Bob");
result = new HttpLocalizedOperationResult();
command = new AddClusterProfileCommand(extension, goConfigService, clusterProfile, username, result);
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class PluginProfilesServiceTest method shouldAddExceptionsThrownByPluginInfraErrorOnPluginProfile.
@Test
void shouldAddExceptionsThrownByPluginInfraErrorOnPluginProfile() {
ClusterProfile pluginProfile = new ClusterProfile();
String errorMessage = "Plugin is missing!";
Mockito.when(command.validateUsingExtension(any(), anyMap())).thenThrow(new GoPluginFrameworkException(errorMessage));
assertThat(pluginProfile.hasErrors()).isFalse();
service.validatePluginProperties(command, pluginProfile);
assertThat(pluginProfile.hasErrors()).isTrue();
assertThat(pluginProfile.errors().get("pluginId")).isEqualTo(Arrays.asList(errorMessage));
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class PluginProfilesServiceTest method shouldAddNotFoundExceptionsThrownOnPluginProfile.
@Test
void shouldAddNotFoundExceptionsThrownOnPluginProfile() {
ClusterProfile pluginProfile = new ClusterProfile("foo", "plugin-id");
String errorMessage = "Plugin with id `plugin-id` is not found.";
Mockito.when(command.validateUsingExtension(any(), anyMap())).thenThrow(new RecordNotFoundException("Boom!"));
assertThat(pluginProfile.hasErrors()).isFalse();
service.validatePluginProperties(command, pluginProfile);
assertThat(pluginProfile.hasErrors()).isTrue();
assertThat(pluginProfile.errors().get("pluginId")).isEqualTo(Arrays.asList(errorMessage));
}
Aggregations