/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void resetClock() { if (clockNotSetup("laterTime")) return; clock.reset(); }
/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void laterDate(final int years, final int months, final int days) { if (clockNotSetup("laterDate")) return; clock.addDate(years, months, days); }
/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void laterTime(final int hours, final int minutes) { if (clockNotSetup("laterTime")) return; clock.addTime(hours, minutes); }
@Override public String toString() { return "LogonFixture [user: " + getUsername() + ", roles: " + getRoles() + "]"; }
public AuthenticationRequestExploration(LogonFixture logonFixture) { super(logonFixture != null? logonFixture.getUsername(): EXPLORATION_USER); this.logonFixture = logonFixture; }
@Override public List<String> getRoles() { return logonFixture!=null? logonFixture.getRoles(): super.getRoles(); }
/** * Configures the system to use a FixtureClock rather than the in-built system clock. * Can be called multiple times. * * <p> * Must call before any other call to {@link Clock#getInstance()}. * * @throws IllegalStateException if Clock singleton already initialized with some other implementation. */ public synchronized static FixtureClock initialize() { if (!isInitialized() || !(getInstance() instanceof FixtureClock)) { // installs the FixtureClock as the Clock singleton via the Clock's constructor // if was initialized, then will replace. // (if non-replaceable, then superclass will throw exception for us. new FixtureClock(); } return (FixtureClock) getInstance(); }
/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void setTime(final int hour, final int minute) { if (clockNotSetup("setTime")) return; clock.setTime(hour, minute); }
/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void setDate(final int year, final int month, final int day) { if (clockNotSetup("setDate")) return; clock.setDate(year, month, day); }
/** * Sets the clock to epoch, that is midnight, 1 Jan 1970 UTC. * * <p> * This is typically called before either {@link #setDate(int, int, int)} * (so that time is set to midnight) and/or {@link #setTime(int, int)} * (so that date is set to a well known value). */ public void clear() { setupCalendarIfRequired(); calendar.clear(); }
public LogonFixture(final String username, final String... roles) { this(username, asList(roles)); }
public final void install() { installProfiles(); }
/** * Obtain any child fixtures for this fixture. * * @param fixture */ private List<Object> getFixtures(final Object fixture) { if (fixture instanceof CompositeFixture) { CompositeFixture compositeFixture = (CompositeFixture) fixture; return compositeFixture.getFixtures(); } return Collections.emptyList(); }
public AuthenticationRequestLogonFixture(LogonFixture logonFixture) { this(logonFixture.getUsername(), logonFixture.getRoles()); }
/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void earlierDate(final int years, final int months, final int days) { if (clockNotSetup("earlierDate")) return; clock.addDate(-years, -months, -days); }
/** * Will print warning message and do nothing if {@link FixtureClock} could not be {@link FixtureClock#initialize() initialized}. */ public void earlierTime(final int hours, final int minutes) { if (clockNotSetup("earlierDate")) return; clock.addTime(-hours, -minutes); }
/** * Sets the date, but the time portion is left unchanged. * * @see #setTime(int, int) * @see #addDate(int, int, int) */ public void setDate(final int year, final int month, final int day) { setupCalendarIfRequired(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); }
/** * Sets the hours and minutes as specified, and sets the seconds and * milliseconds to zero, but the date portion is left unchanged. * * @see #setDate(int, int, int) * @see #addTime(int, int) */ public void setTime(final int hour, final int min) { setupCalendarIfRequired(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, min); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); }