|
1 | 1 | package se.bjurr.prnfb.service; |
2 | 2 |
|
| 3 | +import static com.atlassian.bitbucket.pull.PullRequestParticipantStatus.APPROVED; |
3 | 4 | import static com.atlassian.bitbucket.pull.PullRequestParticipantStatus.NEEDS_WORK; |
4 | 5 | import static com.atlassian.bitbucket.pull.PullRequestParticipantStatus.UNAPPROVED; |
5 | 6 | import static com.google.common.base.Joiner.on; |
@@ -582,6 +583,177 @@ public String resolve( |
582 | 583 | transform(pullRequest.getReviewers(), (p) -> p.getUser().getEmailAddress())); |
583 | 584 | } |
584 | 585 | }), |
| 586 | + PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG( |
| 587 | + new PrnfbVariableResolver() { |
| 588 | + @Override |
| 589 | + public String resolve( |
| 590 | + PullRequest pullRequest, |
| 591 | + PrnfbPullRequestAction pullRequestAction, |
| 592 | + ApplicationUser applicationUser, |
| 593 | + RepositoryService repositoryService, |
| 594 | + ApplicationPropertiesService propertiesService, |
| 595 | + PrnfbNotification prnfbNotification, |
| 596 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 597 | + ClientKeyStore clientKeyStore, |
| 598 | + boolean shouldAcceptAnyCertificate, |
| 599 | + SecurityService securityService) { |
| 600 | + Iterable<PullRequestParticipant> reviewers = |
| 601 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == NEEDS_WORK); |
| 602 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getSlug())); |
| 603 | + } |
| 604 | + }), |
| 605 | + PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL( |
| 606 | + new PrnfbVariableResolver() { |
| 607 | + @Override |
| 608 | + public String resolve( |
| 609 | + PullRequest pullRequest, |
| 610 | + PrnfbPullRequestAction pullRequestAction, |
| 611 | + ApplicationUser applicationUser, |
| 612 | + RepositoryService repositoryService, |
| 613 | + ApplicationPropertiesService propertiesService, |
| 614 | + PrnfbNotification prnfbNotification, |
| 615 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 616 | + ClientKeyStore clientKeyStore, |
| 617 | + boolean shouldAcceptAnyCertificate, |
| 618 | + SecurityService securityService) { |
| 619 | + Iterable<PullRequestParticipant> reviewers = |
| 620 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == NEEDS_WORK); |
| 621 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getEmailAddress())); |
| 622 | + } |
| 623 | + }), |
| 624 | + PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME( |
| 625 | + new PrnfbVariableResolver() { |
| 626 | + @Override |
| 627 | + public String resolve( |
| 628 | + PullRequest pullRequest, |
| 629 | + PrnfbPullRequestAction pullRequestAction, |
| 630 | + ApplicationUser applicationUser, |
| 631 | + RepositoryService repositoryService, |
| 632 | + ApplicationPropertiesService propertiesService, |
| 633 | + PrnfbNotification prnfbNotification, |
| 634 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 635 | + ClientKeyStore clientKeyStore, |
| 636 | + boolean shouldAcceptAnyCertificate, |
| 637 | + SecurityService securityService) { |
| 638 | + Iterable<PullRequestParticipant> reviewers = |
| 639 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == NEEDS_WORK); |
| 640 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getName())); |
| 641 | + } |
| 642 | + }), |
| 643 | + PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG( |
| 644 | + new PrnfbVariableResolver() { |
| 645 | + @Override |
| 646 | + public String resolve( |
| 647 | + PullRequest pullRequest, |
| 648 | + PrnfbPullRequestAction pullRequestAction, |
| 649 | + ApplicationUser applicationUser, |
| 650 | + RepositoryService repositoryService, |
| 651 | + ApplicationPropertiesService propertiesService, |
| 652 | + PrnfbNotification prnfbNotification, |
| 653 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 654 | + ClientKeyStore clientKeyStore, |
| 655 | + boolean shouldAcceptAnyCertificate, |
| 656 | + SecurityService securityService) { |
| 657 | + Iterable<PullRequestParticipant> reviewers = |
| 658 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == UNAPPROVED); |
| 659 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getSlug())); |
| 660 | + } |
| 661 | + }), |
| 662 | + PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL( |
| 663 | + new PrnfbVariableResolver() { |
| 664 | + @Override |
| 665 | + public String resolve( |
| 666 | + PullRequest pullRequest, |
| 667 | + PrnfbPullRequestAction pullRequestAction, |
| 668 | + ApplicationUser applicationUser, |
| 669 | + RepositoryService repositoryService, |
| 670 | + ApplicationPropertiesService propertiesService, |
| 671 | + PrnfbNotification prnfbNotification, |
| 672 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 673 | + ClientKeyStore clientKeyStore, |
| 674 | + boolean shouldAcceptAnyCertificate, |
| 675 | + SecurityService securityService) { |
| 676 | + Iterable<PullRequestParticipant> reviewers = |
| 677 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == UNAPPROVED); |
| 678 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getEmailAddress())); |
| 679 | + } |
| 680 | + }), |
| 681 | + PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME( |
| 682 | + new PrnfbVariableResolver() { |
| 683 | + @Override |
| 684 | + public String resolve( |
| 685 | + PullRequest pullRequest, |
| 686 | + PrnfbPullRequestAction pullRequestAction, |
| 687 | + ApplicationUser applicationUser, |
| 688 | + RepositoryService repositoryService, |
| 689 | + ApplicationPropertiesService propertiesService, |
| 690 | + PrnfbNotification prnfbNotification, |
| 691 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 692 | + ClientKeyStore clientKeyStore, |
| 693 | + boolean shouldAcceptAnyCertificate, |
| 694 | + SecurityService securityService) { |
| 695 | + Iterable<PullRequestParticipant> reviewers = |
| 696 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == UNAPPROVED); |
| 697 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getName())); |
| 698 | + } |
| 699 | + }), |
| 700 | + PULL_REQUEST_REVIEWERS_APPROVED_SLUG( |
| 701 | + new PrnfbVariableResolver() { |
| 702 | + @Override |
| 703 | + public String resolve( |
| 704 | + PullRequest pullRequest, |
| 705 | + PrnfbPullRequestAction pullRequestAction, |
| 706 | + ApplicationUser applicationUser, |
| 707 | + RepositoryService repositoryService, |
| 708 | + ApplicationPropertiesService propertiesService, |
| 709 | + PrnfbNotification prnfbNotification, |
| 710 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 711 | + ClientKeyStore clientKeyStore, |
| 712 | + boolean shouldAcceptAnyCertificate, |
| 713 | + SecurityService securityService) { |
| 714 | + Iterable<PullRequestParticipant> reviewers = |
| 715 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == APPROVED); |
| 716 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getSlug())); |
| 717 | + } |
| 718 | + }), |
| 719 | + PULL_REQUEST_REVIEWERS_APPROVED_EMAIL( |
| 720 | + new PrnfbVariableResolver() { |
| 721 | + @Override |
| 722 | + public String resolve( |
| 723 | + PullRequest pullRequest, |
| 724 | + PrnfbPullRequestAction pullRequestAction, |
| 725 | + ApplicationUser applicationUser, |
| 726 | + RepositoryService repositoryService, |
| 727 | + ApplicationPropertiesService propertiesService, |
| 728 | + PrnfbNotification prnfbNotification, |
| 729 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 730 | + ClientKeyStore clientKeyStore, |
| 731 | + boolean shouldAcceptAnyCertificate, |
| 732 | + SecurityService securityService) { |
| 733 | + Iterable<PullRequestParticipant> reviewers = |
| 734 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == APPROVED); |
| 735 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getEmailAddress())); |
| 736 | + } |
| 737 | + }), |
| 738 | + PULL_REQUEST_REVIEWERS_APPROVED_NAME( |
| 739 | + new PrnfbVariableResolver() { |
| 740 | + @Override |
| 741 | + public String resolve( |
| 742 | + PullRequest pullRequest, |
| 743 | + PrnfbPullRequestAction pullRequestAction, |
| 744 | + ApplicationUser applicationUser, |
| 745 | + RepositoryService repositoryService, |
| 746 | + ApplicationPropertiesService propertiesService, |
| 747 | + PrnfbNotification prnfbNotification, |
| 748 | + Map<PrnfbVariable, Supplier<String>> variables, |
| 749 | + ClientKeyStore clientKeyStore, |
| 750 | + boolean shouldAcceptAnyCertificate, |
| 751 | + SecurityService securityService) { |
| 752 | + Iterable<PullRequestParticipant> reviewers = |
| 753 | + filter(pullRequest.getReviewers(), (r) -> r.getStatus() == APPROVED); |
| 754 | + return iterableToString(transform(reviewers, (p) -> p.getUser().getName())); |
| 755 | + } |
| 756 | + }), |
585 | 757 | PULL_REQUEST_REVIEWERS_ID( |
586 | 758 | new PrnfbVariableResolver() { |
587 | 759 | @Override |
|
0 commit comments