-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
276: further implementation of sensors for process test coverage
- Loading branch information
Showing
14 changed files
with
210 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
...ain/kotlin/org/camunda/community/process_test_coverage/core/export/CoverageStateResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
package org.camunda.community.process_test_coverage.core.export | ||
|
||
import org.camunda.community.process_test_coverage.core.model.Coverage | ||
import org.camunda.community.process_test_coverage.core.model.Event | ||
import org.camunda.community.process_test_coverage.core.model.Model | ||
import org.camunda.community.process_test_coverage.core.model.Suite | ||
|
||
data class CoverageStateResult( | ||
class CoverageStateResult( | ||
val suites: Collection<Suite>, | ||
val models: Collection<Model> | ||
) | ||
) : Coverage { | ||
override fun getEvents() = suites.map { it.getEvents() }.flatten() | ||
|
||
override fun getEvents(modelKey: String) = suites.map { it.getEvents(modelKey) }.flatten() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
kotlinVersion=1.7.21 | ||
kotlinVersion=1.9.10 | ||
projectName=report-aggregator-gradle-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...-plugin/src/main/kotlin/org/camunda/community/process_test_coverage/sonar/BpmnLanguage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.camunda.community.process_test_coverage.sonar | ||
|
||
import org.sonar.api.resources.AbstractLanguage | ||
|
||
class BpmnLanguage : AbstractLanguage(KEY, NAME) { | ||
|
||
companion object { | ||
const val NAME = "BPMN" | ||
const val KEY = "bpmn" | ||
} | ||
|
||
override fun getFileSuffixes() = arrayOf(".bpmn") | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...n/src/main/kotlin/org/camunda/community/process_test_coverage/sonar/BpmnQualityProfile.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.camunda.community.process_test_coverage.sonar | ||
|
||
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition | ||
|
||
|
||
class BpmnQualityProfile : BuiltInQualityProfilesDefinition { | ||
override fun define(context: BuiltInQualityProfilesDefinition.Context) { | ||
val profile = context.createBuiltInQualityProfile("BPMN Rules", BpmnLanguage.KEY) | ||
profile.setDefault(true) | ||
profile.done() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...lin/org/camunda/community/process_test_coverage/sonar/ProcessTestCoverageProjectSensor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.camunda.community.process_test_coverage.sonar | ||
|
||
import org.camunda.community.process_test_coverage.core.export.CoverageStateJsonExporter.combineCoverageStateResults | ||
import org.camunda.community.process_test_coverage.core.export.CoverageStateJsonExporter.readCoverageStateResult | ||
import org.sonar.api.batch.sensor.SensorContext | ||
import org.sonar.api.batch.sensor.SensorDescriptor | ||
import org.sonar.api.scanner.sensor.ProjectSensor | ||
import org.sonar.api.utils.log.Loggers | ||
import java.nio.file.Files | ||
|
||
|
||
class ProcessTestCoverageProjectSensor : ProjectSensor { | ||
|
||
companion object { | ||
private val LOG = Loggers.get(ProcessTestCoverageProjectSensor::class.java) | ||
} | ||
|
||
override fun describe(descriptor: SensorDescriptor) { | ||
descriptor.name("Process Test Coverage Report Importer") | ||
} | ||
|
||
override fun execute(context: SensorContext) { | ||
val reportPathsProvider = ReportPathsProvider(context) | ||
val importer = ReportImporter(context) | ||
importReports(reportPathsProvider, importer) | ||
} | ||
|
||
private fun importReports(reportPathsProvider: ReportPathsProvider, importer: ReportImporter) { | ||
val reportPaths = reportPathsProvider.getPaths() | ||
if (reportPaths.isEmpty()) { | ||
LOG.info("No report imported, no coverage information will be imported by Process Test Coverage Report Importer") | ||
return | ||
} | ||
LOG.info( | ||
"Importing {} report(s). Turn your logs in debug mode in order to see the exhaustive list.", | ||
reportPaths.size | ||
) | ||
try { | ||
reportPaths | ||
.map { | ||
LOG.debug("Reading report '{}'", it) | ||
Files.readAllBytes(it).decodeToString() | ||
} | ||
.reduceOrNull { result1, result2 -> combineCoverageStateResults(result1, result2) } | ||
?.let { importer.importProjectCoverage(readCoverageStateResult(it)) } | ||
?: LOG.warn("No coverage results found, skipping analysis") | ||
} catch (e: Exception) { | ||
LOG.error("Coverage reports could not be read/imported. Error: {}", e) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.