Итак, у меня есть следующий тест
@Test
fun `when save claims is called with email saved to that profile` () {
//arrange
given(profileRepository.findProfileByEmail(anyString())).willAnswer { daoProfile }
given(patientRepository.findById(anyInt())).willAnswer { Optional.of(daoPatient) }
given(claimRepository.saveAll(anyList())).willAnswer { mutableListOf(daoClaim) }
//act
val result = claimService.saveClaimsForEmail(listOf(dtoClaim), "Test@test.test")
//assert
assert(result != null)
assert(result?.isNotEmpty() ?: false)
verify(claimRepository).saveAll(anyList())
}
Строка given(claimRepository.saveAll(anyList())).willAnswer { mutableListOf(daoClaim) }
выдает следующую ошибку
e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Failed to generate expression: KtBlockExpression
File being compiled at position: (217,71) in /Users/archer/Work/masterhealth/master_billing/src/test/kotlin/com/masterhealthsoftware/master_billing/data/service/ClaimServiceTest.kt
The root cause java.lang.IllegalStateException was thrown at: org.jetbrains.kotlin.codegen.state.KotlinTypeMapper$typeMappingConfiguration$1.processErrorType(KotlinTypeMapper.kt:113)
...
Caused by: java.lang.IllegalStateException: Error type encountered: (???..???) (FlexibleTypeImpl).
at org.jetbrains.kotlin.codegen.state.KotlinTypeMapper$typeMappingConfiguration$1.processErrorType(KotlinTypeMapper.kt:113)
Когда строка удалена, она компилируется, но тест не выполняется для очевидного причины.
ApplicRespoitory помечен @MockBean в верхней части тестового класса и является JpaInterface. Строка 217 является началом функции. Я также tr ie, используя when
и другие различные willReturn или willAnswer ....
Есть идеи почему?