From 44a8017daf190a9636fd93d9b32a0849e7b3193f Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Wed, 20 Jan 2016 12:48:24 +0100 Subject: [PATCH] SONAR-7134 WS api/measures/component refKey in response --- .../java/org/sonar/server/measure/ws/ComponentAction.java | 4 ++-- .../java/org/sonar/server/measure/ws/ComponentActionTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) 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 -- 2.39.5