I'm trying to mock out my calls to hibernate using the mockk framework. I need to mock the Query object that is returned by here. When I use the following code I get this compiler error, which not being a kotlin developer I don't understand.
Type mismatch: inferred type is () -> Query but Query<(raw) Any!>! was expected
var mockedQuery = mockk<Query<Any>>{ }
var mockSessionFactory = mockk<SessionFactory> {
every { openSession() } returns mockk {
every { get(any(), any()) } returns { null }
every { createQuery("delete from SaveableObject where expiration < getdate() ") } returns { mockedQuery }
}
How do I mock out that Query object?