Search in sources :

Example 31 with Repo

use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method reviewerAndCcByEmail.

@Test
public void reviewerAndCcByEmail() throws Exception {
    Project.NameKey project = Project.nameKey("repo");
    TestRepository<Repo> repo = createProject(project.get());
    ConfigInput conf = new ConfigInput();
    conf.enableReviewerByEmail = InheritableBoolean.TRUE;
    gApi.projects().name(project.get()).config(conf);
    String userByEmail = "un.registered@reviewer.com";
    String userByEmailWithName = "John Doe <" + userByEmail + ">";
    Change change1 = insert(repo, newChange(repo));
    Change change2 = insert(repo, newChange(repo));
    insert(repo, newChange(repo));
    ReviewerInput rin = new ReviewerInput();
    rin.reviewer = userByEmailWithName;
    rin.state = ReviewerState.REVIEWER;
    gApi.changes().id(change1.getId().get()).addReviewer(rin);
    rin = new ReviewerInput();
    rin.reviewer = userByEmailWithName;
    rin.state = ReviewerState.CC;
    gApi.changes().id(change2.getId().get()).addReviewer(rin);
    assertQuery("reviewer:\"" + userByEmailWithName + "\"", change1);
    assertQuery("cc:\"" + userByEmailWithName + "\"", change2);
    // Omitting the name:
    assertQuery("reviewer:\"" + userByEmail + "\"", change1);
    assertQuery("cc:\"" + userByEmail + "\"", change2);
}
Also used : Project(com.google.gerrit.entities.Project) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) Change(com.google.gerrit.entities.Change) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test)

Example 32 with Repo

use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method submitRecords.

@Test
public void submitRecords() throws Exception {
    Account.Id user1 = createAccount("user1");
    TestRepository<Repo> repo = createProject("repo");
    Change change1 = insert(repo, newChange(repo));
    Change change2 = insert(repo, newChange(repo));
    gApi.changes().id(change1.getId().get()).current().review(ReviewInput.approve());
    requestContext.setContext(newRequestContext(user1));
    gApi.changes().id(change2.getId().get()).current().review(ReviewInput.recommend());
    requestContext.setContext(newRequestContext(user.getAccountId()));
    assertQuery("is:submittable", change1);
    assertQuery("-is:submittable", change2);
    assertQuery("label:CodE-RevieW=ok", change1);
    assertQuery("label:CodE-RevieW=ok,user=user", change1);
    assertQuery("label:CodE-RevieW=ok,Administrators", change1);
    assertQuery("label:CodE-RevieW=ok,group=Administrators", change1);
    assertQuery("label:CodE-RevieW=ok,owner", change1);
    assertQuery("label:CodE-RevieW=ok,user1");
    assertQuery("label:CodE-RevieW=need", change2);
    // NEED records don't have associated users.
    assertQuery("label:CodE-RevieW=need,user1");
    assertQuery("label:CodE-RevieW=need,user");
    gApi.changes().id(change1.getId().get()).current().submit();
    assertQuery("is:submittable");
    assertQuery("-is:submittable", change1, change2);
}
Also used : Account(com.google.gerrit.entities.Account) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 33 with Repo

use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method filterOutMoreThanOnePageOfResults.

@Test
public void filterOutMoreThanOnePageOfResults() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    Change change = insert(repo, newChange(repo), userId);
    Account.Id user2 = accountManager.authenticate(authRequestFactory.createForUser("anotheruser")).getAccountId();
    for (int i = 0; i < 5; i++) {
        insert(repo, newChange(repo), user2);
    }
    assertQuery("status:new ownerin:Administrators", change);
    assertQuery("status:new ownerin:Administrators limit:2", change);
}
Also used : Account(com.google.gerrit.entities.Account) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 34 with Repo

use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method byLabelGroup.

@Test
public void byLabelGroup() throws Exception {
    Account.Id user1 = createAccount("user1");
    createAccount("user2");
    TestRepository<Repo> repo = createProject("repo");
    // create group and add users
    String g1 = createGroup("group1", "Administrators");
    String g2 = createGroup("group2", "Administrators");
    gApi.groups().id(g1).addMembers("user1");
    gApi.groups().id(g2).addMembers("user2");
    // create a change
    Change change1 = insert(repo, newChange(repo), user1);
    // post a review with user1
    requestContext.setContext(newRequestContext(user1));
    gApi.changes().id(change1.getId().get()).current().review(new ReviewInput().label("Code-Review", 1));
    // verify that query with user1 will return results.
    requestContext.setContext(newRequestContext(userId));
    assertQuery("label:Code-Review=+1,group1", change1);
    assertQuery("label:Code-Review=+1,group=group1", change1);
    assertQuery("label:Code-Review=+1,user=user1", change1);
    assertQuery("label:Code-Review=+1,user=user2");
    assertQuery("label:Code-Review=+1,group=group2");
}
Also used : Account(com.google.gerrit.entities.Account) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) Change(com.google.gerrit.entities.Change) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Test(org.junit.Test)

Example 35 with Repo

use of com.google.gerrit.testing.InMemoryRepositoryManager.Repo in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method byFileRegex.

@Test
public void byFileRegex() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    Change change = insert(repo, newChangeWithFiles(repo, "dir/file1", "dir/file2"));
    assertQuery("file:.*file.*");
    // Whole path only.
    assertQuery("file:^file.*");
    assertQuery("file:^dir.file.*", change);
}
Also used : Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Aggregations

Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)126 Test (org.junit.Test)117 Change (com.google.gerrit.entities.Change)112 Account (com.google.gerrit.entities.Account)30 RevCommit (org.eclipse.jgit.revwalk.RevCommit)30 ChangeInserter (com.google.gerrit.server.change.ChangeInserter)17 ChangeData (com.google.gerrit.server.query.change.ChangeData)11 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)10 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)8 Project (com.google.gerrit.entities.Project)7 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)6 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)5 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)5 RevWalk (org.eclipse.jgit.revwalk.RevWalk)5 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)4 ConfigInput (com.google.gerrit.extensions.api.projects.ConfigInput)4 AuthException (com.google.gerrit.extensions.restapi.AuthException)4 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)4 QueryParseException (com.google.gerrit.index.query.QueryParseException)4 IOException (java.io.IOException)4