Search in sources :

Example 86 with Repo

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

the class AbstractQueryChangesTest method byHasDraft.

private void byHasDraft() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    Change change1 = insert(repo, newChange(repo));
    Change change2 = insert(repo, newChange(repo));
    assertQuery("has:draft");
    DraftInput in = new DraftInput();
    in.line = 1;
    in.message = "nit: trailing whitespace";
    in.path = Patch.COMMIT_MSG;
    gApi.changes().id(change1.getId().get()).current().createDraft(in);
    in = new DraftInput();
    in.line = 2;
    in.message = "nit: point in the end of the statement";
    in.path = Patch.COMMIT_MSG;
    gApi.changes().id(change2.getId().get()).current().createDraft(in);
    Account.Id user2 = accountManager.authenticate(authRequestFactory.createForUser("anotheruser")).getAccountId();
    assertQuery("has:draft", change2, change1);
    requestContext.setContext(newRequestContext(user2));
    assertQuery("has:draft");
}
Also used : Account(com.google.gerrit.entities.Account) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) Change(com.google.gerrit.entities.Change)

Example 87 with Repo

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

the class AbstractQueryChangesTest method byLabelNotOwner.

@Test
public void byLabelNotOwner() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    ChangeInserter ins = newChange(repo);
    Account.Id user1 = createAccount("user1");
    Change reviewPlus1Change = insert(repo, ins);
    // post a review with user1
    requestContext.setContext(newRequestContext(user1));
    gApi.changes().id(reviewPlus1Change.getId().get()).current().review(ReviewInput.recommend());
    assertQuery("label:Code-Review=+1,user=user1", reviewPlus1Change);
    assertQuery("label:Code-Review=+1,owner");
}
Also used : Account(com.google.gerrit.entities.Account) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 88 with Repo

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

the class AbstractQueryChangesTest method byComment.

@Test
public void byComment() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    ChangeInserter ins = newChange(repo);
    Change change = insert(repo, ins);
    ReviewInput input = new ReviewInput();
    input.message = "toplevel";
    ReviewInput.CommentInput commentInput = new ReviewInput.CommentInput();
    commentInput.line = 1;
    commentInput.message = "inline";
    input.comments = ImmutableMap.of(Patch.COMMIT_MSG, ImmutableList.of(commentInput));
    gApi.changes().id(change.getId().get()).current().review(input);
    Map<String, List<CommentInfo>> comments = gApi.changes().id(change.getId().get()).current().comments();
    assertThat(comments).hasSize(1);
    CommentInfo comment = Iterables.getOnlyElement(comments.get(Patch.COMMIT_MSG));
    assertThat(comment.message).isEqualTo(commentInput.message);
    ChangeMessageInfo lastMsg = Iterables.getLast(gApi.changes().id(change.getId().get()).get().messages, null);
    assertThat(lastMsg.message).isEqualTo("Patch Set 1:\n\n(1 comment)\n\n" + input.message);
    assertQuery("comment:foo");
    assertQuery("comment:toplevel", change);
    assertQuery("comment:inline", change);
}
Also used : Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) Change(com.google.gerrit.entities.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Test(org.junit.Test)

Example 89 with Repo

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

the class LuceneQueryChangesTest method byOwnerInvalidQuery.

@Test
@Override
public void byOwnerInvalidQuery() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    Change change1 = insert(repo, newChange(repo), userId);
    String nameEmail = user.asIdentifiedUser().getNameEmail();
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> assertQuery("owner: \"" + nameEmail + "\"\\", change1));
    assertThat(thrown).hasMessageThat().contains("Cannot create full-text query with value: \\");
}
Also used : Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 90 with Repo

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

the class AbstractQueryChangesTest method byDeletedChange.

@Test
public void byDeletedChange() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    Change change = insert(repo, newChange(repo));
    String query = "change:" + change.getId();
    assertQuery(query, change);
    gApi.changes().id(change.getChangeId()).delete();
    assertQuery(query);
}
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