diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-07-18 18:17:44 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-07-18 18:20:58 +0200 |
commit | 4bdf4fea4c183147b9dc50436232d6e8a87d07c5 (patch) | |
tree | de80bee9fa29a44158e3d9a02e275c8ff01b4230 | |
parent | 6b1eb68b6b65e4cf69c5632892a3bced829ffb75 (diff) | |
download | sonarqube-4bdf4fea4c183147b9dc50436232d6e8a87d07c5.tar.gz sonarqube-4bdf4fea4c183147b9dc50436232d6e8a87d07c5.zip |
Restore BadRequestException when action is not found
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeService.java | 9 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceTest.java | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeService.java b/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeService.java index 55cf6efb5e1..dc9253a3910 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeService.java @@ -32,6 +32,7 @@ import org.sonar.api.issue.internal.IssueChangeContext; import org.sonar.api.web.UserRole; import org.sonar.core.issue.IssueNotifications; import org.sonar.core.issue.db.IssueStorage; +import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.user.UserSession; import java.util.Date; @@ -110,12 +111,16 @@ public class IssueBulkChangeService { } private Action getAction(final String actionKey) { - return Iterables.find(actions, new Predicate<Action>() { + Action action = Iterables.find(actions, new Predicate<Action>() { @Override public boolean apply(Action action) { return action.key().equals(actionKey); } - }); + }, null); + if (action == null) { + throw new BadRequestException("The action : '"+ actionKey + "' is unknown"); + } + return action; } static class ActionContext implements Action.Context { diff --git a/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceTest.java index 6a9ac61b342..70281632224 100644 --- a/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceTest.java @@ -32,13 +32,13 @@ import org.sonar.api.issue.internal.IssueChangeContext; import org.sonar.api.web.UserRole; import org.sonar.core.issue.IssueNotifications; import org.sonar.core.issue.db.IssueStorage; +import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.user.MockUserSession; import org.sonar.server.user.UserSession; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; @@ -277,7 +277,7 @@ public class IssueBulkChangeServiceTest { service.execute(issueBulkChangeQuery, userSession); fail(); } catch (Exception e) { - assertThat(e).isInstanceOf(NoSuchElementException.class); + assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("The action : 'unknown' is unknown"); } verifyZeroInteractions(issueStorage); verifyZeroInteractions(issueNotifications); |