title: How to create and assert a Mockito list of custom object?
body: <p>I'm trying to simplify a test case 1st code block to something similar shown in the 2nd code block.
  I have two questions:</p>
  
  <ol>
  <li>Can I mock a list of custom objects?</li>
  <li>Can I assert a mocked list of custom objects with the fields in a returned list of objects?</li>
  </ol>
  
  <p>Is something similar achieveable?</p>
  
  <pre><code>  @Test
      public void testStudentSuccess() {
      Student st = new Student();
          st.setRollNumber("1234");
          st.setFeeAmount("1000");
          List&lt;Student&gt; stList = new ArrayList&lt;Student&gt;();
          stList.add(st);
          Map&lt;String, Object&gt; simpleJdbcCallResult = new HashMap&lt;String, Object&gt;();
          simpleJdbcCallResult.put("X_GET_DATA", stList);
          when(simpleJdbcCall.getSimpleJdbcCall(any(String.class), any(String.class), any(String.class),
                          any(String.class), any(String.class), any(String.class), any(String.class), any(String.class),
                          any(StudentRowMapper.class))).thenReturn(simpleJdbcCallResult);
          List&lt;Student&gt; studentList = opusPackageRepo.getPolicyStudent("123", "123");
          Student student = studentList.get(0);
          assertEquals(student.getRollNumber(), "1234");
          assertEquals(student.getFeeAmount(), "1000");
      }
  </code></pre>
  
  <p>To something like this (see the comments -> //):</p>
  
  <pre><code>@Test
      public void testStudentSuccess() {
          List&lt;Student&gt; stList = Mockito.mock(new ArrayList&lt;Student&gt;()); // 1. IS SOMTHING SIMILAR TO THIS POSSIBLE?
          Map&lt;String, Object&gt; simpleJdbcCallResult = new HashMap&lt;String, Object&gt;();
          simpleJdbcCallResult.put("X_GET_DATA", Mockito.mock(new ArrayList&lt;Student&gt;()));
          when(simpleJdbcCall.getSimpleJdbcCall(any(String.class), any(String.class), any(String.class),
                          any(String.class), any(String.class), any(String.class), any(String.class), any(String.class),
                          any(StudentRowMapper.class))).thenReturn(simpleJdbcCallResult);
          List&lt;Student&gt; studentList = opusPackageRepo.getPolicyStudent("123", "123");
          assertEquals(studentList, stList); // 2. CAN I ASSERT EQUALS A MOCK WITH A RETURNED LIST?
      }
  </code></pre>