We can also use nested tables to directly express domain objects. Again, let's use a very simple example. We want to define the addition of two vectors: !**< test !define vector1 (|''x''|5| |''y''|7| ) !define vector2 (|''x''|10|''y''|20| ) !define vector3 (|''x''|15| |''y''|27| ) **! !|fitlibrary.eg.VectorAddition| |'''check'''|''add''|${vector1}|''to''|${vector2}|${vector3}| Notice that the domain objects are defined as property-value pairs. There can be one or more pairs in a row. Now the method ''addTo()'' is defined as follows: ----{{{ public Vector addTo(Vector v1, Vector v2) { return v1.add(v2); } }}}---- Here's the steps that happen automatically: * Before the method is called, the first two nested tables need to be converted into a ''Vector''. Let's just discuss the first one. As there is an inner table for the object, ''!-FitLibrary-!'' automatically creates an object of class ''Vector'' and uses a ''!-DomainObjectSetUpFixture-!'' to set the properties appropriately from the table. * The method ''addTo()'' is called. * The result of the method is checked against the third nested table. As the result type is an object (of type ''Vector'') and there's a nested table, ''!-FitLibrary-!'' automatically uses a ''!-DomainObjectCheckFixture-!'' to check that the properties in the table and the object correspond. Here's all the Java code: ----{{{public class VectorAddition extends DoFixture { public Vector addTo(Vector v1, Vector v2) { return v1.add(v2); } public static class Vector { private int x, y; public Vector() { // } public Vector(int x, int y) { setX(x); setY(y); } public Vector add(Vector v2) { return new Vector(x+v2.getX(),y+v2.getY()); } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getY() { return y; } public void setY(int y) { this.y = y; } } } }}}---- Notice that: * class ''Vector'' needs a nullary constructor (ie, it's a Java bean) * The only fixture mentioned is the first one * Much of the work happens automatically Let's now consider GeneralNesting.