title: AssertJ: For a Pojo how to check each nested Property/Field in one chained sentence
body: <p>Having a <code>POJO</code> such as:</p>
  <pre><code>public class ClientWebRequest {
  
      private URI uri;
      private HttpMethod httpMethod;
  
      private final Header header;
      private final Body body;
  
  
      public ClientWebRequest(){
          header = new Header();
          body = new Body();
      }
  
      //getters and setters
  }
  </code></pre>
  <p>About <code>JUnit</code> working with <code>AssertJ</code> the following is valid, the <code>@Test</code> method pass:</p>
  <pre><code>assertThat(clientWebRequest).isNotNull();
  assertThat(clientWebRequest.getHeader()).isNotNull();
  assertThat(clientWebRequest.getHeader().getAccept()).isNotNull();
  assertThat(clientWebRequest.getHeader().getAcceptLanguage()).isNull();
  assertThat(clientWebRequest.getHeader().getContentType()).isNull();
  assertThat(clientWebRequest.getBody()).isNotNull();
  assertThat(clientWebRequest.getBody().getBody()).isNull();
  </code></pre>
  <p>Even when it works, is verbose in some way.</p>
  <p>I want to know <em>if is possible</em> rewrite all the above in just one sentence, checking each nested property/field. Thus I have tried for example the following:</p>
  <pre><code>assertThat(clientWebRequest.getHeader()).isNotNull()
          .hasFieldOrProperty(&quot;accept&quot;).isNotNull()
          .hasFieldOrProperty(&quot;acceptLanguage&quot;).isNull();
  </code></pre>
  <p>But fails with the following error message:</p>
  <pre><code>org.junit.ComparisonFailure: expected:&lt;null&gt; 
  but was:&lt;Header [accept=[application/json;charset=UTF-8], acceptLanguage=null, contentType=null]&gt;
          at
  </code></pre>
  <p>My main goal is workaround with <code>isNotNull</code> and <code>isNull</code> for each property/field of the <code>POJO</code></p>
  <p><strong>Alpha</strong>: Thanks to <code>Joel</code>'s suggestion the following works now:</p>
  <pre><code>assertThat(clientWebRequest).isNotNull()
                              .extracting(&quot;header.accept&quot;)
                              .doesNotContainNull();
  
  assertThat(clientWebRequest).isNotNull()
          .extracting(&quot;header.acceptLanguage&quot;, &quot;header.contentType&quot;)
         .containsNull();
  </code></pre>
  <p>From above (two blocks) If I try the following (one block):</p>
  <pre><code>assertThat(clientWebRequest).isNotNull()
                              .extracting(&quot;header.accept&quot;)
                              .doesNotContainNull();
         .extracting(&quot;header.acceptLanguage&quot;, &quot;header.contentType&quot;)
         .containsNull();
  </code></pre>
  <p>It fails. Just curious if is possible apply <em>one</em> block.</p>