Search in sources :

Example 6 with TestAccount

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

the class ChangeReviewersIT method notifyDetailsWorkOnPostReviewers.

@Test
public void notifyDetailsWorkOnPostReviewers() throws Exception {
    PushOneCommit.Result r = createChange();
    TestAccount userToNotify = createAccounts(1, "notify-details-post-reviewers").get(0);
    AddReviewerInput addReviewer = new AddReviewerInput();
    addReviewer.reviewer = user.email;
    addReviewer.notify = NotifyHandling.NONE;
    addReviewer.notifyDetails = ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));
    sender.clear();
    gApi.changes().id(r.getChangeId()).addReviewer(addReviewer);
    assertThat(sender.getMessages()).hasSize(1);
    assertThat(sender.getMessages().get(0).rcpt()).containsExactly(userToNotify.emailAddress);
}
Also used : NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with TestAccount

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

the class RevisionIT method cherryPickNotify.

@Test
public void cherryPickNotify() throws Exception {
    createBranch(new NameKey(project, "branch-1"));
    createBranch(new NameKey(project, "branch-2"));
    createBranch(new NameKey(project, "branch-3"));
    // Creates a change for 'admin'.
    PushOneCommit.Result result = createChange();
    String changeId = project.get() + "~master~" + result.getChangeId();
    // 'user' cherry-picks the change to a new branch, the source change's author/committer('admin')
    // will be added as a reviewer of the newly created change.
    setApiUser(user);
    CherryPickInput input = new CherryPickInput();
    input.message = "it goes to a new branch";
    // Enable the notification. 'admin' as a reviewer should be notified.
    input.destination = "branch-1";
    input.notify = NotifyHandling.ALL;
    sender.clear();
    gApi.changes().id(changeId).current().cherryPick(input);
    assertNotifyCc(admin);
    // Disable the notification. 'admin' as a reviewer should not be notified any more.
    input.destination = "branch-2";
    input.notify = NotifyHandling.NONE;
    sender.clear();
    gApi.changes().id(changeId).current().cherryPick(input);
    assertThat(sender.getMessages()).hasSize(0);
    // Disable the notification. The user provided in the 'notifyDetails' should still be notified.
    TestAccount userToNotify = accounts.user2();
    input.destination = "branch-3";
    input.notify = NotifyHandling.NONE;
    input.notifyDetails = ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));
    sender.clear();
    gApi.changes().id(changeId).current().cherryPick(input);
    assertNotifyTo(userToNotify);
}
Also used : CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) NameKey(com.google.gerrit.reviewdb.client.Branch.NameKey) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 8 with TestAccount

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

the class GroupsIT method reindexPermissions.

// reindex is tested by {@link AbstractQueryGroupsTest#reindex}
@Test
public void reindexPermissions() throws Exception {
    TestAccount groupOwner = accounts.user2();
    GroupInput in = new GroupInput();
    in.name = name("group");
    in.members = Collections.singleton(groupOwner).stream().map(u -> u.id.toString()).collect(toList());
    in.visibleToAll = true;
    GroupInfo group = gApi.groups().create(in).get();
    // admin can reindex any group
    setApiUser(admin);
    gApi.groups().id(group.id).index();
    // group owner can reindex own group (group is owned by itself)
    setApiUser(groupOwner);
    gApi.groups().id(group.id).index();
    // user cannot reindex any group
    setApiUser(user);
    exception.expect(AuthException.class);
    exception.expectMessage("not allowed to index group");
    gApi.groups().id(group.id).index();
}
Also used : GroupInput(com.google.gerrit.extensions.api.groups.GroupInput) GroupAssert.assertGroupInfo(com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 9 with TestAccount

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

the class GroupsIT method addMembersWithAtSign.

@Test
public void addMembersWithAtSign() throws Exception {
    String g = createGroup("users");
    TestAccount u10 = accounts.create("u10", "u10@example.com", "Full Name 10");
    TestAccount u11_at = accounts.create("u11@something", "u11@example.com", "Full Name 11 With At");
    accounts.create("u11", "u11.another@example.com", "Full Name 11 Without At");
    gApi.groups().id(g).addMembers(u10.username, u11_at.username);
    assertMembers(g, u10, u11_at);
}
Also used : TestAccount(com.google.gerrit.acceptance.TestAccount) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 with TestAccount

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

the class SuggestReviewersIT method defaultReviewerSuggestionOnFirstChange.

@Test
public void defaultReviewerSuggestionOnFirstChange() throws Exception {
    TestAccount user1 = user("customuser1", "User1");
    setApiUser(user1);
    List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChange().getChangeId(), "", 4);
    assertThat(reviewers).isEmpty();
}
Also used : SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

TestAccount (com.google.gerrit.acceptance.TestAccount)30 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)28 Test (org.junit.Test)28 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)18 Message (com.google.gerrit.testutil.FakeEmailSender.Message)8 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)6 ArrayList (java.util.ArrayList)6 Project (com.google.gerrit.reviewdb.client.Project)5 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)5 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)4 AddReviewerResult (com.google.gerrit.extensions.api.changes.AddReviewerResult)4 NotifyInfo (com.google.gerrit.extensions.api.changes.NotifyInfo)4 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 SuggestedReviewerInfo (com.google.gerrit.extensions.common.SuggestedReviewerInfo)4 ReviewResult (com.google.gerrit.extensions.api.changes.ReviewResult)3 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)3 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)2 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 GerritConfig (com.google.gerrit.acceptance.GerritConfig)1 GitUtil.deleteRef (com.google.gerrit.acceptance.GitUtil.deleteRef)1