I am building an authentication service in Lagom (scala) which consists of a device entity and an event processor. The service uses the JDBC plugin instead of the default Cassandra. While writing the integration tests I found out that the event processor is not being called on events only for initialization. I am not sure how to approach...
abstract class AuthApplication(context: LagomApplicationContext) extends LagomApplication(context)
with JdbcPersistenceComponents
with AhcWSComponents
with HikariCPComponents {
override lazy val lagomServer = serverFor[AuthService](wire[AuthServiceImpl])
lazy val jsonSerializerRegistry = AuthSerializerRegistry
lazy val jwtAuthenticator: PkiAuthenticator = new JwtAuthenticator(config.getConfig("jwt"))
lazy val tokenRepository = wire[TokenRepository]
persistentEntityRegistry.register(wire[DeviceEntity])
readSide.register(wire[DeviceEventProcessor])
wire[TokenScheduler]
}
The integration test initialization:
override def beforeAll: Unit = {
server = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
new ServiceTestApplication(ctx)
}
authService = server.serviceClient.implement[AuthService]
}
To solve this issue I had to use WordSpec
instead of AsyncWordSpec
, the default execution context messes with Lagom somehow and in addition I had to add an eventually
block to check if the state updated because the event processing is not immediately and takes like 30 seconds.