Search in sources :

Example 1 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class SubmoduleSubscriptionsIT method testSubmoduleSubjectCommitMessage.

@Test
@GerritConfig(name = "submodule.verboseSuperprojectUpdate", value = "SUBJECT_ONLY")
public void testSubmoduleSubjectCommitMessage() throws Exception {
    TestRepository<?> superRepo = createProjectWithPush("super-project");
    TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
    allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master", "super-project", "refs/heads/master");
    pushChangeTo(subRepo, "master");
    createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
    ObjectId subHEAD = pushChangeTo(subRepo, "master");
    // The first update doesn't include the rev log
    RevWalk rw = subRepo.getRevWalk();
    expectToHaveCommitMessage(superRepo, "master", "Update git submodules\n\n" + "* Update " + name("subscribed-to-project") + " from branch 'master'");
    // The next commit should generate only its commit message,
    // omitting previous commit logs
    subHEAD = pushChangeTo(subRepo, "master");
    RevCommit subCommitMsg = rw.parseCommit(subHEAD);
    expectToHaveCommitMessage(superRepo, "master", "Update git submodules\n\n" + "* Update " + name("subscribed-to-project") + " from branch 'master'" + "\n  - " + subCommitMsg.getShortMessage());
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) RevWalk(org.eclipse.jgit.revwalk.RevWalk) RevCommit(org.eclipse.jgit.revwalk.RevCommit) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test)

Example 2 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class ListMailFilterIT method listFilterBlacklistFiltersListedUser.

@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "BLACKLIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+@example\\.com", "a@b\\.com" })
public void listFilterBlacklistFiltersListedUser() throws Exception {
    ChangeInfo changeInfo = createChangeAndReplyByEmail();
    // Check that the comments from the email have been persisted
    Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
    assertThat(messages).hasSize(2);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test)

Example 3 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class GetRelatedIT method getRelatedForStaleChange.

@Test
@GerritConfig(name = "index.testAutoReindexIfStale", value = "false")
public void getRelatedForStaleChange() throws Exception {
    RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create();
    RevCommit c2_1 = commitBuilder().add("b.txt", "1").message("subject: 1").create();
    pushHead(testRepo, "refs/for/master", false);
    RevCommit c2_2 = testRepo.amend(c2_1).add("b.txt", "2").create();
    testRepo.reset(c2_2);
    disableChangeIndexWrites();
    try {
        pushHead(testRepo, "refs/for/master", false);
    } finally {
        enableChangeIndexWrites();
    }
    PatchSet.Id psId1_1 = getPatchSetId(c1_1);
    PatchSet.Id psId2_1 = getPatchSetId(c2_1);
    PatchSet.Id psId2_2 = new PatchSet.Id(psId2_1.changeId, psId2_1.get() + 1);
    assertRelated(psId2_2, changeAndCommit(psId2_2, c2_2, 2), changeAndCommit(psId1_1, c1_1, 1));
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ObjectId(org.eclipse.jgit.lib.ObjectId) RevCommit(org.eclipse.jgit.revwalk.RevCommit) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class AbandonIT method abandonInactiveOpenChanges.

@Test
@GerritConfig(name = "changeCleanup.abandonAfter", value = "1w")
public void abandonInactiveOpenChanges() throws Exception {
    TestTimeUtil.resetWithClockStep(1, SECONDS);
    // create 2 changes which will be abandoned ...
    int id1 = createChange().getChange().getId().get();
    int id2 = createChange().getChange().getId().get();
    // ... because they are older than 1 week
    TestTimeUtil.incrementClock(7 * 24, HOURS);
    // create 1 new change that will not be abandoned
    ChangeData cd = createChange().getChange();
    int id3 = cd.getId().get();
    assertThat(toChangeNumbers(query("is:open"))).containsExactly(id1, id2, id3);
    assertThat(query("is:abandoned")).isEmpty();
    abandonUtil.abandonInactiveOpenChanges(batchUpdateFactory);
    assertThat(toChangeNumbers(query("is:open"))).containsExactly(id3);
    assertThat(toChangeNumbers(query("is:abandoned"))).containsExactly(id1, id2);
}
Also used : ChangeData(com.google.gerrit.server.query.change.ChangeData) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class SuggestReviewersIT method reviewerRanking.

@Test
@GerritConfig(name = "suggest.maxSuggestedReviewers", value = "10")
public void reviewerRanking() throws Exception {
    // Assert that user are ranked by the number of times they have applied a
    // a label to a change (highest), added comments (medium) or owned a
    // change (low).
    String fullName = "Primum Finalis";
    TestAccount userWhoOwns = user("customuser1", fullName);
    TestAccount reviewer1 = user("customuser2", fullName);
    TestAccount reviewer2 = user("customuser3", fullName);
    TestAccount userWhoComments = user("customuser4", fullName);
    TestAccount userWhoLooksForSuggestions = user("customuser5", fullName);
    // Create a change as userWhoOwns and add some reviews
    setApiUser(userWhoOwns);
    String changeId1 = createChangeFromApi();
    setApiUser(reviewer1);
    reviewChange(changeId1);
    setApiUser(user1);
    String changeId2 = createChangeFromApi();
    setApiUser(reviewer1);
    reviewChange(changeId2);
    setApiUser(reviewer2);
    reviewChange(changeId2);
    // Create a comment as a different user
    setApiUser(userWhoComments);
    ReviewInput ri = new ReviewInput();
    ri.message = "Test";
    gApi.changes().id(changeId1).revision(1).review(ri);
    // Create a change as a new user to assert that we receive the correct
    // ranking
    setApiUser(userWhoLooksForSuggestions);
    List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Pri", 4);
    assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList())).containsExactly(reviewer1.id.get(), reviewer2.id.get(), userWhoOwns.id.get(), userWhoComments.id.get()).inOrder();
}
Also used : SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

GerritConfig (com.google.gerrit.acceptance.GerritConfig)19 Test (org.junit.Test)19 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)12 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)6 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)5 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 ServerInfo (com.google.gerrit.extensions.common.ServerInfo)2 SuggestedReviewerInfo (com.google.gerrit.extensions.common.SuggestedReviewerInfo)2 ChangeData (com.google.gerrit.server.query.change.ChangeData)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 RestResponse (com.google.gerrit.acceptance.RestResponse)1 TestAccount (com.google.gerrit.acceptance.TestAccount)1 UseSsh (com.google.gerrit.acceptance.UseSsh)1 GroupAssert.assertGroupInfo (com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo)1 GroupReference (com.google.gerrit.common.data.GroupReference)1 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)1 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)1 SubmitInput (com.google.gerrit.extensions.api.changes.SubmitInput)1