我正在Lagom(scala)中构建一个身份验证服务,它由一个设备实体和一个事件处理器组成。该服务使用JDBC插件而不是默认的Cassandra。在编写集成测试时,我发现事件处理器不是仅在初始化时调用事件。我不确定如何接近...
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]
}
集成测试初始化:
override def beforeAll: Unit = {
server = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
new ServiceTestApplication(ctx)
}
authService = server.serviceClient.implement[AuthService]
}
答案 0 :(得分:0)
要解决此问题,我必须使用WordSpec
而不是AsyncWordSpec
,默认的执行上下文会以某种方式与Lagom混淆,此外我还必须添加eventually
块来检查是否状态更新,因为事件处理不是立即处理,需要30秒。