aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-25 19:01:01 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-25 19:01:01 +0100
commit46dfa139944cb0ff94e5f05f18a55533b489ef10 (patch)
tree30916ff7677dc84ee67af5f8e4a4195852b55ddb /sonar-batch/src
parentfe13138cef996cfc0ade3252d0452442635f6f92 (diff)
downloadsonarqube-46dfa139944cb0ff94e5f05f18a55533b489ef10.tar.gz
sonarqube-46dfa139944cb0ff94e5f05f18a55533b489ef10.zip
SONAR-6257 Fix duplication issue when there's folder in project structure and add component key in report
Diffstat (limited to 'sonar-batch/src')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java6
2 files changed, 8 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java
index 506a7f23765..fa81851088e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java
@@ -30,10 +30,11 @@ import org.sonar.batch.index.BatchResource;
import org.sonar.batch.index.ResourceCache;
import org.sonar.batch.protocol.Constants;
import org.sonar.batch.protocol.Constants.ComponentLinkType;
-import org.sonar.batch.protocol.output.*;
+import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReport.Component.Builder;
import org.sonar.batch.protocol.output.BatchReport.ComponentLink;
import org.sonar.batch.protocol.output.BatchReport.Event;
+import org.sonar.batch.protocol.output.BatchReportWriter;
import javax.annotation.CheckForNull;
@@ -65,6 +66,7 @@ public class ComponentsPublisher implements ReportPublisher {
// non-null fields
builder.setRef(batchResource.batchId());
builder.setType(getType(r));
+ builder.setKey(r.getKey());
// protocol buffers does not accept null values
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
index fb0c2aa4b5f..812d8110339 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
@@ -36,7 +36,9 @@ import org.sonar.batch.protocol.Constants.ComponentLinkType;
import org.sonar.batch.protocol.Constants.EventCategory;
import org.sonar.batch.protocol.output.BatchReport.Component;
import org.sonar.batch.protocol.output.BatchReport.Event;
-import org.sonar.batch.protocol.output.*;
+import org.sonar.batch.protocol.output.BatchReportReader;
+import org.sonar.batch.protocol.output.BatchReportWriter;
+import org.sonar.batch.protocol.output.FileStructure;
import java.io.File;
import java.util.Arrays;
@@ -114,10 +116,12 @@ public class ComponentsPublisherTest {
BatchReportReader reader = new BatchReportReader(outputDir);
Component rootProtobuf = reader.readComponent(1);
+ assertThat(rootProtobuf.getKey()).isEqualTo("foo");
assertThat(rootProtobuf.getVersion()).isEqualTo("1.0");
assertThat(rootProtobuf.getLinkCount()).isEqualTo(0);
Component module1Protobuf = reader.readComponent(2);
+ assertThat(module1Protobuf.getKey()).isEqualTo("module1");
assertThat(module1Protobuf.getVersion()).isEqualTo("1.0");
}