Assert LinkedHashMap element in jUnit test So I have some test, maybe the given side of that test is not so important to catch the point of my confusion. I wrote 

List&lt;LinkedHashMap&gt; failedEvents = ...
//...
assertEquals(failedEvents.size(),1 );
assertTrue(failedEvents.stream().allMatch(x -&gt; x.get("eventId").equals("EVENT3")));


and in the result my code review said I should avoid stream on single element. But I think is clear and readable to show that all elements pass specific matching rule.
Also I though about assertThat, but I ended with much bigger and more complicated piece of code.
One cannot say anything against

assertEquals(failedEvents.size(), 1);
assertEquals(failedEvents.get(0).get("eventId"), "EVENT3");


It is even shorter and more clear.

However your argument of an invariant on the entire collection is valid, though
you should have said so. Better would be to make a reusable assertion:

assertEquals(failedEvents.size(), 1);
assertTrue(failedEventsHaveId(failedEvents, "EVENT3"));

/**
 * Invariant on the failedEvent: the eventId remaining one.
 */
private static boolean failedEventsHaveId(..., String eventId) {
    return ...;
}


If not reusable, then the code is unnecessarily "nice."