Skip to content

Commit cec19f2

Browse files
authored
Merge pull request #595 from cqse/ts/38628_iterative_kotlin_migration
[TS-38628] [Report-Generator] Migration to Kotlin
2 parents a5b04db + 92af16c commit cec19f2

File tree

105 files changed

+2765
-3182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2765
-3182
lines changed

agent/src/main/java/com/teamscale/jacoco/agent/testimpact/CoverageToJsonStrategyBase.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private String createTestwiseCoverageReport(boolean partial) throws IOException,
121121
if (execution == null) {
122122
return null;
123123
} else {
124-
return execution.getUniformPath();
124+
return execution.uniformPath;
125125
}
126126
}).collect(toList());
127127

@@ -132,10 +132,9 @@ private String createTestwiseCoverageReport(boolean partial) throws IOException,
132132
reportGenerator.updateClassDirCache();
133133
TestwiseCoverage testwiseCoverage = reportGenerator.convert(testExecFile);
134134
logger.debug("Created testwise coverage report (containing coverage for tests `{}`)",
135-
testwiseCoverage.getTests().stream().map(TestCoverageBuilder::getUniformPath).collect(toList()));
135+
testwiseCoverage.getTests().values().stream().map(TestCoverageBuilder::getUniformPath).collect(toList()));
136136

137-
TestwiseCoverageReport report = TestwiseCoverageReportBuilder
138-
.createFrom(availableTests, testwiseCoverage.getTests(), testExecutions, partial);
137+
TestwiseCoverageReport report = TestwiseCoverageReportBuilder.createFrom(availableTests, testwiseCoverage.getTests().values(), testExecutions, partial);
139138

140139
testExecFile.delete();
141140
testExecFile = null;

agent/src/main/java/com/teamscale/jacoco/agent/testimpact/CoverageViaHttpStrategy.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.teamscale.report.testwise.model.builder.TestInfoBuilder;
1212
import org.slf4j.Logger;
1313

14+
import java.util.Objects;
15+
1416
/**
1517
* Strategy which directly converts the collected coverage into a JSON object in place and returns the result to the
1618
* caller as response to the http request. If a test execution is given it is merged into the representation and
@@ -36,12 +38,12 @@ public TestInfo testEnd(String test, TestExecution testExecution)
3638
TestInfoBuilder builder = new TestInfoBuilder(test);
3739
Dump dump = controller.dumpAndReset();
3840
reportGenerator.updateClassDirCache();
39-
builder.setCoverage(reportGenerator.convert(dump));
41+
builder.setCoverage(Objects.requireNonNull(reportGenerator.convert(dump)));
4042
if (testExecution != null) {
4143
builder.setExecution(testExecution);
4244
}
4345
TestInfo testInfo = builder.build();
44-
logger.debug("Generated test info {}", testInfo.toString());
46+
logger.debug("Generated test info {}", testInfo);
4547
return testInfo;
4648
}
4749
}

agent/src/main/java/com/teamscale/jacoco/agent/testimpact/TestEventHandlerStrategyBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testStart(String test) {
6565
public TestInfo testEnd(String test,
6666
TestExecution testExecution) throws JacocoRuntimeController.DumpException, CoverageGenerationException {
6767
if (testExecution != null) {
68-
testExecution.setUniformPath(test);
68+
testExecution.uniformPath = test;
6969
if (startTimestamp != -1) {
7070
long endTimestamp = System.currentTimeMillis();
7171
testExecution.setDurationMillis(endTimestamp - startTimestamp);

agent/src/main/java/com/teamscale/jacoco/agent/upload/HttpZipUploaderBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private File createZipFile(CoverageFile coverageFile) throws IOException {
143143
*/
144144
private void fillZipFile(ZipOutputStream zipOutputStream, CoverageFile coverageFile) throws IOException {
145145
zipOutputStream.putNextEntry(new ZipEntry(getZipEntryCoverageFileName(coverageFile)));
146-
coverageFile.copy(zipOutputStream);
146+
coverageFile.copyStream(zipOutputStream);
147147

148148
for (Path additionalFile : additionalMetaDataFiles) {
149149
zipOutputStream.putNextEntry(new ZipEntry(additionalFile.getFileName().toString()));

common-system-test/src/main/java/com/teamscale/test/commons/SystemTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class SystemTestUtils {
4949
* Example: {@code file1.java:1,7-12;file2.java:9-22,33}
5050
*/
5151
public static String getCoverageString(TestInfo info) {
52-
return info.paths.stream().flatMap(path -> path.getFiles().stream())
52+
return info.paths.stream().flatMap(path -> path.files.stream())
5353
.map(file -> file.fileName + ":" + file.coveredLines).collect(
5454
Collectors.joining(";"));
5555
}

impacted-test-engine/src/test/java/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListenerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ void testInteractionWithListenersAndCoverageApi() {
8585

8686
assertThat(testExecutions).hasSize(2);
8787
assertThat(testExecutions).anySatisfy(testExecution ->
88-
assertThat(testExecution.getUniformPath()).isEqualTo("MyClass/impactedTestCase()"));
88+
assertThat(testExecution.uniformPath).isEqualTo("MyClass/impactedTestCase()"));
8989
assertThat(testExecutions).anySatisfy(testExecution ->
90-
assertThat(testExecution.getUniformPath()).isEqualTo("MyClass/regularSkippedTestCase()"));
90+
assertThat(testExecution.uniformPath).isEqualTo("MyClass/regularSkippedTestCase()"));
9191
}
9292

9393
@Test
@@ -125,6 +125,6 @@ void testSkipOfTestClass() {
125125

126126
assertThat(testExecutions).hasSize(2);
127127
assertThat(testExecutions)
128-
.allMatch(testExecution -> testExecution.getResult().equals(ETestExecutionResult.SKIPPED));
128+
.allMatch(testExecution -> testExecution.result.equals(ETestExecutionResult.SKIPPED));
129129
}
130130
}

report-generator/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
com.teamscale.`java-convention`
44
com.teamscale.coverage
55
com.teamscale.publish
6+
kotlin("jvm")
67
}
78

89
publishAs {

report-generator/src/main/java/com/teamscale/report/EDuplicateClassFileBehavior.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

report-generator/src/main/java/com/teamscale/report/ReportUtils.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

report-generator/src/main/java/com/teamscale/report/jacoco/CoverageFile.java

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)