diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-16 21:41:03 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-16 21:41:03 +0200 |
commit | 57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27 (patch) | |
tree | 316a18fb54f71039b89ea405915a397018ce8cb8 /sonar-batch-protocol | |
parent | 97e740133e533f623b6a0bc774dda3804d8df62f (diff) | |
download | sonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.tar.gz sonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.zip |
Rename variables "sut" to "underTest" in tests
Diffstat (limited to 'sonar-batch-protocol')
3 files changed, 92 insertions, 84 deletions
diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto index 08c5340d366..6632bb8a6f9 100644 --- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto +++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto @@ -45,13 +45,21 @@ message Metadata { optional string project_key = 2; optional string branch = 3; optional int32 root_component_ref = 4; +} + +message ActiveRuleParameter { + optional string key = 1; + optional string value = 2; +} - /* - Keys of the rules that were enabled in Quality profiles. - A key is a string composed of the repository and the subKey, specific to the repository. Format is - "{repository}:{subKey}", for instance "java:NullDereference". - */ - repeated string active_rule_key = 5; +/* + The rules that are enabled in the Quality profiles associated with the project +*/ +message ActiveRule { + optional string rule_repository = 1; + optional string rule_key = 2; + optional Severity severity = 3; + repeated ActiveRuleParameter parameter = 4; } message ComponentLink { 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 805cda4dc4a..50afe349b6d 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 @@ -42,12 +42,12 @@ public class BatchReportReaderTest { File dir; - BatchReportReader sut; + BatchReportReader underTest; @Before public void setUp() throws Exception { dir = temp.newFolder(); - sut = new BatchReportReader(dir); + underTest = new BatchReportReader(dir); } @Test @@ -59,7 +59,7 @@ public class BatchReportReaderTest { .setRootComponentRef(1); writer.writeMetadata(metadata.build()); - BatchReport.Metadata readMetadata = sut.readMetadata(); + BatchReport.Metadata readMetadata = underTest.readMetadata(); assertThat(readMetadata.getAnalysisDate()).isEqualTo(15000000L); assertThat(readMetadata.getProjectKey()).isEqualTo("PROJECT_A"); assertThat(readMetadata.getRootComponentRef()).isEqualTo(1); @@ -67,7 +67,7 @@ public class BatchReportReaderTest { @Test(expected = IllegalStateException.class) public void fail_if_missing_metadata_file() { - sut.readMetadata(); + underTest.readMetadata(); } @Test @@ -78,12 +78,12 @@ public class BatchReportReaderTest { .setPath("src/main/java/Foo.java"); writer.writeComponent(component.build()); - assertThat(sut.readComponent(1).getPath()).isEqualTo("src/main/java/Foo.java"); + assertThat(underTest.readComponent(1).getPath()).isEqualTo("src/main/java/Foo.java"); } @Test(expected = IllegalStateException.class) public void fail_if_missing_file_on_component() { - sut.readComponent(UNKNOWN_COMPONENT_REF); + underTest.readComponent(UNKNOWN_COMPONENT_REF); } @Test @@ -94,13 +94,13 @@ public class BatchReportReaderTest { .build(); writer.writeComponentIssues(1, Arrays.asList(issue)); - assertThat(sut.readComponentIssues(1)).hasSize(1); - assertThat(sut.readComponentIssues(200)).isEmpty(); + assertThat(underTest.readComponentIssues(1)).hasSize(1); + assertThat(underTest.readComponentIssues(200)).isEmpty(); } @Test public void empty_list_if_no_issue_found() { - assertThat(sut.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty(); + assertThat(underTest.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty(); } @Test @@ -110,13 +110,13 @@ public class BatchReportReaderTest { .setStringValue("value_a"); writer.writeComponentMeasures(1, Arrays.asList(measure.build())); - assertThat(sut.readComponentMeasures(1)).hasSize(1); - assertThat(sut.readComponentMeasures(1).get(0).getStringValue()).isEqualTo("value_a"); + assertThat(underTest.readComponentMeasures(1)).hasSize(1); + assertThat(underTest.readComponentMeasures(1).get(0).getStringValue()).isEqualTo("value_a"); } @Test public void empty_list_if_no_measure_found() { - assertThat(sut.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty(); + assertThat(underTest.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty(); } @Test @@ -127,13 +127,13 @@ public class BatchReportReaderTest { .addChangeset(BatchReport.Changesets.Changeset.newBuilder().setDate(123_456_789).setAuthor("jack.daniels").setRevision("123-456-789")); writer.writeComponentChangesets(scm.build()); - assertThat(sut.readChangesets(1).getChangesetList()).hasSize(1); - assertThat(sut.readChangesets(1).getChangeset(0).getDate()).isEqualTo(123_456_789L); + assertThat(underTest.readChangesets(1).getChangesetList()).hasSize(1); + assertThat(underTest.readChangesets(1).getChangeset(0).getDate()).isEqualTo(123_456_789L); } @Test public void null_if_no_changeset_found() { - assertThat(sut.readChangesets(UNKNOWN_COMPONENT_REF)).isNull(); + assertThat(underTest.readChangesets(UNKNOWN_COMPONENT_REF)).isNull(); } @Test @@ -160,15 +160,15 @@ public class BatchReportReaderTest { .build(); writer.writeComponentDuplications(1, Arrays.asList(duplication)); - BatchReportReader sut = new BatchReportReader(dir); - assertThat(sut.readComponentDuplications(1)).hasSize(1); - assertThat(sut.readComponentDuplications(1).get(0).getOriginPosition()).isNotNull(); - assertThat(sut.readComponentDuplications(1).get(0).getDuplicateList()).hasSize(1); + BatchReportReader underTest = new BatchReportReader(dir); + assertThat(underTest.readComponentDuplications(1)).hasSize(1); + assertThat(underTest.readComponentDuplications(1).get(0).getOriginPosition()).isNotNull(); + assertThat(underTest.readComponentDuplications(1).get(0).getDuplicateList()).hasSize(1); } @Test public void empty_list_if_no_duplication_found() { - assertThat(sut.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty(); + assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty(); } @Test @@ -190,7 +190,7 @@ public class BatchReportReaderTest { .build() )); - try (InputStream inputStream = FileUtils.openInputStream(sut.readComponentSyntaxHighlighting(1))) { + try (InputStream inputStream = FileUtils.openInputStream(underTest.readComponentSyntaxHighlighting(1))) { BatchReport.SyntaxHighlighting syntaxHighlighting = BatchReport.SyntaxHighlighting.PARSER.parseDelimitedFrom(inputStream); assertThat(syntaxHighlighting.getRange()).isNotNull(); assertThat(syntaxHighlighting.getRange().getStartLine()).isEqualTo(1); @@ -201,7 +201,7 @@ public class BatchReportReaderTest { @Test public void return_null_if_no_highlighting_found() { - assertThat(sut.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isNull(); + assertThat(underTest.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isNull(); } @Test @@ -228,15 +228,15 @@ public class BatchReportReaderTest { .build()) .build())); - sut = new BatchReportReader(dir); - assertThat(sut.readComponentSymbols(1)).hasSize(1); - assertThat(sut.readComponentSymbols(1).get(0).getDeclaration().getStartLine()).isEqualTo(1); - assertThat(sut.readComponentSymbols(1).get(0).getReference(0).getStartLine()).isEqualTo(10); + underTest = new BatchReportReader(dir); + assertThat(underTest.readComponentSymbols(1)).hasSize(1); + assertThat(underTest.readComponentSymbols(1).get(0).getDeclaration().getStartLine()).isEqualTo(1); + assertThat(underTest.readComponentSymbols(1).get(0).getReference(0).getStartLine()).isEqualTo(10); } @Test public void empty_list_if_no_symbol_found() { - assertThat(sut.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty(); + assertThat(underTest.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty(); } @Test @@ -268,7 +268,7 @@ public class BatchReportReaderTest { .setOverallCoveredConditions(5) .build())); - sut = new BatchReportReader(dir); + underTest = new BatchReportReader(dir); try (InputStream inputStream = FileUtils.openInputStream(new BatchReportReader(dir).readComponentCoverage(1))) { BatchReport.Coverage coverage = BatchReport.Coverage.PARSER.parseDelimitedFrom(inputStream); @@ -293,7 +293,7 @@ public class BatchReportReaderTest { @Test public void return_null_if_no_coverage_found() { - assertThat(sut.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isNull(); + assertThat(underTest.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isNull(); } @Test @@ -317,7 +317,7 @@ public class BatchReportReaderTest { .setStatus(Constants.TestStatus.OK) .build())); - try (InputStream inputStream = FileUtils.openInputStream(sut.readTests(1))) { + try (InputStream inputStream = FileUtils.openInputStream(underTest.readTests(1))) { BatchReport.Test testResult = BatchReport.Test.PARSER.parseDelimitedFrom(inputStream); assertThat(testResult.getDurationInMs()).isEqualTo(60_000); assertThat(testResult.getStacktrace()).isEqualTo("stacktrace"); @@ -328,7 +328,7 @@ public class BatchReportReaderTest { @Test public void null_if_no_test_found() { - assertThat(sut.readTests(UNKNOWN_COMPONENT_REF)).isNull(); + assertThat(underTest.readTests(UNKNOWN_COMPONENT_REF)).isNull(); } @Test @@ -344,7 +344,7 @@ public class BatchReportReaderTest { .build() )); - try (InputStream inputStream = FileUtils.openInputStream(sut.readCoverageDetails(1))) { + try (InputStream inputStream = FileUtils.openInputStream(underTest.readCoverageDetails(1))) { BatchReport.CoverageDetail coverageDetail = BatchReport.CoverageDetail.PARSER.parseDelimitedFrom(inputStream); assertThat(coverageDetail.getTestName()).isEqualTo("test-name"); assertThat(coverageDetail.getCoveredFile(0).getFileRef()).isEqualTo(2); @@ -354,7 +354,7 @@ public class BatchReportReaderTest { @Test public void null_if_no_coverage_detail_found() { - assertThat(sut.readCoverageDetails(UNKNOWN_COMPONENT_REF)).isNull(); + assertThat(underTest.readCoverageDetails(UNKNOWN_COMPONENT_REF)).isNull(); } } diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java index cf33a8f6d8f..18716f7332f 100644 --- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java +++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java @@ -38,18 +38,18 @@ public class BatchReportWriterTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); File dir; - BatchReportWriter sut; + BatchReportWriter underTest; @Before public void setUp() throws Exception { dir = temp.newFolder(); - sut = new BatchReportWriter(dir); + underTest = new BatchReportWriter(dir); } @Test public void create_dir_if_does_not_exist() { FileUtils.deleteQuietly(dir); - sut = new BatchReportWriter(dir); + underTest = new BatchReportWriter(dir); assertThat(dir).isDirectory().exists(); } @@ -60,9 +60,9 @@ public class BatchReportWriterTest { .setAnalysisDate(15000000L) .setProjectKey("PROJECT_A") .setRootComponentRef(1); - sut.writeMetadata(metadata.build()); + underTest.writeMetadata(metadata.build()); - BatchReport.Metadata read = ProtobufUtil.readFile(sut.getFileStructure().metadataFile(), BatchReport.Metadata.PARSER); + BatchReport.Metadata read = ProtobufUtil.readFile(underTest.getFileStructure().metadataFile(), BatchReport.Metadata.PARSER); assertThat(read.getAnalysisDate()).isEqualTo(15000000L); assertThat(read.getProjectKey()).isEqualTo("PROJECT_A"); assertThat(read.getRootComponentRef()).isEqualTo(1); @@ -71,7 +71,7 @@ public class BatchReportWriterTest { @Test public void write_component() { // no data yet - assertThat(sut.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isFalse(); // write data BatchReport.Component.Builder component = BatchReport.Component.newBuilder() @@ -82,10 +82,10 @@ public class BatchReportWriterTest { .setIsTest(false) .addChildRef(5) .addChildRef(42); - sut.writeComponent(component.build()); + underTest.writeComponent(component.build()); - assertThat(sut.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue(); - File file = sut.getFileStructure().fileFor(FileStructure.Domain.COMPONENT, 1); + assertThat(underTest.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue(); + File file = underTest.getFileStructure().fileFor(FileStructure.Domain.COMPONENT, 1); assertThat(file).exists().isFile(); BatchReport.Component read = ProtobufUtil.readFile(file, BatchReport.Component.PARSER); assertThat(read.getRef()).isEqualTo(1); @@ -97,7 +97,7 @@ public class BatchReportWriterTest { @Test public void write_issues() { // no data yet - assertThat(sut.hasComponentData(FileStructure.Domain.ISSUES, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.ISSUES, 1)).isFalse(); // write data BatchReport.Issue issue = BatchReport.Issue.newBuilder() @@ -105,10 +105,10 @@ public class BatchReportWriterTest { .setMsg("the message") .build(); - sut.writeComponentIssues(1, Arrays.asList(issue)); + underTest.writeComponentIssues(1, Arrays.asList(issue)); - assertThat(sut.hasComponentData(FileStructure.Domain.ISSUES, 1)).isTrue(); - File file = sut.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1); + assertThat(underTest.hasComponentData(FileStructure.Domain.ISSUES, 1)).isTrue(); + File file = underTest.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1); assertThat(file).exists().isFile(); BatchReport.Issues read = ProtobufUtil.readFile(file, BatchReport.Issues.PARSER); assertThat(read.getComponentRef()).isEqualTo(1); @@ -117,7 +117,7 @@ public class BatchReportWriterTest { @Test public void write_measures() { - assertThat(sut.hasComponentData(FileStructure.Domain.MEASURES, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.MEASURES, 1)).isFalse(); BatchReport.Measure measure = BatchReport.Measure.newBuilder() .setStringValue("text-value") @@ -126,10 +126,10 @@ public class BatchReportWriterTest { .setDescription("description") .build(); - sut.writeComponentMeasures(1, Arrays.asList(measure)); + underTest.writeComponentMeasures(1, Arrays.asList(measure)); - assertThat(sut.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue(); - File file = sut.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1); + assertThat(underTest.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue(); + File file = underTest.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1); assertThat(file).exists().isFile(); BatchReport.Measures measures = ProtobufUtil.readFile(file, BatchReport.Measures.PARSER); assertThat(measures.getComponentRef()).isEqualTo(1); @@ -142,7 +142,7 @@ public class BatchReportWriterTest { @Test public void write_scm() { - assertThat(sut.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isFalse(); BatchReport.Changesets scm = BatchReport.Changesets.newBuilder() .setComponentRef(1) @@ -153,10 +153,10 @@ public class BatchReportWriterTest { .setDate(123_456_789L)) .build(); - sut.writeComponentChangesets(scm); + underTest.writeComponentChangesets(scm); - assertThat(sut.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isTrue(); - File file = sut.getFileStructure().fileFor(FileStructure.Domain.CHANGESETS, 1); + assertThat(underTest.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isTrue(); + File file = underTest.getFileStructure().fileFor(FileStructure.Domain.CHANGESETS, 1); assertThat(file).exists().isFile(); BatchReport.Changesets read = ProtobufUtil.readFile(file, BatchReport.Changesets.PARSER); assertThat(read.getComponentRef()).isEqualTo(1); @@ -167,7 +167,7 @@ public class BatchReportWriterTest { @Test public void write_duplications() { - assertThat(sut.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isFalse(); BatchReport.Duplication duplication = BatchReport.Duplication.newBuilder() .setOriginPosition(Range.newBuilder() @@ -183,10 +183,10 @@ public class BatchReportWriterTest { .build()) .build()) .build(); - sut.writeComponentDuplications(1, Arrays.asList(duplication)); + underTest.writeComponentDuplications(1, Arrays.asList(duplication)); - assertThat(sut.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isTrue(); - File file = sut.getFileStructure().fileFor(FileStructure.Domain.DUPLICATIONS, 1); + assertThat(underTest.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isTrue(); + File file = underTest.getFileStructure().fileFor(FileStructure.Domain.DUPLICATIONS, 1); assertThat(file).exists().isFile(); BatchReport.Duplications duplications = ProtobufUtil.readFile(file, BatchReport.Duplications.PARSER); assertThat(duplications.getComponentRef()).isEqualTo(1); @@ -198,7 +198,7 @@ public class BatchReportWriterTest { @Test public void write_symbols() { // no data yet - assertThat(sut.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isFalse(); // write data BatchReport.Symbols.Symbol symbol = BatchReport.Symbols.Symbol.newBuilder() @@ -216,11 +216,11 @@ public class BatchReportWriterTest { .build()) .build(); - sut.writeComponentSymbols(1, Arrays.asList(symbol)); + underTest.writeComponentSymbols(1, Arrays.asList(symbol)); - assertThat(sut.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isTrue(); + assertThat(underTest.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isTrue(); - File file = sut.getFileStructure().fileFor(FileStructure.Domain.SYMBOLS, 1); + File file = underTest.getFileStructure().fileFor(FileStructure.Domain.SYMBOLS, 1); assertThat(file).exists().isFile(); BatchReport.Symbols read = ProtobufUtil.readFile(file, BatchReport.Symbols.PARSER); assertThat(read.getFileRef()).isEqualTo(1); @@ -232,9 +232,9 @@ public class BatchReportWriterTest { @Test public void write_syntax_highlighting() { // no data yet - assertThat(sut.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isFalse(); - sut.writeComponentSyntaxHighlighting(1, Arrays.asList( + underTest.writeComponentSyntaxHighlighting(1, Arrays.asList( BatchReport.SyntaxHighlighting.newBuilder() .setRange(BatchReport.Range.newBuilder() .setStartLine(1) @@ -242,17 +242,17 @@ public class BatchReportWriterTest { .build()) .setType(Constants.HighlightingType.ANNOTATION) .build() - )); + )); - assertThat(sut.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isTrue(); + assertThat(underTest.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isTrue(); } @Test public void write_coverage() { // no data yet - assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isFalse(); - sut.writeComponentCoverage(1, Arrays.asList( + underTest.writeComponentCoverage(1, Arrays.asList( BatchReport.Coverage.newBuilder() .setLine(1) .setConditions(1) @@ -262,31 +262,31 @@ public class BatchReportWriterTest { .setItCoveredConditions(1) .setOverallCoveredConditions(1) .build() - )); + )); - assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isTrue(); + assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isTrue(); } @Test public void write_tests() { - assertThat(sut.hasComponentData(FileStructure.Domain.TESTS, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.TESTS, 1)).isFalse(); - sut.writeTests(1, Arrays.asList( + underTest.writeTests(1, Arrays.asList( BatchReport.Test.getDefaultInstance() - )); + )); - assertThat(sut.hasComponentData(FileStructure.Domain.TESTS, 1)).isTrue(); + assertThat(underTest.hasComponentData(FileStructure.Domain.TESTS, 1)).isTrue(); } @Test public void write_coverage_details() { - assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isFalse(); + assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isFalse(); - sut.writeCoverageDetails(1, Arrays.asList( + underTest.writeCoverageDetails(1, Arrays.asList( BatchReport.CoverageDetail.getDefaultInstance() - )); + )); - assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isTrue(); + assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isTrue(); } } |