SimpleMergeRequestManager implements MergeRequestManager { @Override public void deleteComment(Resource commentId) { try (RepositoryConnection conn = configProvider.getRepository().getConnection()) { Comment comment = getComment(commentId, conn).orElseThrow( () -> new IllegalArgumentException("Comment " + commentId + " does not exist")); Iterator<Statement> statements = conn.getStatements(null, vf.createIRI(Comment.replyComment_IRI), commentId); if (statements.hasNext()) { Resource parentCommentIRI = statements.next().getSubject(); Optional<Comment> parentCommentOpt = getComment(parentCommentIRI, conn); Optional<Resource> childCommentResourceOpt = comment.getReplyComment_resource(); if (childCommentResourceOpt.isPresent() && parentCommentOpt.isPresent()) { Comment childComment = getComment(childCommentResourceOpt.get(), conn).orElseThrow( () -> new IllegalArgumentException("Child comment " + childCommentResourceOpt.get() + " does not exist")); Comment parentComment = parentCommentOpt.get(); parentComment.setReplyComment(childComment); updateComment(parentComment.getResource(), parentComment); } else if (!childCommentResourceOpt.isPresent() && parentCommentOpt.isPresent()) { Comment parentComment = parentCommentOpt.get(); parentComment.removeProperty(commentId, vf.createIRI(Comment.replyComment_IRI)); updateComment(parentComment.getResource(), parentComment); } } catalogUtils.validateResource(commentId, commentFactory.getTypeIRI(), conn); catalogUtils.remove(commentId, conn); } }  @Override List<MergeRequest> getMergeRequests(MergeRequestFilterParams params); @Override List<MergeRequest> getMergeRequests(MergeRequestFilterParams params, RepositoryConnection conn); @Override MergeRequest createMergeRequest(MergeRequestConfig config, Resource localCatalog); @Override MergeRequest createMergeRequest(MergeRequestConfig config, Resource localCatalog,
                                           RepositoryConnection conn); @Override void addMergeRequest(MergeRequest request); @Override void addMergeRequest(MergeRequest request, RepositoryConnection conn); @Override Optional<MergeRequest> getMergeRequest(Resource requestId); @Override Optional<MergeRequest> getMergeRequest(Resource requestId, RepositoryConnection conn); @Override void updateMergeRequest(Resource requestId, MergeRequest request); @Override void updateMergeRequest(Resource requestId, MergeRequest request, RepositoryConnection conn); @Override void deleteMergeRequest(Resource requestId); @Override void deleteMergeRequest(Resource requestId, RepositoryConnection conn); @Override void acceptMergeRequest(Resource requestId, User user); @Override void acceptMergeRequest(Resource requestId, User user,  RepositoryConnection conn); @Override void deleteMergeRequestsWithRecordId(Resource recordId); @Override void deleteMergeRequestsWithRecordId(Resource recordId, RepositoryConnection conn); @Override void cleanMergeRequests(Resource recordId, Resource branchId); @Override void cleanMergeRequests(Resource recordId, Resource branchId, RepositoryConnection conn); @Override Comment createComment(Resource requestId, User user, String commentStr); @Override Comment createComment(Resource requestId, User user, String commentStr, Resource parentCommentId); @Override List<List<Comment>> getComments(Resource requestId); @Override Optional<Comment> getComment(Resource commentId); @Override Optional<Comment> getComment(Resource commentId, RepositoryConnection conn); @Override void updateComment(Resource commentId, Comment comment); @Override void deleteComment(Resource commentId); @Override void deleteCommentsWithRequestId(Resource requestId);  }
@Test public void deleteCommentDoesNotExistTest() { thrown.expect(IllegalArgumentException.class); manager.deleteComment(DOES_NOT_EXIST_IRI); verify(utilsService).validateResource(eq(DOES_NOT_EXIST_IRI), eq(commentFactory.getTypeIRI()), any(RepositoryConnection.class)); }