Sprich, ich habe die folgende Schnittstelle:getAnnotation für Java Annotations auf Kotlin Methode gibt null zurück
interface AppRepository : GraphRepository<App> {
@Query("""MATCH (a:App) RETURN a""")
fun findAll(): List<App>
}
In einem Test Ich möchte Besonderheiten der Query-String überprüfen und deshalb muss ich
open class AppRepositoryTest {
lateinit @Autowired var appRepository: AppRepository
@Test
open fun checkQuery() {
val productionMethod = appRepository.javaClass.getDeclaredMethod("findAll")
val productionQuery = productionMethod!!.getAnnotation(Query::class.java)
//demo test
assertThat(productionQuery!!.value).isNotEmpty() //KotlinNPE
}
}
Aus einem Grund, den ich nicht verstehe, productionQuery
ist n null
. Ich habe überprüft, dass die Typen der importierten Query
in der Testklasse und die Query
im Repository identisch sind.
Also, warum ist die productionQuery
null
in diesem Fall?
verdammt :) so peinlich. –