Is it possible, to mock the event-store with Mockito in Axon for using in TestFixture?
If I run my Tests, I get an Assertion-Error, because no events get thrown. I assume, that I somehow must configure my mocked EventStore correctly.
class CommandHandlingTest {
private val eventStore: EventStore = Mockito.mock(EventStore::class.java)
private val aggregateRepository: Repository<Qualification> =
EventSourcingRepository.builder(MyAggregate::class.java).eventStore(eventStore).build()
private val fixture = AggregateTestFixture(MyAggregate::class.java)
init {
fixture.registerInjectableResource(eventStore)
fixture.registerInjectableResource(aggregateRepository)
fixture.registerAnnotatedCommandHandler(CreateQualificationHandler(aggregateRepository))
}
@Test
fun `Test Command Handling`() {
val uuid = UUID.randomUUID()
val title = "New Qualification"
fixture
.given()
.`when`(MyCommand(uuid.toString(), title))
.expectSuccessfulHandlerExecution()
.expectEvents(MyEvent(uuid, title))
}
}