How to assert that a list has at least n items which are greater than x (with hamcrest in junit)
<p>I could with following code check if a list has a item, which greater than 30.</p>

<pre><code>//Using Hamcrest
List&lt;Integer&gt; ints= Arrays.asList(22,33,44,55);
assertThat(ints,hasItem(greaterThan(30)));
</code></pre>

<p>But how could I assert if a list has at least 2 items, which are greater than 30?</p>

<p>With <code>AssertJ</code>, there is a solution I know. But I have no idea how to realize that with <code>Hamcrest</code>.</p>

<pre><code>//Using AssertJ
List&lt;Integer&gt; ints= Arrays.asList(22,33,44,55);
Condition&lt;Integer&gt; greaterThanCondition = new Condition&lt;Integer&gt;("greater") {
        @Override
        public boolean matches (Integer i){
            return i&gt;30;
        }
    } ;
assertThat(ints).haveatLeast(2,greaterThanCondition);
</code></pre>