title: How to UnitTest a method that recieve and return a list of objects
body: <p>My class is as following, it receives a string and using that create an arraylist of objects.
  I am not sure how to test it.</p>
  
  <pre><code> public class Company{
          private String id;
          private String name;
          ....
   }
  
   public List&lt;Company&gt; retrieve(String factories) {
          String[] fac = factories.split(",");
          List&lt;Company&gt; comp;
          comp = new ArrayList&lt;&gt;();
          for (int i = 0; i &lt; fac.length - 1; i++) {
              comp.add(new Company(fac[i], fac[i]));
          }
          return comp;
      }
  </code></pre>
  
  <p><strong>JUnitTest</strong></p>
  
  <pre><code>    @Test
      public void testRetrieve() {
          System.out.println("retrieve");
          String factories = "a,b,c";
          Transact instance = new Transact();
          List&lt;Company&gt; expResult = null; //&lt;&lt;&lt;how to define this?
          List&lt;Company&gt; result = instance.retrieveData(factories);
          assertEquals(expResult, result);
      }
  </code></pre>