diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-08-05 22:46:36 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-08-05 22:53:18 +0200 |
commit | fac1e96e643d8d2c33d86e87135f4acde895e273 (patch) | |
tree | f544ed98a06a7a64cded8661c8a9f0f2f4a96369 | |
parent | c4958011d0e2e59aa8a79509b59a05878bd8dab2 (diff) | |
download | sonarqube-fac1e96e643d8d2c33d86e87135f4acde895e273.tar.gz sonarqube-fac1e96e643d8d2c33d86e87135f4acde895e273.zip |
WS api/issues/plan and assign must return 400 if bad params
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java | 5 | ||||
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java index d7b07826d64..7b91364234b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java @@ -53,6 +53,7 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.issue.IssueDto; import org.sonar.server.es.SearchOptions; import org.sonar.server.es.SearchResult; +import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.index.IssueDoc; @@ -181,7 +182,7 @@ public class IssueService { if (!Strings.isNullOrEmpty(assignee)) { user = userFinder.findByLogin(assignee); if (user == null) { - throw new NotFoundException("Unknown user: " + assignee); + throw new BadRequestException("Unknown user: " + assignee); } } IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin()); @@ -204,7 +205,7 @@ public class IssueService { if (!Strings.isNullOrEmpty(actionPlanKey)) { actionPlan = actionPlanService.findByKey(actionPlanKey, userSession); if (actionPlan == null) { - throw new NotFoundException("Unknown action plan: " + actionPlanKey); + throw new BadRequestException("Unknown action plan: " + actionPlanKey); } } DefaultIssue issue = getByKeyForUpdate(session, issueKey).toDefaultIssue(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java index e089f14fe15..3656c5bcf38 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java @@ -56,6 +56,7 @@ import org.sonar.db.user.UserDto; import org.sonar.server.component.ComponentTesting; import org.sonar.server.es.SearchOptions; import org.sonar.server.es.SearchResult; +import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.issue.index.IssueDoc; @@ -225,7 +226,7 @@ public class IssueServiceMediumTest { service.assign(issue.getKey(), "unknown"); fail(); } catch (Exception e) { - assertThat(e).isInstanceOf(NotFoundException.class).hasMessage("Unknown user: unknown"); + assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("Unknown user: unknown"); } } @@ -280,7 +281,7 @@ public class IssueServiceMediumTest { service.plan(issue.getKey(), "unknown"); fail(); } catch (Exception e) { - assertThat(e).isInstanceOf(NotFoundException.class).hasMessage("Unknown action plan: unknown"); + assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("Unknown action plan: unknown"); } } |