Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Updating CHANGELOG.md
Browse files Browse the repository at this point in the history
 * And correcting test case assertion for reviewers variables.
  • Loading branch information
tomasbjerre committed Jan 26, 2016
1 parent 91e0c43 commit f016b29
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Changelog of Pull Request Notifier for Bitbucket.

## 2.14
* Bugfix: Fixing IndexOutOfBoundsException if no reviewers and using reviewers variable

## 2.13
* Allowing SSL certificates to be ignored.
* Adding settings to configure custom keystore.
Expand Down
42 changes: 12 additions & 30 deletions src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package se.bjurr.prnfb.listener;

import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.base.Joiner.on;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Ordering.usingToString;
import static java.net.URLEncoder.encode;
import static java.util.logging.Logger.getLogger;
import static java.util.regex.Pattern.compile;
Expand Down Expand Up @@ -447,51 +450,25 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullReques
ApplicationUser applicationUser, RepositoryService repositoryService,
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());

if (slist.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (PullRequestParticipant each : slist) {
sb.append("," + each.getUser().getDisplayName());
}
return sb.substring(1);
return iterableToString(transform(pullRequest.getReviewers(), (p) -> p.getUser().getDisplayName()));
}
}), PULL_REQUEST_REVIEWERS_ID(new Resolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
ApplicationUser applicationUser, RepositoryService repositoryService,
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());

if (slist.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (PullRequestParticipant each : slist) {
sb.append("," + each.getUser().getId());
}
return sb.substring(1);
return iterableToString(transform(pullRequest.getReviewers(), (p) -> Integer.toString(p.getUser().getId())));
}
}), PULL_REQUEST_REVIEWERS_SLUG(new Resolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
ApplicationUser applicationUser, RepositoryService repositoryService,
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());

if (slist.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (PullRequestParticipant each : slist) {
sb.append("," + each.getUser().getSlug());
}
return sb.substring(1);
return iterableToString(transform(pullRequest.getReviewers(), (p) -> p.getUser().getSlug()));
}

}), PULL_REQUEST_REVIEWERS_APPROVED_COUNT(new Resolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
Expand All @@ -517,6 +494,11 @@ public boolean apply(PullRequestParticipant input) {
}
};

private static String iterableToString(Iterable<String> slist) {
List<String> sorted = usingToString().sortedCopy(slist);
return on(',').join(sorted);
}

private Resolver resolver;

private static String cloneUrlFromRepository(REPO_PROTOCOL protocol, Repository repository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ public void testThatAdminFormFieldsAreUsedInAdminGUI() throws IOException {
public void testThatAUrlCanHaveSeveralVariables() throws Exception {
prnfbTestBuilder()
.isLoggedInAsAdmin()
.withPullRequest(//
pullRequestEventBuilder()//
.withParticipantReviewer(REVIEWER, false, "First Last", "firstlast", 1)//
.withParticipantReviewer(REVIEWER, false, "First2 Last2", "firstlast2", 5)//
.withParticipant(PARTICIPANT)//
.build()//
.getPullRequest())
.withNotification( //
notificationBuilder() //
.withFieldValue(
Expand Down Expand Up @@ -144,11 +137,13 @@ public void testThatAUrlCanHaveSeveralVariables() throws Exception {
.withParticipantReviewer(AUTHOR, TRUE) //
.withParticipantReviewer(AUTHOR, TRUE) //
.withParticipantReviewer(AUTHOR, FALSE) //
.withParticipantReviewer(REVIEWER, false, "First Last", "firstlast", 1)//
.withParticipantReviewer(REVIEWER, false, "First2 Last2", "firstlast2", 5)//
.build() //
) //
.invokedUrl(
0,
"http://bjurr.se/?PULL_REQUEST_FROM_HASH=cde456&PULL_REQUEST_TO_HASH=asd123&PULL_REQUEST_FROM_REPO_SLUG=fromslug&PULL_REQUEST_TO_REPO_SLUG=toslug&revapp=2&partapp=3&reviewers=name%2Cname%2Cname&reviewersid=1%2C1%2C1&reviewersslug=username%2Cusername%2Cusername") //
"http://bjurr.se/?PULL_REQUEST_FROM_HASH=cde456&PULL_REQUEST_TO_HASH=asd123&PULL_REQUEST_FROM_REPO_SLUG=fromslug&PULL_REQUEST_TO_REPO_SLUG=toslug&revapp=2&partapp=3&reviewers=First+Last%2CFirst2+Last2%2Cname%2Cname%2Cname&reviewersid=1%2C1%2C1%2C1%2C5&reviewersslug=firstlast%2Cfirstlast2%2Cusername%2Cusername%2Cusername") //
.invokedMethod(GET);
}

Expand Down

0 comments on commit f016b29

Please sign in to comment.