Hello there
Is it possible to mock the EventStore for junit Tests with mockito?
class QualificationCommandHandlingTests {
private val eventStore: EventStore = Mockito.mock(EventStore::class.java)
private val qualificationRepository: Repository<Qualification> =
EventSourcingRepository.builder(Qualification::class.java).eventStore(eventStore).build()
private val fixture = AggregateTestFixture(Qualification::class.java)
init {
fixture.registerInjectableResource(eventStore)
fixture.registerInjectableResource(qualificationRepository)
fixture.registerAnnotatedCommandHandler(CreateQualificationHandler(qualificationRepository))
}
@Test
fun `Test Qualification Command Handling`() {
val uuid = UUID.randomUUID()
val title = "New Qualification"
fixture
.given()
.`when`(CreateQualification(uuid.toString(), title))
.expectSuccessfulHandlerExecution()
.expectEvents(QualificationCreated(uuid, title))
}
}
Does not work, because of course does not throw any events.