具有等待性的 ReaciveCrudRepository

ReaciveCrudRepository with Awaitility

正在编写测试但不确定如何重写此代码:

SomeEntity entity = Awaitility.await()
            .atMost(1, TimeUnit.SECONDS)
            .until({ -> repository.findById(id) }, { entry -> entry.isPresent() })
            .get()

反应型:

SomeEntity entity = Awaitility.await()
            .atMost(1, TimeUnit.SECONDS)
            .until({ -> repository.findById(id) }, { entry -> entry.???() })
            .block()

注:

第一个 findById() 签名是: 可选的 findById(Long id)

第二个 findById() 签名是:Mono findById(ID id)

可以这样做:

Awaitility.await().atMost(1, SECONDS).until({ ->
                Transaction transaction = repository.findAll().blockFirst()
                transaction.currency == USD
                transaction.amount == 20})