use of com.cloudogu.scm.review.comment.service.Location in project scm-review-plugin by scm-manager.
the class CommentLocationUpdateStepTest method shouldUpdateLocation.
@Test
void shouldUpdateLocation(@TempDir Path temp) throws Exception {
Path store = createStore(temp);
doAnswer(ic -> {
BiConsumer<String, Path> consumer = ic.getArgument(0);
consumer.accept("repo", temp);
return null;
}).when(resolverInstance).forAllLocations(any());
Path one = copyResource(store, "1");
Path two = copyResource(store, "2");
updateStep.doUpdate();
PullRequestComments commentsOfOne = JAXB.unmarshal(one.toFile(), PullRequestComments.class);
assertThat(commentsOfOne.getComments()).hasSize(4).extracting(Comment::getLocation).containsOnly(null, null, new Location("README.md", "@@ -1,3 +1,41 @@", null, 25), new Location("README.md", "@@ -1,3 +1,41 @@", null, 39));
PullRequestComments commentsOfTwo = JAXB.unmarshal(two.toFile(), PullRequestComments.class);
assertThat(commentsOfTwo.getComments()).hasSize(3).extracting(Comment::getLocation).containsOnly(new Location("README.md", "@@ -1,3 +1,41 @@", null, 39), new Location("README.md", "@@ -1,3 +1,41 @@", 39, null), new Location("README.md", "@@ -1,3 +1,41 @@", 39, 39));
}
use of com.cloudogu.scm.review.comment.service.Location in project scm-review-plugin by scm-manager.
the class RemoveReviewMarksOnChangedCommentsHook method checkForLocation.
private <C extends BasicComment, T extends BasicCommentEvent<C>> void checkForLocation(T event, Function<C, Location> locationExtractor) {
if (event.getEventType() == HandlerEventType.DELETE) {
return;
}
Location location = locationExtractor.apply(event.getItem());
if (location == null) {
return;
}
Collection<ReviewMark> reviewMarksToBeRemoved = event.getPullRequest().getReviewMarks().stream().filter(mark -> mark.getFile().equals(location.getFile())).collect(Collectors.toList());
pullRequestService.removeReviewMarks(event.getRepository(), event.getPullRequest().getId(), reviewMarksToBeRemoved);
}
use of com.cloudogu.scm.review.comment.service.Location in project scm-review-plugin by scm-manager.
the class MentionMapperTest method shouldParseUserIdsToDisplayNames.
@Test
void shouldParseUserIdsToDisplayNames() {
setupExistingUserMock("dent", "Arthur Dent", "dent@hitchhiker.org");
setupExistingUserMock("_anonymous", "SCM Anonymous", "anonymous@hitchhiker.org");
BasicComment unparsedComment = Comment.createComment("1", "new comment @[dent] @[_anonymous]", "author", new Location());
unparsedComment.setMentionUserIds(ImmutableSet.of("dent", "_anonymous"));
BasicComment parsedComment = mentionMapper.parseMentionsUserIdsToDisplayNames(unparsedComment);
assertThat(parsedComment.getComment()).isEqualTo("new comment @Arthur Dent @SCM Anonymous");
}
use of com.cloudogu.scm.review.comment.service.Location in project scm-review-plugin by scm-manager.
the class RemoveReviewMarksOnChangedCommentsHookTest method shouldNotRemoveMarksOnNewCommentWithDifferentLocation.
@Test
void shouldNotRemoveMarksOnNewCommentWithDifferentLocation() {
comment.setLocation(new Location("some/other/file"));
pullRequest.setReviewMarks(of(new ReviewMark("some/file", "dent")));
CommentEvent event = new CommentEvent(repository, pullRequest, comment, null, HandlerEventType.CREATE);
hook.handleCommentEvents(event);
verify(pullRequestService, atMost(1)).removeReviewMarks(repository, pullRequest.getId(), emptyList());
}
use of com.cloudogu.scm.review.comment.service.Location in project scm-review-plugin by scm-manager.
the class RemoveReviewMarksOnChangedCommentsHookTest method shouldRemoveMarksOnNewCommentWithSameLocation.
@Test
void shouldRemoveMarksOnNewCommentWithSameLocation() {
comment.setLocation(new Location("some/file"));
pullRequest.setReviewMarks(of(new ReviewMark("some/file", "dent")));
CommentEvent event = new CommentEvent(repository, pullRequest, comment, null, HandlerEventType.CREATE);
hook.handleCommentEvents(event);
verify(pullRequestService).removeReviewMarks(repository, pullRequest.getId(), singletonList(new ReviewMark("some/file", "dent")));
}
Aggregations