use of com.google.gerrit.extensions.client.GeneralPreferencesInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method setSignedOffByFooter.
// TODO(davido): Expose setting of account preferences in the API
private void setSignedOffByFooter() throws Exception {
RestResponse r = adminRestSession.get("/accounts/" + admin.email + "/preferences");
r.assertOK();
GeneralPreferencesInfo i = newGson().fromJson(r.getReader(), GeneralPreferencesInfo.class);
i.signedOffBy = true;
r = adminRestSession.put("/accounts/" + admin.email + "/preferences", i);
r.assertOK();
GeneralPreferencesInfo o = newGson().fromJson(r.getReader(), GeneralPreferencesInfo.class);
assertThat(o.signedOffBy).isTrue();
}
use of com.google.gerrit.extensions.client.GeneralPreferencesInfo in project gerrit by GerritCodeReview.
the class NotificationMailFormatIT method userReceivesPlaintextEmail.
@Test
public void userReceivesPlaintextEmail() throws Exception {
// Set user preference to receive only plaintext content
GeneralPreferencesInfo i = new GeneralPreferencesInfo();
i.emailFormat = EmailFormat.PLAINTEXT;
gApi.accounts().id(admin.getId().toString()).setPreferences(i);
// Create change as admin and review as user
PushOneCommit.Result r = createChange();
setApiUser(user);
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.recommend());
// Check that admin has received only plaintext content
assertThat(sender.getMessages()).hasSize(1);
FakeEmailSender.Message m = sender.getMessages().get(0);
assertThat(m.body()).isNotNull();
assertThat(m.htmlBody()).isNull();
assertMailReplyTo(m, admin.email);
assertMailReplyTo(m, user.email);
// Reset user preference
setApiUser(admin);
i.emailFormat = EmailFormat.HTML_PLAINTEXT;
gApi.accounts().id(admin.getId().toString()).setPreferences(i);
}
use of com.google.gerrit.extensions.client.GeneralPreferencesInfo in project gerrit by GerritCodeReview.
the class GeneralPreferences method createDefault.
public static GeneralPreferences createDefault() {
GeneralPreferencesInfo d = GeneralPreferencesInfo.defaults();
GeneralPreferences p = createObject().cast();
p.changesPerPage(d.changesPerPage);
p.showSiteHeader(d.showSiteHeader);
p.useFlashClipboard(d.useFlashClipboard);
p.downloadScheme(d.downloadScheme);
p.downloadCommand(d.downloadCommand);
p.dateFormat(d.getDateFormat());
p.timeFormat(d.getTimeFormat());
p.highlightAssigneeInChangeTable(d.highlightAssigneeInChangeTable);
p.relativeDateInChangeTable(d.relativeDateInChangeTable);
p.sizeBarInChangeTable(d.sizeBarInChangeTable);
p.legacycidInChangeTable(d.legacycidInChangeTable);
p.muteCommonPathPrefixes(d.muteCommonPathPrefixes);
p.signedOffBy(d.signedOffBy);
p.emailFormat(d.emailFormat);
p.reviewCategoryStrategy(d.getReviewCategoryStrategy());
p.diffView(d.getDiffView());
p.emailStrategy(d.emailStrategy);
p.defaultBaseForMerges(d.defaultBaseForMerges);
return p;
}
use of com.google.gerrit.extensions.client.GeneralPreferencesInfo in project gerrit by GerritCodeReview.
the class GeneralPreferencesIT method getAndSetPreferences.
@Test
public void getAndSetPreferences() throws Exception {
GeneralPreferencesInfo o = gApi.accounts().id(user42.id.toString()).getPreferences();
assertPrefs(o, GeneralPreferencesInfo.defaults(), "my", "changeTable");
assertThat(o.my).hasSize(7);
assertThat(o.changeTable).isEmpty();
GeneralPreferencesInfo i = GeneralPreferencesInfo.defaults();
// change all default values
i.changesPerPage *= -1;
i.showSiteHeader ^= true;
i.useFlashClipboard ^= true;
i.downloadCommand = DownloadCommand.REPO_DOWNLOAD;
i.dateFormat = DateFormat.US;
i.timeFormat = TimeFormat.HHMM_24;
i.emailStrategy = EmailStrategy.DISABLED;
i.emailFormat = EmailFormat.PLAINTEXT;
i.defaultBaseForMerges = DefaultBase.AUTO_MERGE;
i.expandInlineDiffs ^= true;
i.highlightAssigneeInChangeTable ^= true;
i.relativeDateInChangeTable ^= true;
i.sizeBarInChangeTable ^= true;
i.legacycidInChangeTable ^= true;
i.muteCommonPathPrefixes ^= true;
i.signedOffBy ^= true;
i.reviewCategoryStrategy = ReviewCategoryStrategy.ABBREV;
i.diffView = DiffView.UNIFIED_DIFF;
i.my = new ArrayList<>();
i.my.add(new MenuItem("name", "url"));
i.changeTable = new ArrayList<>();
i.changeTable.add("Status");
i.urlAliases = new HashMap<>();
i.urlAliases.put("foo", "bar");
o = gApi.accounts().id(user42.getId().toString()).setPreferences(i);
assertPrefs(o, i, "my");
assertThat(o.my).hasSize(1);
assertThat(o.changeTable).hasSize(1);
}
use of com.google.gerrit.extensions.client.GeneralPreferencesInfo in project gerrit by GerritCodeReview.
the class GeneralPreferencesIT method overwriteConfiguredDefaults.
@Test
public void overwriteConfiguredDefaults() throws Exception {
GeneralPreferencesInfo d = GeneralPreferencesInfo.defaults();
int configuredChangesPerPage = d.changesPerPage * 2;
GeneralPreferencesInfo update = new GeneralPreferencesInfo();
update.changesPerPage = configuredChangesPerPage;
gApi.config().server().setDefaultPreferences(update);
GeneralPreferencesInfo o = gApi.accounts().id(admin.getId().toString()).getPreferences();
assertThat(o.changesPerPage).isEqualTo(configuredChangesPerPage);
assertPrefs(o, d, "my", "changeTable", "changesPerPage");
int newChangesPerPage = configuredChangesPerPage * 2;
GeneralPreferencesInfo i = new GeneralPreferencesInfo();
i.changesPerPage = newChangesPerPage;
GeneralPreferencesInfo a = gApi.accounts().id(admin.getId().toString()).setPreferences(i);
assertThat(a.changesPerPage).isEqualTo(newChangesPerPage);
assertPrefs(a, d, "my", "changeTable", "changesPerPage");
a = gApi.accounts().id(admin.getId().toString()).getPreferences();
assertThat(a.changesPerPage).isEqualTo(newChangesPerPage);
assertPrefs(a, d, "my", "changeTable", "changesPerPage");
// overwrite the configured default with original hard-coded default
i = new GeneralPreferencesInfo();
i.changesPerPage = d.changesPerPage;
a = gApi.accounts().id(admin.getId().toString()).setPreferences(i);
assertThat(a.changesPerPage).isEqualTo(d.changesPerPage);
assertPrefs(a, d, "my", "changeTable", "changesPerPage");
a = gApi.accounts().id(admin.getId().toString()).getPreferences();
assertThat(a.changesPerPage).isEqualTo(d.changesPerPage);
assertPrefs(a, d, "my", "changeTable", "changesPerPage");
}
Aggregations