ReaciveCrudRepository与Awaitility

huangapple go评论70阅读模式
英文:

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({ -&gt; repository.findById(id) }, { entry -&gt; entry.isPresent() })
            .get()

to reactive one:

SomeEntity entity = Awaitility.await()
            .atMost(1, TimeUnit.SECONDS)
            .until({ -&gt; repository.findById(id) }, { entry -&gt; 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({ -&gt;
                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({ -&gt;
                Transaction transaction = repository.findAll().blockFirst()
                transaction.currency == USD
                transaction.amount == 20})

huangapple
  • 本文由 发表于 2020年8月6日 23:10:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63286562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定