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);
}
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);
}
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);
}
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");
}
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);
}
Aggregations