use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelinePauseServiceTest method shouldPopulatePausePipelineSuccessResult.
@Test
public void shouldPopulatePausePipelineSuccessResult() throws Exception {
setUpValidPipelineWithAuth();
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
pipelinePauseService.pause(VALID_PIPELINE, null, VALID_USER, result);
assertThat(result.isSuccessful(), is(true));
assertThat(result.httpCode(), is(SC_OK));
assertThat(result.localizable(), is(LocalizedMessage.string("PIPELINE_PAUSE_SUCCESSFUL", VALID_PIPELINE)));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelineStagesFeedServiceTest method setUp.
@Before
public void setUp() throws Exception {
user = new Username(new CaseInsensitiveString("barrow"));
expected = new FeedEntries();
stageService = mock(StageService.class);
securityService = mock(SecurityService.class);
operationResult = new HttpLocalizedOperationResult();
pipelineStagesFeedResolver = new PipelineStagesFeedService(stageService, securityService).feedResolverFor("cruise");
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PluginServiceTest method shouldNotSavePluginSettingsIfPluginDoesNotExist.
@Test
public void shouldNotSavePluginSettingsIfPluginDoesNotExist() {
PluginSettings pluginSettings = new PluginSettings("non-existent-plugin");
Username currentUser = new Username("admin");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(securityService.isUserAdmin(currentUser)).thenReturn(true);
for (GoPluginExtension extension : extensions) {
when(extension.canHandlePlugin("non-existent-plugin")).thenReturn(false);
}
pluginService.savePluginSettings(currentUser, result, pluginSettings);
assertThat(result.httpCode(), is(422));
assertThat(result.toString(), containsString("Plugin 'non-existent-plugin' does not exist or does not implement settings validation"));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class BackupsControllerDelegate method create.
public String create(Request request, Response response) throws IOException {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
ServerBackup backup = backupService.startBackup(currentUsername(), result);
if (result.isSuccessful()) {
return writerForTopLevelObject(request, response, outputWriter -> BackupRepresenter.toJSON(outputWriter, backup));
}
return renderHTTPOperationResult(result, request, response, localizer);
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class CurrentUserControllerDelegate method update.
public String update(Request req, Response res) throws IOException {
User user = userService.findUserByName(currentUserLoginName().toString());
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
Map map = readRequestBodyAsJSON(req);
String checkinAliases = null;
if (map.containsKey("checkin_aliases")) {
Object newAliases = map.get("checkin_aliases");
if (newAliases instanceof Collection) {
checkinAliases = StringUtils.join((Collection) newAliases, ", ");
} else if (newAliases instanceof String) {
checkinAliases = (String) newAliases;
}
}
TriState emailMe = TriState.from(String.valueOf(map.get("email_me")));
String email = (String) map.get("email");
User serializedUser = userService.save(user, TriState.from(null), emailMe, email, checkinAliases, result);
String json = jsonizeAsTopLevelObject(req, writer -> UserRepresenter.toJSON(writer, serializedUser));
String etag = etagFor(json);
setEtagHeader(res, etag);
return json;
}
Aggregations