List being populated by null records - junit test failing
<p>I've been banging my head against the wall for a while with this one - </p>

<p>I have a method to create a list of objects of another class:</p>

<pre><code>    public List &lt;PayrollRecord&gt; processPayroll() {
    List&lt;PayrollRecord&gt; payroll = new ArrayList&lt;PayrollRecord&gt;();
    for (Employee employee : staff) {
        PayrollRecord payRec = new PayrollRecord(employee.getName(), employee.calculatePay());
        payroll.add(payRec);
    }
    return payroll;
}
</code></pre>

<p>staff is a list of Employee class objects that can be added to the list by this method:</p>

<pre><code>    public void addEmployee(Employee employee) {
    staff.add(employee);
}
</code></pre>

<p>Employee is also an interface implemented by a few other classes - Manager, SalesAssociate and StoreEmployee. (Can you tell I'm trying to get through an assignment yet? Maybe some of you are familiar). </p>

<p>The PayrollRecord class looks like this:</p>

<pre><code>    package my.package.ext;

public class PayrollRecord {

    private String employeeName;
    private double currentPay;

    public PayrollRecord(String employeeName, double currentPay) {

    }

    public double getCurrentPay() {


        return this.currentPay;
        }

        public String getEmployeeName() {
            return this.employeeName;
        }

    }
</code></pre>

<p>So within a test class, I should be able to create some variables for employee info, add some employees to staff, and then run the processPayroll method and do some asserts on it. My test class currently looks like this (and will need several more asserts. I'm not going to bother adding those until I can get this basic problem figured out):</p>

<pre><code>    @Test
public void testPayroll() {
    List&lt;PayrollRecord&gt; list = store.processPayroll();
    assertEquals(managerTestPay, list.get(0).getCurrentPay(), 0);
}
</code></pre>

<p>Based on the number of employees I have added elsewhere in the test class, there should be five. I can set list.get out of bounds and verify that there are indeed 5. However the problem is that all 5 records are null and 0.0. I should have a name and pay for each employee record. However the assertion error comes back showing me what I expected, but that the actual value is 0.0 (or null when I try list.get(0).getName()).</p>

<p>Thank you in advance for your help and wisdom.</p>
