Search in sources :

Example 1 with ChangeInfoDifference

use of com.google.gerrit.extensions.common.ChangeInfoDifference in project gerrit by GerritCodeReview.

the class GetMetaDiffIT method metaDiffWithOptionIncludesExtraInformation.

@Test
public void metaDiffWithOptionIncludesExtraInformation() throws Exception {
    PushOneCommit.Result ch = createChange();
    ChangeApi chApi = gApi.changes().id(ch.getChangeId());
    ChangeInfo oldInfo = chApi.get(ListChangesOption.CURRENT_REVISION);
    amendChange(ch.getChangeId());
    ChangeInfo newInfo = chApi.get(ListChangesOption.CURRENT_REVISION);
    ChangeInfoDifference difference = chApi.metaDiff(oldInfo.metaRevId, newInfo.metaRevId, ImmutableSet.of(ListChangesOption.CURRENT_REVISION));
    assertThat(newInfo.currentRevision).isNotNull();
    assertThat(oldInfo.currentRevision).isNotNull();
    assertThat(difference.added().currentRevision).isEqualTo(newInfo.currentRevision);
    assertThat(difference.removed().currentRevision).isEqualTo(oldInfo.currentRevision);
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with ChangeInfoDifference

use of com.google.gerrit.extensions.common.ChangeInfoDifference in project gerrit by GerritCodeReview.

the class GetMetaDiffIT method metaDiffWithoutOptionDoesNotIncludeExtraInformation.

@Test
public void metaDiffWithoutOptionDoesNotIncludeExtraInformation() throws Exception {
    PushOneCommit.Result ch = createChange();
    ChangeApi chApi = gApi.changes().id(ch.getChangeId());
    ChangeInfo oldInfo = chApi.get();
    amendChange(ch.getChangeId());
    ChangeInfo newInfo = chApi.get();
    ChangeInfoDifference difference = chApi.metaDiff(oldInfo.metaRevId, newInfo.metaRevId);
    assertThat(difference.added().currentRevision).isNull();
    assertThat(difference.removed().currentRevision).isNull();
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with ChangeInfoDifference

use of com.google.gerrit.extensions.common.ChangeInfoDifference in project gerrit by GerritCodeReview.

the class GetMetaDiffIT method metaDiffWithOldSha1NotInRepoUsesDefault.

@Test
public void metaDiffWithOldSha1NotInRepoUsesDefault() throws Exception {
    PushOneCommit.Result ch = createChange();
    gApi.changes().id(ch.getChangeId()).topic("intermediate-topic");
    gApi.changes().id(ch.getChangeId()).topic(TOPIC);
    ChangeInfo info = gApi.changes().id(ch.getChangeId()).get();
    ChangeInfoDifference difference = gApi.changes().id(ch.getChangeId()).metaDiff(UNSAVED_REV_ID, info.metaRevId);
    assertThat(difference.added().topic).isEqualTo(TOPIC);
    assertThat(difference.removed().topic).isNull();
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with ChangeInfoDifference

use of com.google.gerrit.extensions.common.ChangeInfoDifference in project gerrit by GerritCodeReview.

the class GetMetaDiffIT method metaDiffUnreachableOldSha1UsesDefault.

@Test
public void metaDiffUnreachableOldSha1UsesDefault() throws Exception {
    PushOneCommit.Result ch1 = createChange();
    PushOneCommit.Result ch2 = createChange();
    gApi.changes().id(ch1.getChangeId()).topic("intermediate-topic");
    gApi.changes().id(ch1.getChangeId()).topic(TOPIC);
    ChangeInfo info1 = gApi.changes().id(ch1.getChangeId()).get();
    ChangeInfo info2 = gApi.changes().id(ch2.getChangeId()).get();
    ChangeInfoDifference difference = gApi.changes().id(ch1.getChangeId()).metaDiff(info2.metaRevId, info1.metaRevId);
    assertThat(difference.added().topic).isEqualTo(TOPIC);
    assertThat(difference.removed().topic).isNull();
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with ChangeInfoDifference

use of com.google.gerrit.extensions.common.ChangeInfoDifference in project gerrit by GerritCodeReview.

the class GetMetaDiffIT method metaDiffNoOldMetaGivenUsesPatchSetBeforeNew.

@Test
public void metaDiffNoOldMetaGivenUsesPatchSetBeforeNew() throws Exception {
    PushOneCommit.Result ch = createChange();
    ChangeApi chApi = gApi.changes().id(ch.getChangeId());
    chApi.topic(TOPIC);
    ChangeInfo newInfo = chApi.get();
    chApi.topic(TOPIC + "2");
    ChangeInfoDifference difference = chApi.metaDiff(null, newInfo.metaRevId);
    assertThat(difference.added().topic).isEqualTo(TOPIC);
    assertThat(difference.removed().topic).isNull();
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)8 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)8 ChangeInfoDifference (com.google.gerrit.extensions.common.ChangeInfoDifference)8 Test (org.junit.Test)8 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)7 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)6 HashtagsInput (com.google.gerrit.extensions.api.changes.HashtagsInput)1 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)1 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)1