My goal is to test a method of a repository interface. I had some errors when I ran this, but I fixed them (hope so). But I don't understand the following one: TheFullErrorStack
I have no clue whats the reason for this error because I never use @BootstrapWith in my test class.
This is my test class:
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@SpringBootTest
@DataJpaTest
class DepartmentRepositoryTest {
@Autowired
private lateinit var entityManager: TestEntityManager
private lateinit var departmentRepository: DepartmentRepository
@Test
fun runFindAllByMembersContainsForNormalValuesShouldBeTrue() {
val departmentAddress = DepartmentAddress("Musterstraße 1", "0", "Musterstadt", "Musterland")
val cardLimits: MutableMap<JobType, Int> = mutableMapOf(Pair(JobType.EXPRESS, 1))
val members: HashSet<Long> = mutableSetOf<Long>(1) as HashSet<Long>
val department = Department("Test-Department", Cluster.CENTER, departmentAddress, cardLimits, true, PaymentMethods.CARD_PAYMENT_ONLY, "", "", members)
entityManager.persist(department)
entityManager.flush()
val userId = 1.toLong()
val departments = departmentRepository.findAllByMembersContains(userId)
Assertions.assertThat(departments).isEqualTo(arrayOf(department))
}
}
I dont't use @Autowire for the departmentRepository, because I would get the error that there is no bean in this interface.
Aucun commentaire:
Enregistrer un commentaire