aboutsummaryrefslogtreecommitdiffstats
path: root/server
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
parentb6bffded1c8e125cb2621b47ddcb9ddb0799b98f (diff)
downloadsonarqube-2c36dc6f775adbdbd6688a9329064ec0ff332941.tar.gz
sonarqube-2c36dc6f775adbdbd6688a9329064ec0ff332941.zip
SONAR-17412 minor fixes on log and tests (#6812)
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java2
-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
6 files changed, 15 insertions, 8 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java b/server/sonar-server-common/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java
index 2e27ce531f5..261bd7fee94 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java
@@ -51,7 +51,7 @@ public class FavoriteUpdater {
.setUserUuid(userUuid)
.setComponentUuid(componentDto.uuid())
.build(), dbSession);
- checkArgument(existingFavoriteOnComponent.isEmpty(), "Component '%s' is already a favorite", componentDto.getKey());
+ checkArgument(existingFavoriteOnComponent.isEmpty(), "Component '%s' (uuid: %s) is already a favorite", componentDto.getKey(), componentDto.uuid());
List<PropertyDto> existingFavorites = dbClient.propertiesDao().selectByKeyAndUserUuidAndComponentQualifier(dbSession, PROP_FAVORITE_KEY, userUuid, componentDto.qualifier());
if (existingFavorites.size() >= 100) {
@@ -81,6 +81,6 @@ public class FavoriteUpdater {
.setComponentUuid(component.uuid())
.setUserUuid(userUuid),
userLogin, component.getKey(), component.name(), component.qualifier());
- checkArgument(result == 1, "Component '%s' is not a favorite", component.getKey());
+ checkArgument(result == 1, "Component '%s' (uuid: %s) is not a favorite", component.getKey(), component.uuid());
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java
index 3678a2656eb..8bcd228f662 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java
@@ -118,7 +118,7 @@ public class FavoriteUpdaterTest {
assertThatThrownBy(() -> underTest.add(dbSession, project, user.getUuid(), user.getLogin(), true))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage(String.format("Component '%s' is already a favorite", project.getKey()));
+ .hasMessage(String.format("Component '%s' (uuid: %s) is already a favorite", project.getKey(), project.uuid()));
}
private void assertFavorite(ComponentDto project, UserDto user) {
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