title: How can I recursively verify for nulls while navigating down an object?
body: <p>I'm using Powermock Mockito  1.5.1 with Java 1.7.</p>
  
  <p>On testing a web service method, I need to check a certain value with in the response object. The problem is, this value is a few layers deep and I'll need to do <code>null</code> check on all its parent values before getting to the actual value in question. </p>
  
  <p>Currently, this is what I'm doing:</p>
  
  <pre><code>response = service.method1();
  assertThat(response, notNullValue());
  assertThat(response.getA(), notNullValue());
  assertThat(response.getA().getB(), notNullValue());
  assertThat(response.getA().getB().getC(), notNullValue());
  assertThat(response.getA().getB().getC().getD(), notNullValue());
  assertThat(response.getA().getB().getC().getD().size(), is(1));
  assertThat(response.getA().getB().getC().getD().get(0), notNullValue());
  assertThat(response.getA().getB().getC().getD().get(0).value(), is("ABC"));
  </code></pre>
  
  <p>Is there a way to save out on all the <code>notNullValue()</code> validation code, but have it automatically happen. So can be something like:</p>
  
  <pre><code>assertThat(response.getA().getB().getC().getD(), *recursivelyNotNull()*);
  assertThat(response.getA().getB().getC().getD().size(), is(1));
  assertThat(response.getA().getB().getC().getD().get(0).value(), is("ABC"));
  </code></pre>