Search in sources :

Example 16 with DiffPreferencesInfo

use of com.google.gerrit.extensions.client.DiffPreferencesInfo in project gerrit by GerritCodeReview.

the class DefaultConfigCacheIT method canLoadAtSpecificRev.

@Test
public void canLoadAtSpecificRev() throws Exception {
    // Set a value to make sure we have custom preferences set
    DiffPreferencesInfo update = new DiffPreferencesInfo();
    update.lineLength = 1337;
    gApi.config().server().setDefaultDiffPreferences(update);
    ObjectId oldRev = currentRev();
    CachedPreferences before = defaultPreferencesCache.get();
    // Mutate the preferences
    DiffPreferencesInfo update2 = new DiffPreferencesInfo();
    update2.lineLength = 815;
    gApi.config().server().setDefaultDiffPreferences(update2);
    assertThat(oldRev).isNotEqualTo(currentRev());
    assertThat(defaultPreferencesCache.get()).isNotEqualTo(before);
    assertThat(defaultPreferencesCache.get(oldRev)).isEqualTo(before);
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) DiffPreferencesInfo(com.google.gerrit.extensions.client.DiffPreferencesInfo) CachedPreferences(com.google.gerrit.server.config.CachedPreferences) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 17 with DiffPreferencesInfo

use of com.google.gerrit.extensions.client.DiffPreferencesInfo in project gerrit by GerritCodeReview.

the class DefaultConfigCacheIT method invalidatesOldValue.

@Test
public void invalidatesOldValue() throws Exception {
    CachedPreferences before = defaultPreferencesCache.get();
    DiffPreferencesInfo update = new DiffPreferencesInfo();
    update.lineLength = 123;
    gApi.config().server().setDefaultDiffPreferences(update);
    assertThat(before).isNotEqualTo(defaultPreferencesCache.get());
}
Also used : DiffPreferencesInfo(com.google.gerrit.extensions.client.DiffPreferencesInfo) CachedPreferences(com.google.gerrit.server.config.CachedPreferences) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 18 with DiffPreferencesInfo

use of com.google.gerrit.extensions.client.DiffPreferencesInfo in project gerrit by GerritCodeReview.

the class SubmitWithStickyApprovalDiff method createDefaultDiffPreferencesInfo.

private DiffPreferencesInfo createDefaultDiffPreferencesInfo() {
    DiffPreferencesInfo diffPreferencesInfo = new DiffPreferencesInfo();
    diffPreferencesInfo.ignoreWhitespace = Whitespace.IGNORE_NONE;
    diffPreferencesInfo.intralineDifference = true;
    return diffPreferencesInfo;
}
Also used : DiffPreferencesInfo(com.google.gerrit.extensions.client.DiffPreferencesInfo)

Example 19 with DiffPreferencesInfo

use of com.google.gerrit.extensions.client.DiffPreferencesInfo in project gerrit by GerritCodeReview.

the class DiffPreferencesIT method setDiffPreferences.

@Test
public void setDiffPreferences() throws Exception {
    DiffPreferencesInfo i = DiffPreferencesInfo.defaults();
    // change all default values
    i.context *= -1;
    i.tabSize *= -1;
    i.fontSize *= -1;
    i.lineLength *= -1;
    i.cursorBlinkRate = 500;
    i.ignoreWhitespace = Whitespace.IGNORE_ALL;
    i.expandAllComments ^= true;
    i.intralineDifference ^= true;
    i.manualReview ^= true;
    i.retainHeader ^= true;
    i.showLineEndings ^= true;
    i.showTabs ^= true;
    i.showWhitespaceErrors ^= true;
    i.skipDeleted ^= true;
    i.skipUnchanged ^= true;
    i.skipUncommented ^= true;
    i.syntaxHighlighting ^= true;
    i.hideTopMenu ^= true;
    i.autoHideDiffTableHeader ^= true;
    i.hideLineNumbers ^= true;
    i.renderEntireFile ^= true;
    i.hideEmptyPane ^= true;
    i.matchBrackets ^= true;
    i.lineWrapping ^= true;
    DiffPreferencesInfo o = gApi.accounts().id(admin.id().toString()).setDiffPreferences(i);
    assertPrefs(o, i);
    // Partially fill input record
    i = new DiffPreferencesInfo();
    i.tabSize = 42;
    DiffPreferencesInfo a = gApi.accounts().id(admin.id().toString()).setDiffPreferences(i);
    assertPrefs(a, o, "tabSize");
    assertThat(a.tabSize).isEqualTo(42);
}
Also used : DiffPreferencesInfo(com.google.gerrit.extensions.client.DiffPreferencesInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 20 with DiffPreferencesInfo

use of com.google.gerrit.extensions.client.DiffPreferencesInfo in project gerrit by GerritCodeReview.

the class DiffPreferencesIT method setDiffPreferences.

@Test
public void setDiffPreferences() throws Exception {
    int newLineLength = DiffPreferencesInfo.defaults().lineLength + 10;
    DiffPreferencesInfo update = new DiffPreferencesInfo();
    update.lineLength = newLineLength;
    DiffPreferencesInfo result = gApi.config().server().setDefaultDiffPreferences(update);
    assertWithMessage("lineLength").that(result.lineLength).isEqualTo(newLineLength);
    result = gApi.config().server().getDefaultDiffPreferences();
    DiffPreferencesInfo expected = DiffPreferencesInfo.defaults();
    expected.lineLength = newLineLength;
    assertPrefs(result, expected);
}
Also used : DiffPreferencesInfo(com.google.gerrit.extensions.client.DiffPreferencesInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

DiffPreferencesInfo (com.google.gerrit.extensions.client.DiffPreferencesInfo)20 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)8 Test (org.junit.Test)8 PatchScript (com.google.gerrit.common.data.PatchScript)3 VersionedAccountPreferences (com.google.gerrit.server.account.VersionedAccountPreferences)3 LargeObjectException (com.google.gerrit.server.git.LargeObjectException)3 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)3 Repository (org.eclipse.jgit.lib.Repository)3 DiffInfo (com.google.gerrit.extensions.common.DiffInfo)2 IdString (com.google.gerrit.extensions.restapi.IdString)2 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)2 CachedPreferences (com.google.gerrit.server.config.CachedPreferences)2 PatchScriptFactory (com.google.gerrit.server.patch.PatchScriptFactory)2 NoSuchChangeException (com.google.gerrit.server.project.NoSuchChangeException)2 ProjectState (com.google.gerrit.server.project.ProjectState)2 PatchSet (com.google.gerrit.entities.PatchSet)1 Project (com.google.gerrit.entities.Project)1 EditPreferencesInfo (com.google.gerrit.extensions.client.EditPreferencesInfo)1 GeneralPreferencesInfo (com.google.gerrit.extensions.client.GeneralPreferencesInfo)1