001 package org.nakedobjects.applib.fixtures;
002
003 /**
004 * Sole purpose is to switch the current user while object fixtures are being installed.
005 *
006 * <p>
007 * An alternative is to switch user using the {@link AbstractFixture#switchUser(String, String...) switchUser} method.
008 *
009 * <p>
010 * Note that (unlike the otherwise similar {@link DateFixture}) the last user switched to is
011 * <i>not</i> used as the logon fixture. If you want to automatically logon as some user,
012 * use the {@link LogonFixture}.
013 *
014 * @see DateFixture
015 * @see LogonFixture
016 */
017 public class SwitchUserFixture extends AbstractFixture {
018
019 public SwitchUserFixture(final int year, final int month, final int day, final int hour, final int minutes) {
020 this.year = year;
021 this.month = month;
022 this.day = day;
023 this.hour = hour;
024 this.minute = minutes;
025 }
026
027 public SwitchUserFixture(final int year, final int month, final int day) {
028 this(year, month, day, 0, 0);
029 }
030
031 private final int year;
032
033 public int getYear() {
034 return year;
035 }
036 private final int month;
037
038 public int getMonth() {
039 return month;
040 }
041 private final int day;
042
043 public int getDay() {
044 return day;
045 }
046 private final int hour;
047
048 public int getHour() {
049 return hour;
050 }
051 private final int minute;
052
053 public int getMinute() {
054 return minute;
055 }
056
057 @Override
058 public void install() {
059 setDate(year, month, day);
060 setTime(hour, minute);
061 }
062
063 }