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;
}
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 {
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;
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);