Package at.fhj.itm.model

Examples of at.fhj.itm.model.User


   * @throws Exception
   */
  @Before
  public void setUp() throws Exception {
        mockLocation = new Location(8605, "Kapfenberg");
    mockUser = new User("Hannes", "Lauser", "hlauser", "password", "lauser@aon.at", "+436641234567", this.mockLocation, null, "");
    mockUserDao = EasyMock.createMock(UserDAO.class);
    mockDataSource = EasyMock.createMock(DataSource.class);
    mockConnection = EasyMock.createMock(Connection.class);
    mockJsfUtil = EasyMock.createMock(JsfUtil.class);
    mockRandUtil = EasyMock.createMock(RandomUtil.class);
View Full Code Here


    replayMocks();

    // Do Test:
    ServiceUser serviceUser = new ServiceUserImpl(mockUserDao,
        mockDataSource, mockJsfUtil, mockRandUtil, mockMailUtil);
    User user = serviceUser.doLogin(email, password);

    // Verify:
    long now = System.currentTimeMillis();
    long actualTime = user.getLastLoginDate().getTime();
    // the time set was prior now
    Assert.assertTrue(actualTime <= now);
    // the time set must not be older than 5 seconds
    Assert.assertTrue(actualTime >= now - 5000);
    verifyMocks();
View Full Code Here

    replayMocks();

    // Do Test:
    ServiceUser serviceUser = new ServiceUserImpl(mockUserDao,
        mockDataSource, mockJsfUtil, mockRandUtil, mockMailUtil);
    User nullUser = serviceUser.doLogin(email, password);

    // Verify:
    Assert.assertNull(nullUser);
    verifyMocks();
  }
View Full Code Here

  private Location mockLocation;

  @Before
  public void setUp() {
        this.mockLocation = new Location(8605, "Kapfenberg");
    this.mockUser = new User("Hannes", "Lauser", "hlauser", "halauser", "lauser@aon.at", "+436641234567", this.mockLocation, null, "");
    mockServiceUser = EasyMock.createMock(ServiceUser.class);
    mockJsfUtil = EasyMock.createMock(JsfUtil.class);

    ServiceAssembler serviceAssembler = new ServiceAssembler() {
View Full Code Here

     */
    @Before
    public void setUp() throws Exception
    {
  mockLocation = new Location(8605, "Kapfenberg");
  mockUser = new User("Hannes", "Lauser", "hlauser", "password",
    "lauser@aon.at", "+436641234567", this.mockLocation, null, "");
  mockUserDao = EasyMock.createMock(UserDAO.class);
  mockDataSource = EasyMock.createMock(DataSource.class);
  mockConnection = EasyMock.createMock(Connection.class);
  mockJsfUtil = EasyMock.createMock(JsfUtil.class);
View Full Code Here

   */
  @Override
  public void insertTrip(Date departure, int seats, Location fromLocation,
      Location toLocation, Location... stops) throws ServiceException {

    User user = jsfUtil.getLoggedInUser();
    if (user == null)
      throw new UnauthorizedAccessException("No user logged in!");
    Trip newTrip;
    try {
      begin();
View Full Code Here

    String comment = set.getString("comment");
    boolean active = set.getBoolean("active");

    Location fromLocation = this.locationDAO.getByID(from_location,connection);
    Location toLocation = this.locationDAO.getByID(to_location, connection);
    User user = this.userDAO.getByID(user_id, connection);

    return new Waypoint(id, fromLocation, toLocation, user, comment, active);
  }
View Full Code Here

   *            the LoginListener to add
   */
  @Override
  public void addLoginListener(LoginListener listener) {
    loginListeners.add(listener);
    User user = getLoggedInUser();
    if (user != null)
      listener.userLoggedIn(user);
  }
View Full Code Here

   * @return the User that matches the passed values, or null if non was found
   * @throws ServiceException if a database error occured
   */
  @Override
  public User doLogin(String email, String password) {
    User user = null;
    try {
      begin();
      user = getUserDAO().userValid(email, password, getConnection());
      commit();
    } catch (DAOException e) {
      throw new ServiceException("Error in retrieving user with email and password", e);
    } catch (SQLException e) {
      throw new ServiceException("Error in retrieving user with email and password", e);
    } finally {
      closeConnection();
    }
    if (user == null)
      return null;

    user.setLastLoginDate(new Date());
    try {
      updateUser(user, "s last login date");
    } catch (ServiceException e) {
      logger.error(
          "Failed to set lastlogindate for user " + user.getId(), e);
    }
    jsfUtil.userLoggedIn(user);
    return user;
  }
View Full Code Here

   */
  public boolean doRegistration(final String firstName, final String lastName, final String username,
    final String password, final String email, final String phone, final int zip, final String city)
  {
      Location loc = new Location(zip, city);
      User user = new User(-1, firstName, lastName, username, password, email, phone, loc,
        new java.util.Date(), this.randUtil.getRandSessionID());
      try
      {
    boolean updateSuccess = this.updateUser(user, "'s registration data!");
        this.mailUtil.sendRegConfirmation(email, username);
View Full Code Here

TOP

Related Classes of at.fhj.itm.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.