aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java151
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java146
-rw-r--r--sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java293
-rw-r--r--sonar-batch-protocol/src/main/protobuf/file_source_db.proto1
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java4
6 files changed, 434 insertions, 165 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
index 9ff1a514184..8be0e1c5d2e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
@@ -20,16 +20,22 @@
package org.sonar.server.computation.step;
+import com.google.common.base.Joiner;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Table;
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.utils.System2;
+import org.sonar.api.utils.internal.Uuids;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReportReader;
import org.sonar.core.persistence.DbSession;
@@ -41,17 +47,20 @@ import org.sonar.server.computation.source.ReportIterator;
import org.sonar.server.db.DbClient;
import org.sonar.server.source.db.FileSourceDb;
-import javax.annotation.CheckForNull;
-
import java.io.File;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
public class PersistTestsStep implements ComputationStep {
+ private static final Logger LOG = Loggers.get(PersistTestsStep.class);
+
private final DbClient dbClient;
private final System2 system;
@@ -74,6 +83,9 @@ public class PersistTestsStep implements ComputationStep {
recursivelyProcessComponent(context, rootComponentRef);
session.commit();
+ if (context.hasUnprocessedCoverageDetails) {
+ LOG.warn("Some coverage tests are not taken into account during analysis of project '{}'", computationContext.getProject().getKey());
+ }
} finally {
MyBatis.closeQuietly(session);
}
@@ -82,7 +94,7 @@ public class PersistTestsStep implements ComputationStep {
private void recursivelyProcessComponent(TestContext context, int componentRef) {
BatchReportReader reportReader = context.reader;
BatchReport.Component component = reportReader.readComponent(componentRef);
- if (component.getIsTest() && reportReader.readTests(componentRef) != null) {
+ if (component.getIsTest()) {
persistTestResults(component, context);
}
@@ -92,8 +104,16 @@ public class PersistTestsStep implements ComputationStep {
}
private void persistTestResults(BatchReport.Component component, TestContext context) {
- ListMultimap<String, FileSourceDb.Test.CoveredFile> coveredFilesByName = loadCoverageDetails(component.getRef(), context);
- List<FileSourceDb.Test> tests = buildDbTests(component, context, coveredFilesByName);
+ Multimap<String, FileSourceDb.Test.Builder> testsByName = buildDbTests(context, component);
+ Table<String, String, FileSourceDb.Test.CoveredFile.Builder> coveredFilesByName = loadCoverageDetails(component.getRef(), context);
+ List<FileSourceDb.Test> tests = addCoveredFilesToTests(testsByName, coveredFilesByName);
+ if (checkIfThereAreUnprocessedCoverageDetails(testsByName, coveredFilesByName, component)) {
+ context.hasUnprocessedCoverageDetails = true;
+ }
+
+ if (tests.isEmpty()) {
+ return;
+ }
FileSourceDto existingDto = context.existingFileSourcesByUuid.get(component.getUuid());
long now = system.now();
@@ -116,53 +136,102 @@ public class PersistTestsStep implements ComputationStep {
}
}
- private List<FileSourceDb.Test> buildDbTests(BatchReport.Component component, TestContext context, ListMultimap<String, FileSourceDb.Test.CoveredFile> coveredFilesByName) {
+ private boolean checkIfThereAreUnprocessedCoverageDetails(Multimap<String, FileSourceDb.Test.Builder> testsByName,
+ Table<String, String, FileSourceDb.Test.CoveredFile.Builder> coveredFilesByName,
+ BatchReport.Component component) {
+ Set<String> unprocessedCoverageDetailNames = new HashSet<>(coveredFilesByName.rowKeySet());
+ unprocessedCoverageDetailNames.removeAll(testsByName.keySet());
+ boolean hasUnprocessedCoverageDetails = !unprocessedCoverageDetailNames.isEmpty();
+ if (hasUnprocessedCoverageDetails) {
+ LOG.trace("The following test coverages for file '{}' have not been taken into account: {}", component.getPath(), Joiner.on(", ").join(unprocessedCoverageDetailNames));
+ }
+ return hasUnprocessedCoverageDetails;
+ }
+
+ private List<FileSourceDb.Test> addCoveredFilesToTests(Multimap<String, FileSourceDb.Test.Builder> testsByName,
+ Table<String, String, FileSourceDb.Test.CoveredFile.Builder> coveredFilesByName) {
List<FileSourceDb.Test> tests = new ArrayList<>();
- ReportIterator<BatchReport.Test> testIterator = new ReportIterator<>(context.reader.readTests(component.getRef()), BatchReport.Test.PARSER);
- while (testIterator.hasNext()) {
- BatchReport.Test batchTest = testIterator.next();
- FileSourceDb.Test.Builder dbTest = FileSourceDb.Test.newBuilder();
- dbTest.setType(batchTest.getType());
- dbTest.setName(batchTest.getName());
- if (batchTest.hasStacktrace()) {
- dbTest.setStacktrace(batchTest.getStacktrace());
- }
- if (batchTest.hasStatus()) {
- dbTest.setStatus(batchTest.getStatus());
- }
- if (batchTest.hasMsg()) {
- dbTest.setMsg(batchTest.getMsg());
- }
- if (batchTest.hasExecutionTimeMs()) {
- dbTest.setExecutionTimeMs(batchTest.getExecutionTimeMs());
+ for (FileSourceDb.Test.Builder test : testsByName.values()) {
+ Collection<FileSourceDb.Test.CoveredFile.Builder> coveredFiles = coveredFilesByName.row(test.getName()).values();
+ if (!coveredFiles.isEmpty()) {
+ for (FileSourceDb.Test.CoveredFile.Builder coveredFile : coveredFiles) {
+ test.addCoveredFile(coveredFile);
+ }
}
- List<FileSourceDb.Test.CoveredFile> coveredFiles = coveredFilesByName == null ? null : coveredFilesByName.get(batchTest.getName());
- if (coveredFiles != null) {
- dbTest.addAllCoveredFile(coveredFiles);
+ tests.add(test.build());
+ }
+
+ return tests;
+ }
+
+ private Multimap<String, FileSourceDb.Test.Builder> buildDbTests(TestContext context, BatchReport.Component component) {
+ Multimap<String, FileSourceDb.Test.Builder> tests = ArrayListMultimap.create();
+ File testsFile = context.reader.readTests(component.getRef());
+ if (testsFile == null) {
+ return tests;
+ }
+ ReportIterator<BatchReport.Test> testIterator = new ReportIterator<>(testsFile, BatchReport.Test.PARSER);
+ try {
+ while (testIterator.hasNext()) {
+ BatchReport.Test batchTest = testIterator.next();
+ FileSourceDb.Test.Builder dbTest = FileSourceDb.Test.newBuilder();
+ dbTest.setUuid(Uuids.create());
+ dbTest.setName(batchTest.getName());
+ if (batchTest.hasStacktrace()) {
+ dbTest.setStacktrace(batchTest.getStacktrace());
+ }
+ if (batchTest.hasStatus()) {
+ dbTest.setStatus(batchTest.getStatus());
+ }
+ if (batchTest.hasMsg()) {
+ dbTest.setMsg(batchTest.getMsg());
+ }
+ if (batchTest.hasDurationInMs()) {
+ dbTest.setExecutionTimeMs(batchTest.getDurationInMs());
+ }
+
+ tests.put(dbTest.getName(), dbTest);
}
- tests.add(dbTest.build());
+ } finally {
+ testIterator.close();
}
return tests;
}
- @CheckForNull
- private ListMultimap<String, FileSourceDb.Test.CoveredFile> loadCoverageDetails(int testFileRef, TestContext context) {
+ /**
+ * returns a Table of (test name, main file uuid, covered file)
+ */
+ private Table<String, String, FileSourceDb.Test.CoveredFile.Builder> loadCoverageDetails(int testFileRef, TestContext context) {
+ Table<String, String, FileSourceDb.Test.CoveredFile.Builder> nameToCoveredFiles = HashBasedTable.create();
File coverageDetailsFile = context.reader.readCoverageDetails(testFileRef);
if (coverageDetailsFile == null) {
- return null;
+ return nameToCoveredFiles;
}
- ListMultimap<String, FileSourceDb.Test.CoveredFile> nameToCoveredFiles = ArrayListMultimap.create();
ReportIterator<BatchReport.CoverageDetail> coverageIterator = new ReportIterator<>(coverageDetailsFile, BatchReport.CoverageDetail.PARSER);
- while (coverageIterator.hasNext()) {
- BatchReport.CoverageDetail batchCoverageDetail = coverageIterator.next();
- for (BatchReport.CoverageDetail.CoveredFile batchCoveredFile : batchCoverageDetail.getCoveredFileList()) {
- FileSourceDb.Test.CoveredFile.Builder dbCoveredFile = FileSourceDb.Test.CoveredFile.newBuilder()
- .setFileUuid(context.getUuid(batchCoveredFile.getFileRef()))
- .addAllCoveredLine(batchCoveredFile.getCoveredLineList());
- nameToCoveredFiles.put(batchCoverageDetail.getTestName(), dbCoveredFile.build());
+ try {
+ while (coverageIterator.hasNext()) {
+ BatchReport.CoverageDetail batchCoverageDetail = coverageIterator.next();
+ for (BatchReport.CoverageDetail.CoveredFile batchCoveredFile : batchCoverageDetail.getCoveredFileList()) {
+ String testName = batchCoverageDetail.getTestName();
+ String mainFileUuid = context.getUuid(batchCoveredFile.getFileRef());
+ FileSourceDb.Test.CoveredFile.Builder existingDbCoveredFile = nameToCoveredFiles.get(testName, mainFileUuid);
+ List<Integer> batchCoveredLines = batchCoveredFile.getCoveredLineList();
+ if (existingDbCoveredFile == null) {
+ FileSourceDb.Test.CoveredFile.Builder dbCoveredFile = FileSourceDb.Test.CoveredFile.newBuilder()
+ .setFileUuid(context.getUuid(batchCoveredFile.getFileRef()))
+ .addAllCoveredLine(batchCoveredLines);
+ nameToCoveredFiles.put(testName, mainFileUuid, dbCoveredFile);
+ } else {
+ List<Integer> remainingBatchCoveredLines = new ArrayList<>(batchCoveredLines);
+ remainingBatchCoveredLines.removeAll(existingDbCoveredFile.getCoveredLineList());
+ existingDbCoveredFile.addAllCoveredLine(batchCoveredLines);
+ }
+ }
}
+ } finally {
+ coverageIterator.close();
}
return nameToCoveredFiles;
}
@@ -178,6 +247,7 @@ public class PersistTestsStep implements ComputationStep {
final BatchReportReader reader;
final Cache<Integer, String> componentRefToUuidCache;
final Map<String, FileSourceDto> existingFileSourcesByUuid;
+ boolean hasUnprocessedCoverageDetails = false;
TestContext(ComputationContext context, DbSession session) {
this.session = session;
@@ -187,6 +257,7 @@ public class PersistTestsStep implements ComputationStep {
.maximumSize(500_000)
.build(
new CacheLoader<Integer, String>() {
+ @Override
public String load(Integer key) {
return reader.readComponent(key).getUuid();
}
@@ -207,7 +278,7 @@ public class PersistTestsStep implements ComputationStep {
try {
return componentRefToUuidCache.get(fileRef);
} catch (ExecutionException e) {
- throw new IllegalStateException(String.format("Error while retrieving uuid of component file ref '%d'", fileRef));
+ throw new IllegalStateException(String.format("Error while retrieving uuid of component file ref '%d'", fileRef), e);
}
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java
index 1d91b26da9e..474b5f44527 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java
@@ -27,9 +27,10 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.utils.System2;
+import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.batch.protocol.Constants;
import org.sonar.batch.protocol.Constants.TestStatus;
-import org.sonar.batch.protocol.Constants.TestType;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReport.CoverageDetail;
import org.sonar.batch.protocol.output.BatchReportReader;
@@ -38,7 +39,6 @@ import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.DbTester;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.source.db.FileSourceDto;
-import org.sonar.server.component.ComponentTesting;
import org.sonar.server.computation.ComputationContext;
import org.sonar.server.db.DbClient;
import org.sonar.server.source.db.FileSourceDao;
@@ -50,8 +50,10 @@ import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.sonar.server.component.ComponentTesting.newProjectDto;
public class PersistTestsStepTest extends BaseStepTest {
private static final String PROJECT_UUID = "PROJECT";
@@ -63,6 +65,8 @@ public class PersistTestsStepTest extends BaseStepTest {
private static final String TEST_FILE_UUID_2 = "TEST-FILE-2";
private static final String MAIN_FILE_UUID_1 = "MAIN-FILE-1";
private static final String MAIN_FILE_UUID_2 = "MAIN-FILE-2";
+ private static final String TEST_FILE_PATH_1 = "TEST-PATH-1";
+ private static final String TEST_FILE_PATH_2 = "TEST-PATH-2";
PersistTestsStep sut;
@@ -72,6 +76,9 @@ public class PersistTestsStepTest extends BaseStepTest {
@ClassRule
public static DbTester db = new DbTester();
+ @Rule
+ public LogTester log = new LogTester();
+
File reportDir;
DbSession session;
DbClient dbClient;
@@ -106,9 +113,10 @@ public class PersistTestsStepTest extends BaseStepTest {
@Test
public void no_test_in_database_and_batch_report() throws Exception {
- sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto()));
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto()));
assertThat(dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1)).isNull();
+ assertThat(log.logs()).isEmpty();
}
@Test
@@ -120,10 +128,10 @@ public class PersistTestsStepTest extends BaseStepTest {
writer.writeTests(TEST_FILE_REF_1, batchTests);
List<CoverageDetail> coverageDetails = Arrays.asList(
newCoverageDetail(1, MAIN_FILE_REF_1)
- );
+ );
writer.writeCoverageDetails(TEST_FILE_REF_1, coverageDetails);
- sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto(PROJECT_UUID)));
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto(PROJECT_UUID)));
FileSourceDto dto = dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1);
assertThat(dto.getCreatedAt()).isEqualTo(now);
@@ -132,29 +140,20 @@ public class PersistTestsStepTest extends BaseStepTest {
assertThat(dto.getFileUuid()).isEqualTo(TEST_FILE_UUID_1);
assertThat(dto.getTestData()).hasSize(2);
- FileSourceDb.Test test1 = dto.getTestData().get(0);
- assertThat(test1.getName()).isEqualTo("name#1");
- assertThat(test1.getCoveredFileCount()).isEqualTo(1);
- assertThat(test1.getCoveredFile(0).getFileUuid()).isEqualTo(MAIN_FILE_UUID_1);
+ assertThat(dto.getTestData()).extracting("name", "coveredFileCount").containsOnly(
+ tuple("name#1", 1),
+ tuple("name#2", 0));
- FileSourceDb.Test test2 = dto.getTestData().get(1);
- assertThat(test2.getName()).isEqualTo("name#2");
- assertThat(test2.getCoveredFileList()).isEmpty();
+ assertThat(log.logs()).isEmpty();
}
@Test
public void insert_all_data_of_a_test() throws Exception {
BatchReportWriter writer = new BatchReportWriter(reportDir);
- List<BatchReport.Test> batchTests = Arrays.asList(
- newTest(1)
- );
- writer.writeTests(TEST_FILE_REF_1, batchTests);
- List<CoverageDetail> coverageDetails = Arrays.asList(
- newCoverageDetail(1, MAIN_FILE_REF_1)
- );
- writer.writeCoverageDetails(TEST_FILE_REF_1, coverageDetails);
+ writer.writeTests(TEST_FILE_REF_1, Arrays.asList(newTest(1)));
+ writer.writeCoverageDetails(TEST_FILE_REF_1, Arrays.asList(newCoverageDetail(1, MAIN_FILE_REF_1)));
- sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto(PROJECT_UUID)));
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto(PROJECT_UUID)));
FileSourceDto dto = dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1);
assertThat(dto.getCreatedAt()).isEqualTo(now);
@@ -164,99 +163,134 @@ public class PersistTestsStepTest extends BaseStepTest {
assertThat(dto.getTestData()).hasSize(1);
FileSourceDb.Test test1 = dto.getTestData().get(0);
+ assertThat(test1.getUuid()).isNotEmpty();
assertThat(test1.getName()).isEqualTo("name#1");
assertThat(test1.getMsg()).isEqualTo("message#1");
assertThat(test1.getStacktrace()).isEqualTo("stacktrace#1");
assertThat(test1.getStatus()).isEqualTo(TestStatus.FAILURE);
- assertThat(test1.getType()).isEqualTo(TestType.UT);
assertThat(test1.getExecutionTimeMs()).isEqualTo(1_000);
assertThat(test1.getCoveredFileCount()).isEqualTo(1);
- assertThat(test1.getCoveredFile(0).getCoveredLineList()).containsExactly(1, 2, 3);
+ assertThat(test1.getCoveredFile(0).getCoveredLineList()).containsOnly(1, 2, 3);
assertThat(test1.getCoveredFile(0).getFileUuid()).isEqualTo(MAIN_FILE_UUID_1);
}
@Test
public void insert_tests_without_coverage_details() throws Exception {
BatchReportWriter writer = new BatchReportWriter(reportDir);
- List<BatchReport.Test> batchTests = Arrays.asList(
- newTest(1), newTest(2)
- );
+ List<BatchReport.Test> batchTests = Arrays.asList(newTest(1), newTest(2));
writer.writeTests(TEST_FILE_REF_1, batchTests);
- sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto(PROJECT_UUID)));
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto(PROJECT_UUID)));
FileSourceDto dto = dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1);
assertThat(dto.getFileUuid()).isEqualTo(TEST_FILE_UUID_1);
List<FileSourceDb.Test> tests = dto.getTestData();
assertThat(tests).hasSize(2);
assertThat(tests.get(0).getCoveredFileList()).isEmpty();
+ assertThat(tests.get(0).getMsg()).isEqualTo("message#1");
+ assertThat(tests.get(1).getCoveredFileList()).isEmpty();
+ }
+
+ @Test
+ public void insert_coverage_details_not_taken_into_account() throws Exception {
+ BatchReportWriter writer = new BatchReportWriter(reportDir);
+ List<BatchReport.Test> batchTests = Arrays.asList(newTest(1));
+ writer.writeTests(TEST_FILE_REF_1, batchTests);
+ List<CoverageDetail> coverageDetails = Arrays.asList(newCoverageDetail(1, MAIN_FILE_REF_1), newCoverageDetail(2, MAIN_FILE_REF_2));
+ writer.writeCoverageDetails(TEST_FILE_REF_1, coverageDetails);
+ writer.writeCoverageDetails(TEST_FILE_REF_2, coverageDetails);
+
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto(PROJECT_UUID)));
+
+ assertThat(log.logs(LoggerLevel.WARN)).hasSize(1);
+ assertThat(log.logs(LoggerLevel.WARN).get(0)).isEqualTo("Some coverage tests are not taken into account during analysis of project 'KEY_PROJECT'");
+ assertThat(log.logs(LoggerLevel.TRACE)).hasSize(2);
+ assertThat(log.logs(LoggerLevel.TRACE).get(0)).isEqualTo("The following test coverages for file 'TEST-PATH-1' have not been taken into account: name#2");
+ assertThat(log.logs(LoggerLevel.TRACE).get(1)).startsWith("The following test coverages for file 'TEST-PATH-2' have not been taken into account: ");
+ assertThat(log.logs(LoggerLevel.TRACE).get(1)).contains("name#1", "name#2");
}
@Test
- public void update_one_test() throws Exception {
+ public void aggregate_coverage_details() throws Exception {
+ BatchReportWriter writer = new BatchReportWriter(reportDir);
+ writer.writeTests(TEST_FILE_REF_1, Arrays.asList(newTest(1)));
+ writer.writeCoverageDetails(TEST_FILE_REF_1, Arrays.asList(
+ newCoverageDetailWithLines(1, MAIN_FILE_REF_1, 1, 3),
+ newCoverageDetailWithLines(1, MAIN_FILE_REF_1, 2, 4)));
+
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto(PROJECT_UUID)));
+
+ FileSourceDto dto = dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1);
+ List<Integer> coveredLines = dto.getTestData().get(0).getCoveredFile(0).getCoveredLineList();
+ assertThat(coveredLines).containsOnly(1, 2, 3, 4);
+ }
+
+ @Test
+ public void update_existing_test() throws Exception {
// ARRANGE
dbClient.fileSourceDao().insert(session, new FileSourceDto()
.setProjectUuid(PROJECT_UUID)
.setFileUuid(TEST_FILE_UUID_1)
- .setTestData(Arrays.asList(newDbTest(1)))
+ .setTestData(Arrays.asList(FileSourceDb.Test.newBuilder()
+ .setUuid("test-uuid-1")
+ .setName("name#1")
+ .setStatus(TestStatus.ERROR)
+ .setStacktrace("old-stacktrace#1")
+ .setMsg("old-message#1")
+ .setExecutionTimeMs(987_654_321L)
+ .build()))
.setCreatedAt(100_000)
.setUpdatedAt(100_000));
session.commit();
assertThat(dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1)).isNotNull();
+
BatchReportWriter writer = new BatchReportWriter(reportDir);
- List<BatchReport.Test> batchTests = Arrays.asList(
- newTest(1), newTest(2)
- );
- writer.writeTests(TEST_FILE_REF_1, batchTests);
- List<CoverageDetail> coverageDetails = Arrays.asList(
- newCoverageDetail(1, MAIN_FILE_REF_1)
- );
- writer.writeCoverageDetails(TEST_FILE_REF_1, coverageDetails);
+ BatchReport.Test newBatchTest = newTest(1);
+ writer.writeTests(TEST_FILE_REF_1, Arrays.asList(newBatchTest));
+
+ CoverageDetail newCoverageDetail = newCoverageDetail(1, MAIN_FILE_REF_1);
+ writer.writeCoverageDetails(TEST_FILE_REF_1, Arrays.asList(newCoverageDetail));
// ACT
- sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto(PROJECT_UUID)));
+ sut.execute(new ComputationContext(new BatchReportReader(reportDir), newProjectDto(PROJECT_UUID)));
// ASSERT
FileSourceDto dto = dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1);
assertThat(dto.getCreatedAt()).isEqualTo(100_000);
assertThat(dto.getUpdatedAt()).isEqualTo(now);
- assertThat(dto.getTestData()).hasSize(2);
+ assertThat(dto.getTestData()).hasSize(1);
FileSourceDb.Test test = dto.getTestData().get(0);
+ assertThat(test.getUuid()).isNotEqualTo("test-uuid-1");
assertThat(test.getName()).isEqualTo("name#1");
- assertThat(test.getMsg()).isEqualTo("message#1");
+ assertThat(test.getStatus()).isEqualTo(newBatchTest.getStatus());
+ assertThat(test.getMsg()).isEqualTo(newBatchTest.getMsg());
+ assertThat(test.getStacktrace()).isEqualTo(newBatchTest.getStacktrace());
+ assertThat(test.getExecutionTimeMs()).isEqualTo(newBatchTest.getDurationInMs());
assertThat(test.getCoveredFileCount()).isEqualTo(1);
- assertThat(test.getCoveredFile(0).getCoveredLineList()).containsExactly(1, 2, 3);
+ assertThat(test.getCoveredFile(0).getCoveredLineList()).containsOnly(1, 2, 3);
assertThat(test.getCoveredFile(0).getFileUuid()).isEqualTo(MAIN_FILE_UUID_1);
}
- private FileSourceDb.Test newDbTest(int id) {
- return FileSourceDb.Test.newBuilder()
- .setName("name#" + id)
- .setType(TestType.IT)
- .setStatus(TestStatus.ERROR)
- .setStacktrace("old-stacktrace#" + id)
- .setMsg("old-message#" + id)
- .setExecutionTimeMs(123_456_789L)
- .build();
- }
-
private BatchReport.Test newTest(int id) {
return BatchReport.Test.newBuilder()
- .setType(TestType.UT)
.setStatus(TestStatus.FAILURE)
.setName("name#" + id)
.setStacktrace("stacktrace#" + id)
.setMsg("message#" + id)
- .setExecutionTimeMs(1_000)
+ .setDurationInMs(1_000)
.build();
}
private BatchReport.CoverageDetail newCoverageDetail(int id, int covered_file_ref) {
+ return newCoverageDetailWithLines(id, covered_file_ref, 1, 2, 3);
+ }
+
+ private BatchReport.CoverageDetail newCoverageDetailWithLines(int id, int covered_file_ref, Integer... lines) {
return CoverageDetail.newBuilder()
.setTestName("name#" + id)
.addCoveredFile(CoverageDetail.CoveredFile.newBuilder()
- .addAllCoveredLine(Arrays.asList(1, 2, 3))
+ .addAllCoveredLine(Arrays.asList(lines))
.setFileRef(covered_file_ref)
.build()
)
@@ -287,12 +321,14 @@ public class PersistTestsStepTest extends BaseStepTest {
.setIsTest(true)
.setType(Constants.ComponentType.FILE)
.setUuid(TEST_FILE_UUID_1)
+ .setPath(TEST_FILE_PATH_1)
.build());
writer.writeComponent(BatchReport.Component.newBuilder()
.setRef(TEST_FILE_REF_2)
.setIsTest(true)
.setType(Constants.ComponentType.FILE)
.setUuid(TEST_FILE_UUID_2)
+ .setPath(TEST_FILE_PATH_2)
.build());
writer.writeComponent(BatchReport.Component.newBuilder()
.setRef(MAIN_FILE_REF_1)
diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java
index f05dc4f0341..987acb9659f 100644
--- a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java
+++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java
@@ -2960,6 +2960,20 @@ public final class FileSourceDb {
com.google.protobuf.MessageOrBuilder {
/**
+ * <code>optional string uuid = 1;</code>
+ */
+ boolean hasUuid();
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ java.lang.String getUuid();
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ com.google.protobuf.ByteString
+ getUuidBytes();
+
+ /**
* <code>optional string name = 2;</code>
*/
boolean hasName();
@@ -3095,9 +3109,15 @@ public final class FileSourceDb {
}
break;
}
- case 18: {
+ case 10: {
com.google.protobuf.ByteString bs = input.readBytes();
bitField0_ |= 0x00000001;
+ uuid_ = bs;
+ break;
+ }
+ case 18: {
+ com.google.protobuf.ByteString bs = input.readBytes();
+ bitField0_ |= 0x00000002;
name_ = bs;
break;
}
@@ -3107,32 +3127,32 @@ public final class FileSourceDb {
if (value == null) {
unknownFields.mergeVarintField(3, rawValue);
} else {
- bitField0_ |= 0x00000002;
+ bitField0_ |= 0x00000004;
status_ = value;
}
break;
}
case 32: {
- bitField0_ |= 0x00000004;
+ bitField0_ |= 0x00000008;
executionTimeMs_ = input.readInt64();
break;
}
case 42: {
com.google.protobuf.ByteString bs = input.readBytes();
- bitField0_ |= 0x00000008;
+ bitField0_ |= 0x00000010;
stacktrace_ = bs;
break;
}
case 50: {
com.google.protobuf.ByteString bs = input.readBytes();
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000020;
msg_ = bs;
break;
}
case 58: {
- if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
+ if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
coveredFile_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceDb.Test.CoveredFile>();
- mutable_bitField0_ |= 0x00000020;
+ mutable_bitField0_ |= 0x00000040;
}
coveredFile_.add(input.readMessage(org.sonar.server.source.db.FileSourceDb.Test.CoveredFile.PARSER, extensionRegistry));
break;
@@ -3145,7 +3165,7 @@ public final class FileSourceDb {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
- if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
+ if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
coveredFile_ = java.util.Collections.unmodifiableList(coveredFile_);
}
this.unknownFields = unknownFields.build();
@@ -3821,13 +3841,55 @@ public final class FileSourceDb {
}
private int bitField0_;
+ public static final int UUID_FIELD_NUMBER = 1;
+ private java.lang.Object uuid_;
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public boolean hasUuid() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public java.lang.String getUuid() {
+ java.lang.Object ref = uuid_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ uuid_ = s;
+ }
+ return s;
+ }
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getUuidBytes() {
+ java.lang.Object ref = uuid_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ uuid_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
public static final int NAME_FIELD_NUMBER = 2;
private java.lang.Object name_;
/**
* <code>optional string name = 2;</code>
*/
public boolean hasName() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
+ return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional string name = 2;</code>
@@ -3869,7 +3931,7 @@ public final class FileSourceDb {
* <code>optional .TestStatus status = 3;</code>
*/
public boolean hasStatus() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
+ return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional .TestStatus status = 3;</code>
@@ -3884,7 +3946,7 @@ public final class FileSourceDb {
* <code>optional int64 execution_time_ms = 4;</code>
*/
public boolean hasExecutionTimeMs() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
+ return ((bitField0_ & 0x00000008) == 0x00000008);
}
/**
* <code>optional int64 execution_time_ms = 4;</code>
@@ -3899,7 +3961,7 @@ public final class FileSourceDb {
* <code>optional string stacktrace = 5;</code>
*/
public boolean hasStacktrace() {
- return ((bitField0_ & 0x00000008) == 0x00000008);
+ return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional string stacktrace = 5;</code>
@@ -3941,7 +4003,7 @@ public final class FileSourceDb {
* <code>optional string msg = 6;</code>
*/
public boolean hasMsg() {
- return ((bitField0_ & 0x00000010) == 0x00000010);
+ return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional string msg = 6;</code>
@@ -4013,6 +4075,7 @@ public final class FileSourceDb {
}
private void initFields() {
+ uuid_ = "";
name_ = "";
status_ = org.sonar.batch.protocol.Constants.TestStatus.OK;
executionTimeMs_ = 0L;
@@ -4034,18 +4097,21 @@ public final class FileSourceDb {
throws java.io.IOException {
getSerializedSize();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeBytes(2, getNameBytes());
+ output.writeBytes(1, getUuidBytes());
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
- output.writeEnum(3, status_.getNumber());
+ output.writeBytes(2, getNameBytes());
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
- output.writeInt64(4, executionTimeMs_);
+ output.writeEnum(3, status_.getNumber());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
- output.writeBytes(5, getStacktraceBytes());
+ output.writeInt64(4, executionTimeMs_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
+ output.writeBytes(5, getStacktraceBytes());
+ }
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
output.writeBytes(6, getMsgBytes());
}
for (int i = 0; i < coveredFile_.size(); i++) {
@@ -4062,22 +4128,26 @@ public final class FileSourceDb {
size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(2, getNameBytes());
+ .computeBytesSize(1, getUuidBytes());
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
- .computeEnumSize(3, status_.getNumber());
+ .computeBytesSize(2, getNameBytes());
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(4, executionTimeMs_);
+ .computeEnumSize(3, status_.getNumber());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(5, getStacktraceBytes());
+ .computeInt64Size(4, executionTimeMs_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(5, getStacktraceBytes());
+ }
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
+ size += com.google.protobuf.CodedOutputStream
.computeBytesSize(6, getMsgBytes());
}
for (int i = 0; i < coveredFile_.size(); i++) {
@@ -4202,19 +4272,21 @@ public final class FileSourceDb {
public Builder clear() {
super.clear();
- name_ = "";
+ uuid_ = "";
bitField0_ = (bitField0_ & ~0x00000001);
- status_ = org.sonar.batch.protocol.Constants.TestStatus.OK;
+ name_ = "";
bitField0_ = (bitField0_ & ~0x00000002);
- executionTimeMs_ = 0L;
+ status_ = org.sonar.batch.protocol.Constants.TestStatus.OK;
bitField0_ = (bitField0_ & ~0x00000004);
- stacktrace_ = "";
+ executionTimeMs_ = 0L;
bitField0_ = (bitField0_ & ~0x00000008);
- msg_ = "";
+ stacktrace_ = "";
bitField0_ = (bitField0_ & ~0x00000010);
+ msg_ = "";
+ bitField0_ = (bitField0_ & ~0x00000020);
if (coveredFileBuilder_ == null) {
coveredFile_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000020);
+ bitField0_ = (bitField0_ & ~0x00000040);
} else {
coveredFileBuilder_.clear();
}
@@ -4249,27 +4321,31 @@ public final class FileSourceDb {
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
- result.name_ = name_;
+ result.uuid_ = uuid_;
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
to_bitField0_ |= 0x00000002;
}
- result.status_ = status_;
+ result.name_ = name_;
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
to_bitField0_ |= 0x00000004;
}
- result.executionTimeMs_ = executionTimeMs_;
+ result.status_ = status_;
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
to_bitField0_ |= 0x00000008;
}
- result.stacktrace_ = stacktrace_;
+ result.executionTimeMs_ = executionTimeMs_;
if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
to_bitField0_ |= 0x00000010;
}
+ result.stacktrace_ = stacktrace_;
+ if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
+ to_bitField0_ |= 0x00000020;
+ }
result.msg_ = msg_;
if (coveredFileBuilder_ == null) {
- if (((bitField0_ & 0x00000020) == 0x00000020)) {
+ if (((bitField0_ & 0x00000040) == 0x00000040)) {
coveredFile_ = java.util.Collections.unmodifiableList(coveredFile_);
- bitField0_ = (bitField0_ & ~0x00000020);
+ bitField0_ = (bitField0_ & ~0x00000040);
}
result.coveredFile_ = coveredFile_;
} else {
@@ -4291,8 +4367,13 @@ public final class FileSourceDb {
public Builder mergeFrom(org.sonar.server.source.db.FileSourceDb.Test other) {
if (other == org.sonar.server.source.db.FileSourceDb.Test.getDefaultInstance()) return this;
- if (other.hasName()) {
+ if (other.hasUuid()) {
bitField0_ |= 0x00000001;
+ uuid_ = other.uuid_;
+ onChanged();
+ }
+ if (other.hasName()) {
+ bitField0_ |= 0x00000002;
name_ = other.name_;
onChanged();
}
@@ -4303,12 +4384,12 @@ public final class FileSourceDb {
setExecutionTimeMs(other.getExecutionTimeMs());
}
if (other.hasStacktrace()) {
- bitField0_ |= 0x00000008;
+ bitField0_ |= 0x00000010;
stacktrace_ = other.stacktrace_;
onChanged();
}
if (other.hasMsg()) {
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000020;
msg_ = other.msg_;
onChanged();
}
@@ -4316,7 +4397,7 @@ public final class FileSourceDb {
if (!other.coveredFile_.isEmpty()) {
if (coveredFile_.isEmpty()) {
coveredFile_ = other.coveredFile_;
- bitField0_ = (bitField0_ & ~0x00000020);
+ bitField0_ = (bitField0_ & ~0x00000040);
} else {
ensureCoveredFileIsMutable();
coveredFile_.addAll(other.coveredFile_);
@@ -4329,7 +4410,7 @@ public final class FileSourceDb {
coveredFileBuilder_.dispose();
coveredFileBuilder_ = null;
coveredFile_ = other.coveredFile_;
- bitField0_ = (bitField0_ & ~0x00000020);
+ bitField0_ = (bitField0_ & ~0x00000040);
coveredFileBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getCoveredFileFieldBuilder() : null;
@@ -4365,12 +4446,88 @@ public final class FileSourceDb {
}
private int bitField0_;
+ private java.lang.Object uuid_ = "";
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public boolean hasUuid() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public java.lang.String getUuid() {
+ java.lang.Object ref = uuid_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ uuid_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getUuidBytes() {
+ java.lang.Object ref = uuid_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ uuid_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public Builder setUuid(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ uuid_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public Builder clearUuid() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ uuid_ = getDefaultInstance().getUuid();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string uuid = 1;</code>
+ */
+ public Builder setUuidBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ uuid_ = value;
+ onChanged();
+ return this;
+ }
+
private java.lang.Object name_ = "";
/**
* <code>optional string name = 2;</code>
*/
public boolean hasName() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
+ return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional string name = 2;</code>
@@ -4413,7 +4570,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000001;
+ bitField0_ |= 0x00000002;
name_ = value;
onChanged();
return this;
@@ -4422,7 +4579,7 @@ public final class FileSourceDb {
* <code>optional string name = 2;</code>
*/
public Builder clearName() {
- bitField0_ = (bitField0_ & ~0x00000001);
+ bitField0_ = (bitField0_ & ~0x00000002);
name_ = getDefaultInstance().getName();
onChanged();
return this;
@@ -4435,7 +4592,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000001;
+ bitField0_ |= 0x00000002;
name_ = value;
onChanged();
return this;
@@ -4446,7 +4603,7 @@ public final class FileSourceDb {
* <code>optional .TestStatus status = 3;</code>
*/
public boolean hasStatus() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
+ return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional .TestStatus status = 3;</code>
@@ -4461,7 +4618,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000002;
+ bitField0_ |= 0x00000004;
status_ = value;
onChanged();
return this;
@@ -4470,7 +4627,7 @@ public final class FileSourceDb {
* <code>optional .TestStatus status = 3;</code>
*/
public Builder clearStatus() {
- bitField0_ = (bitField0_ & ~0x00000002);
+ bitField0_ = (bitField0_ & ~0x00000004);
status_ = org.sonar.batch.protocol.Constants.TestStatus.OK;
onChanged();
return this;
@@ -4481,7 +4638,7 @@ public final class FileSourceDb {
* <code>optional int64 execution_time_ms = 4;</code>
*/
public boolean hasExecutionTimeMs() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
+ return ((bitField0_ & 0x00000008) == 0x00000008);
}
/**
* <code>optional int64 execution_time_ms = 4;</code>
@@ -4493,7 +4650,7 @@ public final class FileSourceDb {
* <code>optional int64 execution_time_ms = 4;</code>
*/
public Builder setExecutionTimeMs(long value) {
- bitField0_ |= 0x00000004;
+ bitField0_ |= 0x00000008;
executionTimeMs_ = value;
onChanged();
return this;
@@ -4502,7 +4659,7 @@ public final class FileSourceDb {
* <code>optional int64 execution_time_ms = 4;</code>
*/
public Builder clearExecutionTimeMs() {
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000008);
executionTimeMs_ = 0L;
onChanged();
return this;
@@ -4513,7 +4670,7 @@ public final class FileSourceDb {
* <code>optional string stacktrace = 5;</code>
*/
public boolean hasStacktrace() {
- return ((bitField0_ & 0x00000008) == 0x00000008);
+ return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional string stacktrace = 5;</code>
@@ -4556,7 +4713,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000008;
+ bitField0_ |= 0x00000010;
stacktrace_ = value;
onChanged();
return this;
@@ -4565,7 +4722,7 @@ public final class FileSourceDb {
* <code>optional string stacktrace = 5;</code>
*/
public Builder clearStacktrace() {
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000010);
stacktrace_ = getDefaultInstance().getStacktrace();
onChanged();
return this;
@@ -4578,7 +4735,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000008;
+ bitField0_ |= 0x00000010;
stacktrace_ = value;
onChanged();
return this;
@@ -4589,7 +4746,7 @@ public final class FileSourceDb {
* <code>optional string msg = 6;</code>
*/
public boolean hasMsg() {
- return ((bitField0_ & 0x00000010) == 0x00000010);
+ return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional string msg = 6;</code>
@@ -4632,7 +4789,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000020;
msg_ = value;
onChanged();
return this;
@@ -4641,7 +4798,7 @@ public final class FileSourceDb {
* <code>optional string msg = 6;</code>
*/
public Builder clearMsg() {
- bitField0_ = (bitField0_ & ~0x00000010);
+ bitField0_ = (bitField0_ & ~0x00000020);
msg_ = getDefaultInstance().getMsg();
onChanged();
return this;
@@ -4654,7 +4811,7 @@ public final class FileSourceDb {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000020;
msg_ = value;
onChanged();
return this;
@@ -4663,9 +4820,9 @@ public final class FileSourceDb {
private java.util.List<org.sonar.server.source.db.FileSourceDb.Test.CoveredFile> coveredFile_ =
java.util.Collections.emptyList();
private void ensureCoveredFileIsMutable() {
- if (!((bitField0_ & 0x00000020) == 0x00000020)) {
+ if (!((bitField0_ & 0x00000040) == 0x00000040)) {
coveredFile_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceDb.Test.CoveredFile>(coveredFile_);
- bitField0_ |= 0x00000020;
+ bitField0_ |= 0x00000040;
}
}
@@ -4815,7 +4972,7 @@ public final class FileSourceDb {
public Builder clearCoveredFile() {
if (coveredFileBuilder_ == null) {
coveredFile_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000020);
+ bitField0_ = (bitField0_ & ~0x00000040);
onChanged();
} else {
coveredFileBuilder_.clear();
@@ -4892,7 +5049,7 @@ public final class FileSourceDb {
coveredFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
org.sonar.server.source.db.FileSourceDb.Test.CoveredFile, org.sonar.server.source.db.FileSourceDb.Test.CoveredFile.Builder, org.sonar.server.source.db.FileSourceDb.Test.CoveredFileOrBuilder>(
coveredFile_,
- ((bitField0_ & 0x00000020) == 0x00000020),
+ ((bitField0_ & 0x00000040) == 0x00000040),
getParentForChildren(),
isClean());
coveredFile_ = null;
@@ -4953,13 +5110,13 @@ public final class FileSourceDb {
"ons\030\016 \001(\005\022\024\n\014highlighting\030\017 \001(\t\022\017\n\007symbo" +
"ls\030\020 \001(\t\022\027\n\013duplication\030\021 \003(\005B\002\020\001\"7\n\004Dat" +
"a\022/\n\005lines\030\001 \003(\0132 .org.sonar.server.sour" +
- "ce.db.Line\"\355\001\n\004Test\022\014\n\004name\030\002 \001(\t\022\033\n\006sta" +
- "tus\030\003 \001(\0162\013.TestStatus\022\031\n\021execution_time" +
- "_ms\030\004 \001(\003\022\022\n\nstacktrace\030\005 \001(\t\022\013\n\003msg\030\006 \001" +
- "(\t\022B\n\014covered_file\030\007 \003(\0132,.org.sonar.ser" +
- "ver.source.db.Test.CoveredFile\032:\n\013Covere" +
- "dFile\022\021\n\tfile_uuid\030\001 \001(\t\022\030\n\014covered_line" +
- "\030\002 \003(\005B\002\020\001B\002H\001"
+ "ce.db.Line\"\373\001\n\004Test\022\014\n\004uuid\030\001 \001(\t\022\014\n\004nam" +
+ "e\030\002 \001(\t\022\033\n\006status\030\003 \001(\0162\013.TestStatus\022\031\n\021" +
+ "execution_time_ms\030\004 \001(\003\022\022\n\nstacktrace\030\005 " +
+ "\001(\t\022\013\n\003msg\030\006 \001(\t\022B\n\014covered_file\030\007 \003(\0132," +
+ ".org.sonar.server.source.db.Test.Covered" +
+ "File\032:\n\013CoveredFile\022\021\n\tfile_uuid\030\001 \001(\t\022\030" +
+ "\n\014covered_line\030\002 \003(\005B\002\020\001B\002H\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -4991,7 +5148,7 @@ public final class FileSourceDb {
internal_static_org_sonar_server_source_db_Test_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_sonar_server_source_db_Test_descriptor,
- new java.lang.String[] { "Name", "Status", "ExecutionTimeMs", "Stacktrace", "Msg", "CoveredFile", });
+ new java.lang.String[] { "Uuid", "Name", "Status", "ExecutionTimeMs", "Stacktrace", "Msg", "CoveredFile", });
internal_static_org_sonar_server_source_db_Test_CoveredFile_descriptor =
internal_static_org_sonar_server_source_db_Test_descriptor.getNestedTypes().get(0);
internal_static_org_sonar_server_source_db_Test_CoveredFile_fieldAccessorTable = new
diff --git a/sonar-batch-protocol/src/main/protobuf/file_source_db.proto b/sonar-batch-protocol/src/main/protobuf/file_source_db.proto
index c28069157c1..b14bd891038 100644
--- a/sonar-batch-protocol/src/main/protobuf/file_source_db.proto
+++ b/sonar-batch-protocol/src/main/protobuf/file_source_db.proto
@@ -75,6 +75,7 @@ message Data {
}
message Test {
+ optional string uuid = 1;
optional string name = 2;
optional TestStatus status = 3;
optional int64 execution_time_ms = 4;
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
index 6f6b32389fe..223e997950e 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
@@ -324,7 +324,7 @@ public class BatchReportReaderTest {
BatchReportWriter writer = new BatchReportWriter(dir);
writer.writeTests(1, Arrays.asList(
BatchReport.Test.newBuilder()
- .setExecutionTimeMs(60_000)
+ .setDurationInMs(60_000)
.setStacktrace("stacktrace")
.setMsg("message")
.setStatus(Constants.TestStatus.OK)
@@ -332,7 +332,7 @@ public class BatchReportReaderTest {
try (InputStream inputStream = FileUtils.openInputStream(sut.readTests(1))) {
BatchReport.Test testResult = BatchReport.Test.PARSER.parseDelimitedFrom(inputStream);
- assertThat(testResult.getExecutionTimeMs()).isEqualTo(60_000);
+ assertThat(testResult.getDurationInMs()).isEqualTo(60_000);
assertThat(testResult.getStacktrace()).isEqualTo("stacktrace");
assertThat(testResult.getMsg()).isEqualTo("message");
assertThat(testResult.getStatus()).isEqualTo(Constants.TestStatus.OK);
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
index 07df74fba01..af0e95b25fd 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
@@ -271,5 +271,9 @@ public class FileSourceDto {
public static class Type {
public static final String SOURCE = "SOURCE";
public static final String TEST = "TEST";
+
+ private Type() {
+ // utility class
+ }
}
}