Search code examples
javafitnesse

Using ArrayFixture with a list of objects containing nested non-primitive objects


I am using ArrayFixture to verify lists of non-primitive objects that contain other non-primitives. I have a simple setup like this:

public class Car {
  public String getName();
  public Details getDetails();
  ...
}

public class Details {
  public String getMake();
  ...
}

With ArrayFixture, all you need to do is call setActualCollection(yourListOfObjects) in the constructor of the class.

How do I reference the elements in the object's non-primitive variables? This is how my Fitnesse test looks:

|Verify Cars|
|name   | details Make | ... |
|Taurus | Ford         | ... |
|...    | ...          | ... | 

I have been able to easily use the ArrayFixture when the object in the list contains primitive objects, but I haven't found any documentation on how to handle non-primitive elements.


Solution

  • ArrayFixture uses the column headings as method names to execute on the objects in your collection, so you'd need methods on Car to access the details you want to check:

    public class Car {
      public String getMake() { return getDetails().getMake(); }
      ...
    }