How to find interfaces extending a specific interf...
# konsist
e
How to find interfaces extending a specific interface? This isn't working for me:
Copy code
@Test
    fun `interfaces extending JpaRepository should have 'Repository' suffix`() {
        Konsist
            .scopeFromProduction()
            .interfaces()
            .withInterfaceNamed(JpaRepository::class.jvmName)
            .assertTrue { it.hasNameEndingWith("Repository") }
    }
If I log the interfaces with
.onEach { println("${it.name} ${it.interfaces()}") }
then it shows an empty list for each.
s
I've written this test for ViewModel class it might help you some how
@Test
`fun `classes extending ViewModel should have 'ViewModel' suffix`() {`
Konsist.scopeFromProduction(moduleName = "app")
.classes()
._withAllParentsOf_(ViewModel::class)
._assertTrue_ *{*
*it*.hasNameEndingWith("ViewModel")
}
}
👍 1
🙌 1
e
Copy code
@Test
    fun test() {
        Konsist
            .scopeFromProduction()
            .interfaces()
            .withParentOf(JpaRepository::class)
            .assertTrue { it.hasNameEndingWith("Repository") }
    }
thanks!
👍 1