title: Asserting properties on list elements with assertJ
body: <p>I have a working hamcrest assertion:</p>
  
  <pre><code>assertThat(mylist, contains(
    containsString("15"), 
    containsString("217")));
  </code></pre>
  
  <p>The intended behavior is:</p>
  
  <ul>
  <li><code>mylist == asList("Abcd15", "217aB")</code> => success</li>
  <li><code>myList == asList("Abcd15", "218")</code> => failure</li>
  </ul>
  
  <p>How can I migrate this expression to assertJ. Of course there exist naive solutions, like asserting on the first and second value, like this:</p>
  
  <pre><code>assertThat(mylist.get(0)).contains("15");
  assertThat(mylist.get(1)).contains("217");
  </code></pre>
  
  <p>But these are assertions on the list elements, not on the list. Trying asserts on the list restricts me to very generic functions. So maybe it could be only resolved with a custom assertion, something like the following would be fine:</p>
  
  <pre><code>assertThat(mylist).elements()
    .next().contains("15")
    .next().contains("217")
  </code></pre>
  
  <p>But before I write a custom assert, I would be interested in how others would solve this problem?  </p>
  
  <p>Edit: One additional non-functional requirement is, that the test should be easily extendible by additional contstraints. In Hamcrest it is quite easy to express additional constraints, e.g. </p>
  
  <pre><code>assertThat(mylist, contains(
    emptyString(),                                     //additional element
    allOf(containsString("08"), containsString("15")), //extended constraint
    containsString("217")));                           // unchanged
  </code></pre>
  
  <p>Tests being dependent on the list index will have to be renumbered for this example, Tests using a custom condition will have to rewrite the complete condition (note that the constraints in <code>allOf</code> are not restricted to substring checks).</p>