use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class ScheduleServiceTest method shouldNotCancelStageIfItsNotActive.
@Test
public void shouldNotCancelStageIfItsNotActive() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
Pipeline pipeline = PipelineMother.pipeline("pipeline-name", StageMother.passedStageInstance("mingle", "job-bar", "pipeline-name"));
Stage firstStage = pipeline.getFirstStage();
long stageId = firstStage.getId();
Username admin = new Username(new CaseInsensitiveString("admin"));
when(stageService.stageById(stageId)).thenReturn(firstStage);
Stage resultStage = service.cancelAndTriggerRelevantStages(stageId, admin, result);
assertThat(resultStage, is(firstStage));
assertThat(result.httpCode(), is(SC_OK));
assertThat(result.isSuccessful(), is(true));
assertThat(result.hasMessage(), is(true));
Localizer localizer = mock(Localizer.class);
String respMsg = "Stage is not active. Cancellation Ignored";
String stageNotActiveKey = "STAGE_IS_NOT_ACTIVE_FOR_CANCELLATION";
when(localizer.localize(eq(stageNotActiveKey), anyVararg())).thenReturn(respMsg);
assertThat(result.message(localizer), is(respMsg));
verify(stageService).stageById(stageId);
verify(localizer).localize(eq(stageNotActiveKey), anyVararg());
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class SecurityAuthConfigServiceTest method shouldPerformPluginValidationsBeforeAddingSecurityAuthConfig.
@Test
public void shouldPerformPluginValidationsBeforeAddingSecurityAuthConfig() {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap", create("key", false, "value"));
Username username = new Username("username");
securityAuthConfigService.create(username, securityAuthConfig, new HttpLocalizedOperationResult());
verify(extension).validateAuthConfig(securityAuthConfig.getPluginId(), securityAuthConfig.getConfigurationAsMap(true));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class SecurityAuthConfigServiceTest method shouldAddSecurityAuthConfigToConfig.
@Test
public void shouldAddSecurityAuthConfigToConfig() {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
Username username = new Username("username");
securityAuthConfigService.create(username, securityAuthConfig, new HttpLocalizedOperationResult());
verify(goConfigService).updateConfig(any(SecurityAuthConfigCreateCommand.class), eq(username));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class SecurityAuthConfigServiceTest method shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginId.
@Test
public void shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginId() throws Exception {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("some-id", "non-existent-plugin", create("key", false, "value"));
Username username = new Username("username");
when(extension.validateAuthConfig(securityAuthConfig.getPluginId(), securityAuthConfig.getConfigurationAsMap(true))).thenThrow(new PluginNotFoundException("plugin not found"));
securityAuthConfigService.update(username, "md5", securityAuthConfig, new HttpLocalizedOperationResult());
assertThat(securityAuthConfig.errors().isEmpty(), is(false));
assertThat(securityAuthConfig.errors().on("pluginId"), is("Plugin with id `non-existent-plugin` is not found."));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class ServerConfigServiceTest method shouldSetMessageAsMergedWhenMergingServerConfigChanges.
@Test
public void shouldSetMessageAsMergedWhenMergingServerConfigChanges() {
GoConfigService goConfigService = mock(GoConfigService.class);
UserService userService = mock(UserService.class);
ServerConfigService serverConfigService = new ServerConfigService(goConfigService, userService);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
MailHost mailHost = new MailHost(new GoCipher());
when(goConfigService.updateServerConfig(mailHost, true, "md5", null, null, null, null, "http://site", "https://site", "location")).thenReturn(ConfigSaveState.MERGED);
serverConfigService.updateServerConfig(mailHost, null, null, null, null, true, "http://site", "https://site", "location", result, "md5");
assertThat(result.localizable(), Is.is(LocalizedMessage.composite(LocalizedMessage.string("SAVED_CONFIGURATION_SUCCESSFULLY"), LocalizedMessage.string("CONFIG_MERGED"))));
}
Aggregations