aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorLéo Geoffroy <99647462+leo-geoffroy-sonarsource@users.noreply.github.com>2022-10-11 09:23:16 +0200
committersonartech <sonartech@sonarsource.com>2022-10-12 20:03:44 +0000
commit2c36dc6f775adbdbd6688a9329064ec0ff332941 (patch)
tree46eba88e9c4b173ddd72697ad00b367555184c4e /server/sonar-webserver-webapi
parentb6bffded1c8e125cb2621b47ddcb9ddb0799b98f (diff)
downloadsonarqube-2c36dc6f775adbdbd6688a9329064ec0ff332941.tar.gz
sonarqube-2c36dc6f775adbdbd6688a9329064ec0ff332941.zip
SONAR-17412 minor fixes on log and tests (#6812)
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesAction.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java4
4 files changed, 12 insertions, 5 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java
index 35e910cfba7..ff8cb14dcc3 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java
@@ -78,7 +78,8 @@ public class LiveMeasureTreeUpdaterImpl implements LiveMeasureTreeUpdater {
try {
formula.computeHierarchy(context);
} catch (RuntimeException e) {
- throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on " + context.getComponent().getKey(), e);
+ throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on "
+ + context.getComponent().getKey() + " (uuid: " + context.getComponent().uuid() + ")", e);
}
}
}
@@ -98,7 +99,8 @@ public class LiveMeasureTreeUpdaterImpl implements LiveMeasureTreeUpdater {
try {
formula.compute(context, issueCounter);
} catch (RuntimeException e) {
- throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on " + context.getComponent().getKey(), e);
+ throw new IllegalStateException("Fail to compute " + formula.getMetric().getKey() + " on "
+ + context.getComponent().getKey() + " (uuid: " + context.getComponent().uuid() + ")", e);
}
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesAction.java
index 109205b4b7f..9696837f164 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/ws/LinesAction.java
@@ -146,7 +146,8 @@ public class LinesAction implements SourcesWsAction {
int from = request.mandatoryParamAsInt(PARAM_FROM);
int to = MoreObjects.firstNonNull(request.paramAsInt(PARAM_TO), Integer.MAX_VALUE);
- Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.getKey());
+ Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to),
+ "No source found for file '%s' (uuid: %s)", file.getKey(), file.uuid());
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject();
linesJsonWriter.writeSource(lines, json, periodDateSupplier);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
index f71292b5740..aa613ea067a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
@@ -270,12 +270,14 @@ public class DuplicationsParserTest {
Duplication duplication1 = duplications.get(0);
assertThat(duplication1.componentDto()).isEqualTo(file1);
assertThat(duplication1.componentDto().getKey()).isEqualTo(file1.getKey());
+ assertThat(duplication1.componentDto().branchUuid()).isEqualTo(branch.uuid());
assertThat(duplication1.from()).isEqualTo(31);
assertThat(duplication1.size()).isEqualTo(5);
Duplication duplication2 = duplications.get(1);
assertThat(duplication2.componentDto()).isEqualTo(file2);
assertThat(duplication2.componentDto().getKey()).isEqualTo(file2.getKey());
+ assertThat(duplication1.componentDto().branchUuid()).isEqualTo(branch.uuid());
assertThat(duplication2.from()).isEqualTo(20);
assertThat(duplication2.size()).isEqualTo(5);
}
@@ -303,12 +305,14 @@ public class DuplicationsParserTest {
Duplication duplication1 = duplications.get(0);
assertThat(duplication1.componentDto()).isEqualTo(file1);
assertThat(duplication1.componentDto().getKey()).isEqualTo(file1.getKey());
+ assertThat(duplication1.componentDto().branchUuid()).isEqualTo(pullRequest.uuid());
assertThat(duplication1.from()).isEqualTo(31);
assertThat(duplication1.size()).isEqualTo(5);
Duplication duplication2 = duplications.get(1);
assertThat(duplication2.componentDto()).isEqualTo(file2);
assertThat(duplication2.componentDto().getKey()).isEqualTo(file2.getKey());
+ assertThat(duplication1.componentDto().branchUuid()).isEqualTo(pullRequest.uuid());
assertThat(duplication2.from()).isEqualTo(20);
assertThat(duplication2.size()).isEqualTo(5);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
index d8a5b32a352..39d77aecff0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
@@ -82,11 +82,11 @@ public class RemoveActionTest {
@Test
public void fail_if_not_already_a_favorite() {
- insertProjectAndPermissions();
+ ComponentDto componentDto = insertProjectAndPermissions();
assertThatThrownBy(() -> call(PROJECT_KEY))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Component '" + PROJECT_KEY + "' is not a favorite");
+ .hasMessage("Component '" + PROJECT_KEY + "' (uuid: "+componentDto.uuid()+") is not a favorite");
}
@Test