英文:
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()
签名是:
Optional<ENTITY> findById(Long id)
第二个 findById()
签名是:
Mono<T> findById(ID id)
英文:
writing tests and not sure how can one rewrite this code:
SomeEntity entity = Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.until({ -> repository.findById(id) }, { entry -> entry.isPresent() })
.get()
to reactive one:
SomeEntity entity = Awaitility.await()
.atMost(1, TimeUnit.SECONDS)
.until({ -> repository.findById(id) }, { entry -> entry.???() })
.block()
Note:
first findById() signature is:
Optional<ENTITY> findById(Long id)
second findById() signature is: Mono<T> findById(ID id)
答案1
得分: 0
可以这样做:
Awaitility.await().atMost(1, SECONDS).until({ ->
Transaction transaction = repository.findAll().blockFirst()
transaction.currency == USD
transaction.amount == 20})
英文:
It is possible to do something like this:
Awaitility.await().atMost(1, SECONDS).until({ ->
Transaction transaction = repository.findAll().blockFirst()
transaction.currency == USD
transaction.amount == 20})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论