Eric
09/05/2023, 9:28 PMclass ControllerConsistencyTests {
@ParameterizedTest
@MethodSource("controllers")
fun `classes with @RestController annotation should have 'Controller' suffix`(controller: KoClassDeclaration) {
controller.assert { it.hasNameEndingWith("Controller") }
}
companion object {
@JvmStatic
fun controllers() = Konsist.scopeFromProject().classes().withAllAnnotationsOf(RestController::class)
}
}
added a little ext fun:
fun <E : KoBaseProvider> E.assert(function: (E) -> Boolean) { listOf(this).assert(function) }
igor.wojda
09/06/2023, 5:50 AMassert
.
We have tried multiple iteration of the API, before and current one seems to be top in terms of low verbosity and usability.
I would not recommend going this path.