ENT-6092 Add flush to MockServices.withEntityManager (#4180)

This commit is contained in:
Dan Newton 2021-01-29 15:29:33 +00:00 committed by Dan Newton
parent d214f5ecbf
commit 682de39d4c

View File

@ -251,11 +251,15 @@ open class MockServices private constructor(
override fun jdbcSession(): Connection = persistence.createSession()
override fun <T : Any?> withEntityManager(block: EntityManager.() -> T): T {
return block(contextTransaction.entityManager)
return contextTransaction.entityManager.run {
block(this).also { flush () }
}
}
override fun withEntityManager(block: Consumer<EntityManager>) {
return block.accept(contextTransaction.entityManager)
return contextTransaction.entityManager.run {
block.accept(this).also { flush () }
}
}
}
}