use of com.cloudogu.scm.review.comment.service.BasicComment in project scm-review-plugin by scm-manager.
the class MentionMapper method parseMentionsUserIdsToDisplayNames.
public BasicComment parseMentionsUserIdsToDisplayNames(BasicComment rootComment) {
BasicComment comment = rootComment.clone();
for (String mentionUserId : rootComment.getMentionUserIds()) {
Optional<DisplayUser> user = userDisplayManager.get(mentionUserId);
user.ifPresent(displayUser -> comment.setComment(comment.getComment().replaceAll("\\[" + mentionUserId + "]", displayUser.getDisplayName())));
}
return comment;
}
use of com.cloudogu.scm.review.comment.service.BasicComment in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldAllowModificationsForAuthor.
@Test
@SubjectAware(username = "trillian", password = "secret")
public void shouldAllowModificationsForAuthor() {
BasicComment comment = createComment("trillian");
boolean modificationsAllowed = PermissionCheck.mayModifyComment(createRepository(), comment);
assertTrue(modificationsAllowed);
}
use of com.cloudogu.scm.review.comment.service.BasicComment in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldDisallowModificationsForNonAuthorWithoutPermission.
@Test
@SubjectAware(username = "trillian", password = "secret")
public void shouldDisallowModificationsForNonAuthorWithoutPermission() {
BasicComment comment = createComment("other");
boolean modificationsAllowed = PermissionCheck.mayModifyComment(createRepository(), comment);
assertFalse(modificationsAllowed);
}
use of com.cloudogu.scm.review.comment.service.BasicComment in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldFailOnModificationsForNonAuthorWithoutPermission.
@Test(expected = UnauthorizedException.class)
@SubjectAware(username = "trillian", password = "secret")
public void shouldFailOnModificationsForNonAuthorWithoutPermission() {
BasicComment comment = createComment("other");
PermissionCheck.checkModifyComment(createRepository(), comment);
}
use of com.cloudogu.scm.review.comment.service.BasicComment 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);
}
Aggregations