use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnNotMergedInConfigUpdateResponse_WhenConfigIsUpdated.
@Test
public void shouldReturnNotMergedInConfigUpdateResponse_WhenConfigIsUpdated() {
when(goConfigDao.updateConfig(org.mockito.Matchers.<UpdateConfigCommand>any())).thenReturn(ConfigSaveState.UPDATED);
ConfigUpdateResponse configUpdateResponse = goConfigService.updateConfigFromUI(mock(UpdateConfigFromUI.class), "md5", new Username(new CaseInsensitiveString("user")), new HttpLocalizedOperationResult());
assertThat(configUpdateResponse.wasMerged(), is(false));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class GoConfigServiceTest method badConfigShouldContainOldMD5_WhenConfigUpdateFailed.
@Test
public void badConfigShouldContainOldMD5_WhenConfigUpdateFailed() {
when(goConfigDao.updateConfig(org.mockito.Matchers.<UpdateConfigCommand>any())).thenThrow(new RuntimeException(getGoConfigInvalidException()));
ConfigUpdateResponse configUpdateResponse = goConfigService.updateConfigFromUI(mock(UpdateConfigFromUI.class), "old-md5", new Username(new CaseInsensitiveString("user")), new HttpLocalizedOperationResult());
assertThat(configUpdateResponse.wasMerged(), is(false));
assertThat(configUpdateResponse.getCruiseConfig().getMd5(), is("old-md5"));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class GoConfigServiceTest method shouldUpdateResultAsConfigRevisionNotFoundWhenConfigChangeIsNotFound.
@Test
public void shouldUpdateResultAsConfigRevisionNotFoundWhenConfigChangeIsNotFound() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
Localizer localizer = mock(Localizer.class);
when(configRepo.configChangesFor("md5-5", "md5-4")).thenThrow(new IllegalArgumentException("something"));
goConfigService.configChangesFor("md5-5", "md5-4", result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(SC_BAD_REQUEST));
result.message(localizer);
verify(localizer).localize("CONFIG_VERSION_NOT_FOUND", new Object[] {});
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class ElasticProfileServiceTest method shouldPerformPluginValidationsBeforeUpdatingElasticProfile.
@Test
public void shouldPerformPluginValidationsBeforeUpdatingElasticProfile() {
ElasticProfile elasticProfile = new ElasticProfile("ldap", "cd.go.ldap", create("key", false, "value"));
Username username = new Username("username");
elasticProfileService.update(username, "md5", elasticProfile, new HttpLocalizedOperationResult());
verify(elasticAgentExtension).validate(elasticProfile.getPluginId(), elasticProfile.getConfigurationAsMap(true));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class ElasticProfileServiceTest method shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginIdWhileUpdating.
@Test
public void shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginIdWhileUpdating() throws Exception {
ElasticProfile elasticProfile = new ElasticProfile("some-id", "non-existent-plugin", create("key", false, "value"));
Username username = new Username("username");
when(elasticAgentExtension.validate(elasticProfile.getPluginId(), elasticProfile.getConfigurationAsMap(true))).thenThrow(new PluginNotFoundException("some error"));
elasticProfileService.update(username, "md5", elasticProfile, new HttpLocalizedOperationResult());
assertThat(elasticProfile.errors().isEmpty(), Matchers.is(false));
assertThat(elasticProfile.errors().on("pluginId"), Matchers.is("Plugin with id `non-existent-plugin` is not found."));
}
Aggregations