Using Spring's MockMvc framework, how do I test the value of an attribute of an attribute of my model?
<p>I’m using Spring 3.2.11.RELEASE and JUnit 4.11. I’m using Spring’s <code>org.springframework.test.web.servlet.MockMvc</code> framework to test a controller method.  In one test, I have a model that is populated with the following object:</p>

<pre><code>public class MyObjectForm 
{

    private List&lt;MyObject&gt; myobjects;

    public List&lt;MyObject&gt; getMyObjects() {
        return myobjects;
    }

    public void setMyObjects(List&lt;MyObject&gt; myobjects) {
        this.myobjects = myobjects;
    }

}
</code></pre>

<p>The “MyObject” object in turn has the following field …</p>

<pre><code>public class MyObject
{
    …
    private Boolean myProperty;
</code></pre>

<p>Using the MockMvc framework, how do I check that the first item in the “myobjects” list has an attribute “myProperty” equal to true?  So far I know it goes something like this …</p>

<pre><code>    mockMvc.perform(get(“/my-path/get-page”)
            .param(“param1”, ids))
            .andExpect(status().isOk())
            .andExpect(model().attribute("MyObjectForm", hasProperty("myobjects[0].myProperty”, Matchers.equalTo(true))))
            .andExpect(view().name("assessment/upload"));
</code></pre>

<p>but I’m clueless as to how to test the value of an attribute of an attribute?</p>