Is there a better way of doing this other than che...
# konsist
e
Is there a better way of doing this other than checking
toString
?
Copy code
@MethodSource("entityClasses")
    @ParameterizedTest(name = "test {1} child collections that are not an immutable Set have @OneToMany(orphanRemoval = true)")
    fun `test entities mutable child collections have @OneToMany(orphanRemoval = true)`(
        entityClass: Class<*>,
        className: String,
    ) {
        expectThat(entityClass.kotlin.declaredMemberProperties)
            .filter { it.returnType.isSubtypeOf(Collection::class.starProjectedType) }
            .filterNot { it.returnType.toString().startsWith("kotlin.collections.Set") }
            .map { requireNotNull(it.javaField).getAnnotation(OneToMany::class.java) }
            .all { get { orphanRemoval }.isTrue() }
    }
i
Hard to help as there is to much stuff going on here and code barely resembles Konist test. Perhaps you can convert this to isolated, non ParameterizedTest?
e
I'm sorry, this is written using Strikt, not Konsist. Ignore this. Our design/architecture tests are a mix of Strikt and Konsist.
👍 1