There's maybe a need for both synchronous and asynchronous testing, no? It's true that I wasn't considering assertj under the angle of Observables, but does it really mean that we should eliminate the benefits of using a good library for all synchronous pieces of code?

If I take the example of our collectors such as the "NumericDataPointCollector" : it's used in a RX transformation flow, but the class itself has nothing asynchronous, it has some methods that I think are complex enough to be put under synchronous unit tests.

About TestSubscriber, I didn't know it, so thanks for sharing this! I'll try to use it instead of the "toBlocking" workaround in my last PR.

On Tue, Sep 6, 2016 at 5:19 PM, Michael Burman <> wrote:

While it's nice to have easier tests, this does not really work for metrics as we use RxJava and AssertJ has no support for any reactive frameworks. The assertJ provides next to nothing in that context, as most of our implementation is reactive in behavior. There are two projects that have tried to improve situation with RxJava, one abandoned because the author thinks TestSubscriber is better and second one is quite incomplete.

We don't currently write our tests well, that's true. We should be using TestSubscriber in multiple place instead of our current .toBlocking().lastOrDefault(null) (workaround). I really don't want the latter to be used more, since it's used in situations where it shouldn't be. Tests should be reactive just like our other code, and AssertJ can't provide that.

  -  Micke

----- Original Message -----
From: "Joel Takvorian" <>
To: "Discussions around Hawkular development" <>
Sent: Tuesday, September 6, 2016 5:24:16 PM
Subject: [Hawkular-dev]  Assertj framework


I'd like to propose the addition of the "assertj" lib in test scope for hawkular-metrics (and/or other modules).

If you don't know it, assertj is basically a "fluent assertion framework". You write assertions like :

assertThat(result) . extracting( DataPoint :: getTimestamp) . containsExactly( 0L , 1L , 5L , 7L , 10L );

It has a very rich collection of assertions, I find it particularly powerful when working on collections, whether they are sorted or not, whether they have nested objects or not.

Also, the fact that it's "fluent" helps a lot when you write a test, because your IDE auto-completion will help you a lot to find what's the assertion you're looking for - something that is not so easy with hamcrest.

I see it as a kind of virtuous cycle: tests are easier to write, easier to read, so you write more tests / better tests.

Would you be ok to give it a try?

If you want to read about it: official site is there
or an article that promotes it nicely :
or an example of file I'd like to push, if you're ok with assertj :) :


hawkular-dev mailing list
hawkular-dev mailing list