From 83e185826c57a1d287d0f622fc50f80017fad944 Mon Sep 17 00:00:00 2001 From: Lukasz Jarocki Date: Tue, 14 Mar 2023 11:30:05 +0100 Subject: [PATCH] SONAR-18679 moved unit test to integration test in sonar-scanner-protocol --- .../output/ScannerReportReaderIT.java} | 2 +- .../input/ProjectRepositoriesTest.java | 1 - .../output/ScannerReportWriterTest.java | 21 ++++----- .../ReportComponentsTest/expected.json | 43 ------------------- 4 files changed, 10 insertions(+), 57 deletions(-) rename sonar-scanner-protocol/src/{test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java => it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java} (99%) delete mode 100644 sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/output/component/ReportComponentsTest/expected.json diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java b/sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java similarity index 99% rename from sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java rename to sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java index ac686857cbb..497b131bc46 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java +++ b/sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java @@ -44,7 +44,7 @@ import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -public class ScannerReportReaderTest { +public class ScannerReportReaderIT { private static final int UNKNOWN_COMPONENT_REF = 123; diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java index 2918a438acc..c9c0cf8a66b 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java @@ -20,7 +20,6 @@ package org.sonar.scanner.protocol.input; import com.google.common.collect.Maps; -import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java index ca35d3c7b93..d0853ac4ba1 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java @@ -21,6 +21,7 @@ package org.sonar.scanner.protocol.output; import com.google.common.collect.Iterators; import java.io.File; +import java.util.List; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,21 +33,17 @@ import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType; import org.sonar.scanner.protocol.output.ScannerReport.Measure.DoubleValue; import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType; -import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; public class ScannerReportWriterTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - File dir; - private FileStructure fileStructure; private ScannerReportWriter underTest; @Before public void setUp() throws Exception { - fileStructure = new FileStructure(temp.newFolder()); - underTest = new ScannerReportWriter(fileStructure); + underTest = new ScannerReportWriter(new FileStructure(temp.newFolder())); } @Test @@ -99,7 +96,7 @@ public class ScannerReportWriterTest { .setMsg("the message") .build(); - underTest.writeComponentIssues(1, asList(issue)); + underTest.writeComponentIssues(1, List.of(issue)); assertThat(underTest.hasComponentData(FileStructure.Domain.ISSUES, 1)).isTrue(); File file = underTest.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1); @@ -227,7 +224,7 @@ public class ScannerReportWriterTest { .build()) .build()) .build(); - underTest.writeComponentDuplications(1, asList(duplication)); + underTest.writeComponentDuplications(1, List.of(duplication)); assertThat(underTest.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isTrue(); File file = underTest.getFileStructure().fileFor(FileStructure.Domain.DUPLICATIONS, 1); @@ -250,7 +247,7 @@ public class ScannerReportWriterTest { .setStartTokenIndex(10) .setEndTokenIndex(15) .build(); - underTest.writeCpdTextBlocks(1, asList(duplicationBlock)); + underTest.writeCpdTextBlocks(1, List.of(duplicationBlock)); assertThat(underTest.hasComponentData(FileStructure.Domain.CPD_TEXT_BLOCKS, 1)).isTrue(); File file = underTest.getFileStructure().fileFor(FileStructure.Domain.CPD_TEXT_BLOCKS, 1); @@ -286,7 +283,7 @@ public class ScannerReportWriterTest { .build()) .build(); - underTest.writeComponentSymbols(1, asList(symbol)); + underTest.writeComponentSymbols(1, List.of(symbol)); assertThat(underTest.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isTrue(); @@ -302,7 +299,7 @@ public class ScannerReportWriterTest { // no data yet assertThat(underTest.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isFalse(); - underTest.writeComponentSyntaxHighlighting(1, asList( + underTest.writeComponentSyntaxHighlighting(1, List.of( ScannerReport.SyntaxHighlightingRule.newBuilder() .setRange(ScannerReport.TextRange.newBuilder() .setStartLine(1) @@ -319,7 +316,7 @@ public class ScannerReportWriterTest { // no data yet assertThat(underTest.hasComponentData(FileStructure.Domain.SGNIFICANT_CODE, 1)).isFalse(); - underTest.writeComponentSignificantCode(1, asList( + underTest.writeComponentSignificantCode(1, List.of( ScannerReport.LineSgnificantCode.newBuilder() .setLine(1) .setStartOffset(2) @@ -334,7 +331,7 @@ public class ScannerReportWriterTest { // no data yet assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isFalse(); - underTest.writeComponentCoverage(1, asList( + underTest.writeComponentCoverage(1, List.of( ScannerReport.LineCoverage.newBuilder() .setLine(1) .setConditions(1) diff --git a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/output/component/ReportComponentsTest/expected.json b/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/output/component/ReportComponentsTest/expected.json deleted file mode 100644 index 581bbc5ea23..00000000000 --- a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/output/component/ReportComponentsTest/expected.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "analysisDate": "2012-12-12T00:00:00+0100", - "root": { - "batchId": 1, - "id": 11, - "snapshotId": 111, - "name": "Root project", - "type": "PRJ", - "children": [ - { - "batchId": 2, - "id": 22, - "snapshotId": 222, - "path": "module1", - "name": "Module", - "type": "MOD", - "children": [ - { - "batchId": 3, - "id": 33, - "snapshotId": 333, - "path": "src", - "name": "src", - "type": "DIR", - "children": [ - { - "batchId": 4, - "id": 44, - "snapshotId": 444, - "path": "Foo.java", - "name": "Foo.java", - "type": "FIL", - "languageKey": "java", - "isTest": true, - "children": [] - } - ] - } - ] - } - ] - } -} \ No newline at end of file -- 2.39.5