aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-08-05 23:26:17 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-08-05 23:50:15 +0200
commit4d119d3c92675105c46ead03ca6eeadb540b7987 (patch)
tree145644d5cf86e8e641037c5c1093ff4f1cbfc721 /server
parentfac1e96e643d8d2c33d86e87135f4acde895e273 (diff)
downloadsonarqube-4d119d3c92675105c46ead03ca6eeadb540b7987.tar.gz
sonarqube-4d119d3c92675105c46ead03ca6eeadb540b7987.zip
WS api/issues/create must return 400 if component does not exist
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java19
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java5
2 files changed, 11 insertions, 13 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 7b91364234b..d57ab537439 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
@@ -54,7 +54,6 @@ 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;
import org.sonar.server.issue.index.IssueIndex;
@@ -84,14 +83,14 @@ public class IssueService {
private final UserSession userSession;
public IssueService(DbClient dbClient, IssueIndex issueIndex,
- IssueWorkflow workflow,
- IssueStorage issueStorage,
- IssueUpdater issueUpdater,
- NotificationManager notificationService,
- ActionPlanService actionPlanService,
- RuleFinder ruleFinder,
- UserFinder userFinder,
- UserIndex userIndex, SourceLineIndex sourceLineIndex, UserSession userSession) {
+ IssueWorkflow workflow,
+ IssueStorage issueStorage,
+ IssueUpdater issueUpdater,
+ NotificationManager notificationService,
+ ActionPlanService actionPlanService,
+ RuleFinder ruleFinder,
+ UserFinder userFinder,
+ UserIndex userIndex, SourceLineIndex sourceLineIndex, UserSession userSession) {
this.dbClient = dbClient;
this.issueIndex = issueIndex;
this.workflow = workflow;
@@ -246,7 +245,7 @@ public class IssueService {
try {
Optional<ComponentDto> componentOptional = dbClient.componentDao().selectByKey(session, componentKey);
if (!componentOptional.isPresent()) {
- throw new NotFoundException(String.format("Component with key '%s' not found", componentKey));
+ throw new BadRequestException(String.format("Component with key '%s' not found", componentKey));
}
ComponentDto component = componentOptional.get();
ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid());
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 3656c5bcf38..52bd7cdd062 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
@@ -58,7 +58,6 @@ 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;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.index.IssueIndexDefinition;
@@ -436,7 +435,7 @@ public class IssueServiceMediumTest {
}
@Test(expected = IllegalArgumentException.class)
- public void fail_create_manual_issue_if_rule_does_not_exists() {
+ public void fail_create_manual_issue_if_rule_does_not_exist() {
ComponentDto project = newProject();
ComponentDto file = newFile(project);
userSessionRule.login("john").addProjectPermissions(UserRole.USER, project.key());
@@ -460,7 +459,7 @@ public class IssueServiceMediumTest {
service.createManualIssue(file.key(), rule.getKey(), 10, "Fix it", null);
}
- @Test(expected = NotFoundException.class)
+ @Test(expected = BadRequestException.class)
public void fail_to_create_manual_issue_on_unknown_component() {
ComponentDto project = newProject();
userSessionRule.login("john").addProjectPermissions(UserRole.USER, project.key());