org.nakedobjects.applib.fixtures
Class AbstractFixture

java.lang.Object
  extended by org.nakedobjects.applib.AbstractContainedObject
      extended by org.nakedobjects.applib.fixtures.AbstractFixture
All Implemented Interfaces:
CompositeFixture, InstallableFixture, SwitchUserServiceAware
Direct Known Subclasses:
DateFixture, SwitchUserFixture, UserProfileFixture

public abstract class AbstractFixture
extends AbstractContainedObject
implements InstallableFixture, CompositeFixture, SwitchUserServiceAware

Convenience class for creating fixtures.

Most subclasses will simply override install() to setup objects. In addition though fixtures may also:

To automatically logon for the demo/test, use


Constructor Summary
AbstractFixture()
          Assumed to be data fixture.
AbstractFixture(FixtureType fixtureType)
           
 
Method Summary
protected  void addFixture(java.lang.Object fixture)
          Allows the fixture to act as a composite (call within constructor).
 void earlierDate(int years, int months, int days)
          Will print warning message and do nothing if FixtureClock could not be initialized.
 void earlierTime(int hours, int minutes)
          Will print warning message and do nothing if FixtureClock could not be initialized.
 FixtureClock getFixtureClock()
          The Clock singleton, downcast to FixtureClock.
 java.util.List<java.lang.Object> getFixtures()
          Returns an array of any fixtures that have been added.
 FixtureType getType()
          As specified in constructor.
 void install()
          Most subclasses will override this method, but composite fixtures should instead call addFixture(Object) in their constructor.
 void laterDate(int years, int months, int days)
          Will print warning message and do nothing if FixtureClock could not be initialized.
 void laterTime(int hours, int minutes)
          Will print warning message and do nothing if FixtureClock could not be initialized.
 void resetClock()
          Will print warning message and do nothing if FixtureClock could not be initialized.
 void setDate(int year, int month, int day)
          Will print warning message and do nothing if FixtureClock could not be initialized.
 void setService(SwitchUserService fixtureService)
           
 void setTime(int hour, int minute)
          Will print warning message and do nothing if FixtureClock could not be initialized.
protected  void switchUser(java.lang.String username, java.lang.String... roles)
           
 
Methods inherited from class org.nakedobjects.applib.AbstractContainedObject
allInstances, allMatches, allMatches, allMatches, allMatches, firstMatch, firstMatch, firstMatch, firstMatch, getContainer, getUser, informUser, isPersistent, isValid, newTransientInstance, persist, persistentIfNotAlready, raiseError, remove, setContainer, uniqueMatch, uniqueMatch, uniqueMatch, uniqueMatch, validate, warnUser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFixture

public AbstractFixture()
Assumed to be data fixture.


AbstractFixture

public AbstractFixture(FixtureType fixtureType)
Method Detail

getType

public FixtureType getType()
As specified in constructor.

Specified by:
getType in interface InstallableFixture

install

public void install()
Most subclasses will override this method, but composite fixtures should instead call addFixture(Object) in their constructor.

Specified by:
install in interface InstallableFixture

addFixture

protected void addFixture(java.lang.Object fixture)
Allows the fixture to act as a composite (call within constructor).


getFixtures

public java.util.List<java.lang.Object> getFixtures()
Returns an array of any fixtures that have been added.

Specified by:
getFixtures in interface CompositeFixture

getFixtureClock

public FixtureClock getFixtureClock()
The Clock singleton, downcast to FixtureClock.

Will return null if FixtureClock could not be initialized.


earlierDate

public void earlierDate(int years,
                        int months,
                        int days)
Will print warning message and do nothing if FixtureClock could not be initialized.


earlierTime

public void earlierTime(int hours,
                        int minutes)
Will print warning message and do nothing if FixtureClock could not be initialized.


laterDate

public void laterDate(int years,
                      int months,
                      int days)
Will print warning message and do nothing if FixtureClock could not be initialized.


laterTime

public void laterTime(int hours,
                      int minutes)
Will print warning message and do nothing if FixtureClock could not be initialized.


resetClock

public void resetClock()
Will print warning message and do nothing if FixtureClock could not be initialized.


setDate

public void setDate(int year,
                    int month,
                    int day)
Will print warning message and do nothing if FixtureClock could not be initialized.


setTime

public void setTime(int hour,
                    int minute)
Will print warning message and do nothing if FixtureClock could not be initialized.


switchUser

protected void switchUser(java.lang.String username,
                          java.lang.String... roles)

setService

public void setService(SwitchUserService fixtureService)
Specified by:
setService in interface SwitchUserServiceAware


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.