Search in sources :

Example 6 with ChangeInfoDifference

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

the class GetMetaDiffIT method metaDiff.

@Test
public void metaDiff() throws Exception {
    PushOneCommit.Result ch = createChange();
    ChangeApi chApi = gApi.changes().id(ch.getChangeId());
    chApi.topic(TOPIC);
    ChangeInfo oldInfo = chApi.get();
    chApi.topic(TOPIC + "-2");
    chApi.setHashtags(new HashtagsInput(ImmutableSet.of(HASHTAG)));
    ChangeInfo newInfo = chApi.get();
    ChangeInfoDifference difference = chApi.metaDiff(oldInfo.metaRevId, newInfo.metaRevId);
    assertThat(difference.added().topic).isEqualTo(newInfo.topic);
    assertThat(difference.added().hashtags).isNotNull();
    assertThat(difference.added().hashtags).containsExactly(HASHTAG);
    assertThat(difference.removed().topic).isEqualTo(oldInfo.topic);
    assertThat(difference.removed().hashtags).isNull();
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) HashtagsInput(com.google.gerrit.extensions.api.changes.HashtagsInput) 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 7 with ChangeInfoDifference

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

the class GetMetaDiffIT method staticField.

@Test
public void staticField() throws Exception {
    PushOneCommit.Result result = createChange();
    ReviewInput in = new ReviewInput();
    in.message("hello");
    requestScopeOperations.setApiUser(user.id());
    gApi.changes().id(result.getChangeId()).revision("current").review(in);
    ChangeApi chApi = gApi.changes().id(result.getChangeId());
    ChangeInfoDifference difference = chApi.metaDiff(null, null, ListChangesOption.LABELS);
    assertThat(difference.added().reviewers).containsKey(ReviewerState.CC);
    assertThat(difference.added().reviewers).hasSize(1);
    Collection<AccountInfo> reviewers = difference.added().reviewers.get(ReviewerState.CC);
    assertThat(reviewers).hasSize(1);
    AccountInfo info = reviewers.iterator().next();
    assertThat(info._accountId).isEqualTo(user.id().get());
}
Also used : ChangeInfoDifference(com.google.gerrit.extensions.common.ChangeInfoDifference) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 8 with ChangeInfoDifference

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

the class GetMetaDiffIT method metaDiffNoNewMetaGivenUsesCurrentPatchSet.

@Test
public void metaDiffNoNewMetaGivenUsesCurrentPatchSet() throws Exception {
    PushOneCommit.Result ch = createChange();
    ChangeApi chApi = gApi.changes().id(ch.getChangeId());
    ChangeInfo oldInfo = chApi.get();
    chApi.topic(TOPIC);
    ChangeInfoDifference difference = chApi.metaDiff(oldInfo.metaRevId, null);
    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