Search in sources :

Example 11 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.

the class CommentCollectorTest method shouldCollectNonOutdatedComments.

@Test
void shouldCollectNonOutdatedComments() {
    Repository repository = RepositoryTestData.createHeartOfGold();
    PullRequest pullRequest = TestData.createPullRequest();
    Comment one = Comment.createSystemComment("hello");
    Comment two = Comment.createSystemComment("hello");
    two.setOutdated(true);
    List<Comment> prcs = ImmutableList.of(one, two);
    when(commentService.getAll(repository.getNamespace(), repository.getName(), pullRequest.getId())).thenReturn(prcs);
    Stream<Comment> comments = collector.collectNonOutdated(repository, pullRequest);
    assertThat(comments).containsOnly(one);
}
Also used : Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.jupiter.api.Test)

Example 12 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.

the class StatusCheckHookTest method mockOpenPullRequest.

private PullRequest mockOpenPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setStatus(PullRequestStatus.OPEN);
    pullRequest.setSource("source");
    pullRequest.setTarget("target");
    when(pullRequestService.getAll(NAMESPACE, NAME)).thenReturn(singletonList(pullRequest));
    return pullRequest;
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 13 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.

the class CommentIndexerTest method shouldDeleteCommentFromIndex.

@Test
void shouldDeleteCommentFromIndex() {
    PullRequest pr = createPullRequest();
    Comment comment = Comment.createComment("1", "first one", "trillian", new Location());
    indexer.handleEvent(new CommentEvent(repository, pr, null, comment, HandlerEventType.DELETE));
    verify(forType).update(any(SerializableIndexTask.class));
}
Also used : SerializableIndexTask(sonia.scm.search.SerializableIndexTask) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.jupiter.api.Test)

Example 14 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.

the class CommentIndexerTest method shouldIndexCommentForCommentEvent.

@Test
void shouldIndexCommentForCommentEvent() {
    PullRequest pr = createPullRequest();
    Comment comment = Comment.createComment("1", "first one", "trillian", new Location());
    indexer.handleEvent(new CommentEvent(repository, pr, comment, comment, HandlerEventType.CREATE));
    verify(forType).update(any(SerializableIndexTask.class));
}
Also used : SerializableIndexTask(sonia.scm.search.SerializableIndexTask) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.jupiter.api.Test)

Example 15 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.

the class CommentIndexerTest method shouldDeleteReplyFromIndexForReplyEvent.

@Test
void shouldDeleteReplyFromIndexForReplyEvent() {
    PullRequest pr = createPullRequest();
    Comment comment = Comment.createComment("1", "first one", "trillian", new Location());
    Reply reply = Reply.createReply("1", "first one", "trillian");
    indexer.handleEvent(new ReplyEvent(repository, pr, null, reply, comment, HandlerEventType.DELETE));
    verify(forType).update(any(SerializableIndexTask.class));
}
Also used : SerializableIndexTask(sonia.scm.search.SerializableIndexTask) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.jupiter.api.Test)

Aggregations

PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)82 Repository (sonia.scm.repository.Repository)27 Test (org.junit.jupiter.api.Test)20 Test (org.junit.Test)18 TestData.createPullRequest (com.cloudogu.scm.review.TestData.createPullRequest)17 MockHttpRequest (org.jboss.resteasy.mock.MockHttpRequest)16 Subscribe (com.github.legman.Subscribe)13 SubjectAware (com.github.sdorra.shiro.SubjectAware)13 NamespaceAndName (sonia.scm.repository.NamespaceAndName)13 User (sonia.scm.user.User)11 DisplayUser (sonia.scm.user.DisplayUser)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Optional (java.util.Optional)7 Comment (com.cloudogu.scm.review.comment.service.Comment)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 PermissionCheck (com.cloudogu.scm.review.PermissionCheck)5 PullRequestService (com.cloudogu.scm.review.pullrequest.service.PullRequestService)5 Operation (io.swagger.v3.oas.annotations.Operation)5 List (java.util.List)5