leaf3DState.setEndPoint1(leaf3DState.getInitialEndPoint1());
leaf3DState.setEndPoint2(leaf3DState.getInitialEndPoint2());
Point3dState initialEndPoint1 = leaf3DState.getInitialEndPoint1();
Point3dState initialEndPoint2 = leaf3DState.getInitialEndPoint2();
BasicTreeLeaf3D leaf3D = new BasicTreeLeaf3D(mockUniverse3D, leaf3DState, mockLeaf);
Shape3D leafShape = (Shape3D) leaf3D.getBranchGroup().getChild(0);
Point3d geomEndPoint1 = new Point3d();
Point3d geomEndPoint2 = new Point3d();
assertFalse(leaf3D.isMaxSizeReached());
leaf3D.increaseSize();
// test state
Point3d endPoint1 = leaf3D.getState().getEndPoint1().toPointValue();
Point3d expectedEndPoint1 = new Point3d(initialEndPoint1.getX() * 2, initialEndPoint1.getY() * 2,
initialEndPoint1.getZ() * 2);
PointTestHelper.assertPointEquals(expectedEndPoint1, endPoint1);
Point3d endPoint2 = leaf3D.getState().getEndPoint2().toPointValue();
Point3d expectedEndPoint2 = new Point3d(initialEndPoint2.getX() * 2, initialEndPoint2.getY() * 2,
initialEndPoint2.getZ() * 2);
PointTestHelper.assertPointEquals(expectedEndPoint2, endPoint2);
// test geometry
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint1);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint1);
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint2);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint2);
leaf3D.increaseSize();
// test state
endPoint1 = leaf3D.getState().getEndPoint1().toPointValue();
expectedEndPoint1 = new Point3d(initialEndPoint1.getX() * 3, initialEndPoint1.getY() * 3, initialEndPoint1
.getZ() * 3);
PointTestHelper.assertPointEquals(expectedEndPoint1, endPoint1);
endPoint2 = leaf3D.getState().getEndPoint2().toPointValue();
expectedEndPoint2 = new Point3d(initialEndPoint2.getX() * 3, initialEndPoint2.getY() * 3, initialEndPoint2
.getZ() * 3);
PointTestHelper.assertPointEquals(expectedEndPoint2, endPoint2);
// test geometry
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint1);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint1);
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint2);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint2);
// increase up to the max size
leaf3D.increaseSize();
leaf3D.increaseSize();
leaf3D.increaseSize();
leaf3D.increaseSize();
leaf3D.increaseSize();
leaf3D.increaseSize();
leaf3D.increaseSize();
// test state
assertTrue(leaf3D.isMaxSizeReached());
endPoint1 = leaf3D.getState().getEndPoint1().toPointValue();
expectedEndPoint1 = new Point3d(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10, initialEndPoint1
.getZ() * 10);
PointTestHelper.assertPointEquals(expectedEndPoint1, endPoint1);
endPoint2 = leaf3D.getState().getEndPoint2().toPointValue();
expectedEndPoint2 = new Point3d(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10, initialEndPoint2
.getZ() * 10);
PointTestHelper.assertPointEquals(expectedEndPoint2, endPoint2);
// test geometry
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint1);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint1);
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint2);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint2);
// nothing changes if we increase the leaf again
leaf3D.increaseSize();
// test state
assertTrue(leaf3D.isMaxSizeReached());
endPoint1 = leaf3D.getState().getEndPoint1().toPointValue();
expectedEndPoint1 = new Point3d(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10, initialEndPoint1
.getZ() * 10);
PointTestHelper.assertPointEquals(expectedEndPoint1, endPoint1);
endPoint2 = leaf3D.getState().getEndPoint2().toPointValue();
expectedEndPoint2 = new Point3d(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10, initialEndPoint2
.getZ() * 10);
PointTestHelper.assertPointEquals(expectedEndPoint2, endPoint2);
// test geometry
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint1);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint1);
((TriangleArray) leafShape.getGeometry()).getCoordinate(1, geomEndPoint2);
PointTestHelper.assertPointEquals(leaf3D.getState().getEndPoint1().toPointValue(), geomEndPoint2);
}