aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-12-05 11:21:28 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-12-05 18:10:32 +0100
commit25cb6851756588388c4746ad60e32ed339abdf92 (patch)
treed8953bae93318911665168560dc0bdf40344f1b0 /server/sonar-server
parentf0b7fcd2a971b179dddaef1d0916500b898efdd5 (diff)
downloadsonarqube-25cb6851756588388c4746ad60e32ed339abdf92.tar.gz
sonarqube-25cb6851756588388c4746ad60e32ed339abdf92.zip
SONAR-8450 Return project description in api/navigation/component WS
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java12
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java6
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json1
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json1
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json1
6 files changed, 15 insertions, 7 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
index 9b1daa4dd95..cbbcf30fcb5 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
@@ -112,23 +112,23 @@ public class ComponentNavigationAction implements NavigationWsAction {
JsonWriter json = response.newJsonWriter();
json.beginObject();
- writeComponent(json, session, component, analysis.orElse(null), userSession);
+ writeComponent(json, session, component, analysis.orElse(null));
if (userSession.hasComponentUuidPermission(ADMIN, component.projectUuid()) || userSession.hasPermission(QUALITY_PROFILE_ADMIN)) {
- writeConfiguration(json, component, userSession);
+ writeConfiguration(json, component);
}
writeBreadCrumbs(json, session, component);
json.endObject().close();
}
}
- private void writeComponent(JsonWriter json, DbSession session, ComponentDto component, @Nullable SnapshotDto analysis, UserSession userSession) {
+ private void writeComponent(JsonWriter json, DbSession session, ComponentDto component, @Nullable SnapshotDto analysis) {
json.prop("key", component.key())
.prop("uuid", component.uuid())
.prop("name", component.name())
.prop("description", component.description())
.prop("isComparable", componentTypeHasProperty(component, PROPERTY_COMPARABLE))
.prop("canBeFavorite", userSession.isLoggedIn())
- .prop("isFavorite", isFavourite(session, component, userSession));
+ .prop("isFavorite", isFavourite(session, component));
if (analysis != null) {
json.prop("version", analysis.getVersion())
@@ -138,7 +138,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
}
}
- private boolean isFavourite(DbSession session, ComponentDto component, UserSession userSession) {
+ private boolean isFavourite(DbSession session, ComponentDto component) {
PropertyQuery propertyQuery = PropertyQuery.builder()
.setUserId(userSession.getUserId())
.setKey("favourite")
@@ -179,7 +179,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
return componentKey;
}
- private void writeConfiguration(JsonWriter json, ComponentDto component, UserSession userSession) {
+ private void writeConfiguration(JsonWriter json, ComponentDto component) {
boolean isAdmin = userSession.hasComponentUuidPermission(ADMIN, component.projectUuid());
json.name("configuration").beginObject();
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json b/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json
index 43a34ed87ce..491e0d21e5a 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json
@@ -2,6 +2,7 @@
"id": 2865,
"key": "org.codehaus.sonar:sonar",
"uuid": "69e57151-be0d-4157-adff-c06741d88879",
+ "description": "Open source platform for continuous inspection of code quality",
"isComparable": true,
"canBeFavorite": true,
"isFavorite": true,
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
index 9dffcf84359..26f9b47dc63 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
@@ -69,7 +69,11 @@ import static org.sonar.test.JsonAssert.assertJson;
public class ComponentNavigationActionTest {
private static final String PROJECT_KEY = "polop";
- private static final ComponentDto PROJECT = newProjectDto("abcd").setKey(PROJECT_KEY).setName("Polop").setLanguage("xoo");
+ private static final ComponentDto PROJECT = newProjectDto("abcd")
+ .setKey(PROJECT_KEY)
+ .setName("Polop")
+ .setDescription("test project")
+ .setLanguage("xoo");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json
index 897600a6b5c..4b7bd4cea94 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json
@@ -2,6 +2,7 @@
"key": "polop",
"uuid": "abcd",
"name": "Polop",
+ "description": "test project",
"isComparable": false,
"canBeFavorite": false,
"isFavorite": false,
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json
index 1ca93830a06..2b77dd2789a 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json
@@ -2,6 +2,7 @@
"key": "polop",
"uuid": "abcd",
"name": "Polop",
+ "description": "test project",
"isComparable": false,
"canBeFavorite": false,
"isFavorite": false,
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json
index 119f86af877..d8304d006dd 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json
@@ -2,6 +2,7 @@
"key": "polop",
"uuid": "abcd",
"name": "Polop",
+ "description": "test project",
"isComparable": false,
"canBeFavorite": true,
"isFavorite": true,