]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7134 WS api/measures/component refKey in response 711/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 20 Jan 2016 11:48:24 +0000 (12:48 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 20 Jan 2016 11:49:07 +0000 (12:49 +0100)
server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java

index b6a62d5e12ef58a5d2b67ee19927b437440ddf73..b7af8e1b042ea0f826dbbcf326edb054e09c7d4b 100644 (file)
@@ -157,9 +157,9 @@ public class ComponentAction implements MeasuresWsAction {
       MetricDto metric = metricsById.get(measure.getMetricId());
       measuresByMetric.put(metric, measure);
     }
-    Map<Long, String> referenceComponentUuidById = new HashMap<>();
+    Map<Long, ComponentDto> referenceComponentUuidById = new HashMap<>();
     if (refComponent.isPresent()) {
-      referenceComponentUuidById.put(refComponent.get().getId(), refComponent.get().uuid());
+      referenceComponentUuidById.put(refComponent.get().getId(), refComponent.get());
     }
 
     response.setComponent(componentDtoToWsComponent(component, measuresByMetric, referenceComponentUuidById));
index 955ddcf0bcd603b03e4ec4fe9ee3df7d15d3c20e..97d6363d68ba797c1ecbb0b81acf0be538cef6dc 100644 (file)
@@ -128,7 +128,7 @@ public class ComponentActionTest {
 
   @Test
   public void reference_uuid_in_the_response() {
-    ComponentDto project = newProjectDto("project-uuid");
+    ComponentDto project = newProjectDto("project-uuid").setKey("project-key");
     ComponentDto view = newView("view-uuid");
     componentDb.insertViewAndSnapshot(view);
     componentDb.insertProjectAndSnapshot(project);
@@ -139,6 +139,7 @@ public class ComponentActionTest {
 
     assertThat(response.getComponent().getId()).isEqualTo("project-uuid-copy");
     assertThat(response.getComponent().getRefId()).isEqualTo("project-uuid");
+    assertThat(response.getComponent().getRefKey()).isEqualTo("project-key");
   }
 
   @Test