From: Teryk Bellahsene Date: Wed, 20 Jan 2016 11:48:24 +0000 (+0100) Subject: SONAR-7134 WS api/measures/component refKey in response X-Git-Tag: 5.4-M9~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F711%2Fhead;p=sonarqube.git SONAR-7134 WS api/measures/component refKey in response --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java index b6a62d5e12e..b7af8e1b042 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java @@ -157,9 +157,9 @@ public class ComponentAction implements MeasuresWsAction { MetricDto metric = metricsById.get(measure.getMetricId()); measuresByMetric.put(metric, measure); } - Map referenceComponentUuidById = new HashMap<>(); + Map 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)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java index 955ddcf0bcd..97d6363d68b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java @@ -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