in.specmatic.test.reports.coverage.json.OpenApiCoverageJsonRow.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit5-support Show documentation
Show all versions of junit5-support Show documentation
Run contracts as tests in Junit tests using Specmatic.
Deprecation Notice for group ID "in.specmatic"
******************************************************************************************************
Updates for "junit5-support" will no longer be available under the deprecated group ID "in.specmatic".
Please update your dependencies to use the new group ID "io.specmatic".
******************************************************************************************************
package `in`.specmatic.test.reports.coverage.json
import `in`.specmatic.test.TestResultRecord
import `in`.specmatic.test.reports.coverage.console.Remarks
import kotlinx.serialization.Serializable
@Serializable
class OpenApiCoverageJsonRow {
private val type: String?
private val repository: String?
private val branch: String?
private val specification: String?
private val serviceType: String?
private val operations: List
constructor(
type: String?,
repository: String?,
branch: String?,
specification: String?,
serviceType: String?,
testResults: List
) {
this.type = type
this.repository = repository
this.branch = branch
this.specification = specification
this.serviceType = serviceType
this.operations = buildOpenApiCoverageOperations(testResults)
}
private fun buildOpenApiCoverageOperations(testResults: List): List =
testResults.groupBy {
Triple(it.path, it.method, it.responseStatus)
}.map { (operationGroup, operationRows) ->
OpenApiCoverageOperation(
path = operationGroup.first,
method = operationGroup.second,
responseCode = operationGroup.third,
count = operationRows.count { it.isExercised },
coverageStatus = Remarks.resolve(operationRows).toString()
)
}
}