Package org.onebusaway.users.model

Examples of org.onebusaway.users.model.User


  @Test
  public void testGetNumberOfUsers() {

    assertEquals(0, _dao.getNumberOfUsers());

    User userA = new User();
    userA.setCreationTime(new Date());
    userA.setProperties(new UserPropertiesV1());

    _dao.saveOrUpdateUser(userA);

    assertEquals(1, _dao.getNumberOfUsers());

    User userB = new User();
    userB.setCreationTime(new Date());
    userB.setProperties(new UserPropertiesV1());

    _dao.saveOrUpdateUser(userB);

    assertEquals(2, _dao.getNumberOfUsers());
  }
View Full Code Here


    c.add(Calendar.MONTH, -1);
    Date threeMonth = c.getTime();

    assertEquals(0, _dao.getNumberOfStaleUsers(oneMonth));

    User userA = new User();
    userA.setCreationTime(new Date());
    userA.setLastAccessTime(twoMonth);
    userA.setProperties(new UserPropertiesV2());

    _dao.saveOrUpdateUser(userA);

    assertEquals(1, _dao.getNumberOfStaleUsers(oneMonth));
    assertEquals(0, _dao.getNumberOfStaleUsers(twoMonth));
    assertEquals(0, _dao.getNumberOfStaleUsers(threeMonth));

    User userB = new User();
    userB.setCreationTime(new Date());
    userB.setLastAccessTime(threeMonth);
    userB.setProperties(new UserPropertiesV2());

    _dao.saveOrUpdateUser(userB);

    assertEquals(2, _dao.getNumberOfStaleUsers(oneMonth));
    assertEquals(1, _dao.getNumberOfStaleUsers(twoMonth));
View Full Code Here

    Set<Integer> ids = new HashSet<Integer>();

    for (int i = 0; i < 100; i++) {

      User userA = new User();
      userA.setCreationTime(new Date());
      userA.setProperties(new UserPropertiesV1());

      _dao.saveOrUpdateUser(userA);

      ids.add(userA.getId());
    }

    int n = _dao.getNumberOfUsers();
    assertEquals(100, n);
View Full Code Here

    UserRole userRole = new UserRole("user");

    _dao.saveOrUpdateUserRole(userRole);

    User user = new User();
    user.setCreationTime(new Date());
    user.setProperties(new UserPropertiesV2());
    user.getRoles().add(userRole);

    UserIndexKey key = new UserIndexKey("phone", "2065551234");

    UserIndex index = new UserIndex();
    index.setId(key);
    index.setUser(user);
    user.getUserIndices().add(index);

    _dao.saveOrUpdateUser(user);

    assertEquals(1, _dao.getNumberOfUsers());
View Full Code Here

  }

  @Test
  public void testTransitionUserIndex() {

    User userA = new User();
    userA.setCreationTime(new Date());
    userA.setProperties(new UserPropertiesV2());

    UserIndex index = new UserIndex();
    index.setId(new UserIndexKey("test", "A"));
    index.setUser(userA);
    userA.getUserIndices().add(index);

    _dao.saveOrUpdateUser(userA);

    User userB = new User();
    userB.setCreationTime(new Date());
    userB.setProperties(new UserPropertiesV2());

    _dao.saveOrUpdateUser(userB);

    assertEquals(1, _dao.getUserForId(userA.getId()).getUserIndices().size());
    assertEquals(0, _dao.getUserForId(userB.getId()).getUserIndices().size());

    index.setUser(userB);
    userA.getUserIndices().remove(index);
    userB.getUserIndices().add(index);

    _dao.saveOrUpdateUsers(userA, userB);

    assertEquals(0, _dao.getUserForId(userA.getId()).getUserIndices().size());
    assertEquals(1, _dao.getUserForId(userB.getId()).getUserIndices().size());
  }
View Full Code Here

  }

  @Test
  public void testRegisterPhoneNumber() {

    User user = createUser(1234);

    double total = 0;
    int n = 100;

    for (int i = 0; i < n; i++) {
View Full Code Here

  }

  @Test
  public void testCompletePhoneNumberRegistration() {

    User userA = createUser(1234);

    UserIndexKey key = new UserIndexKey(UserIndexTypes.PHONE_NUMBER,
        "12065551234");

    UserDao userDao = Mockito.mock(UserDao.class);
    _service.setUserDao(userDao);

    Mockito.when(userDao.getUserForId(1234)).thenReturn(userA);

    UserIndex migratedIndex = new UserIndex();
    migratedIndex.setId(key);
    migratedIndex.setUser(userA);
    migratedIndex.setCredentials("");
    Mockito.when(userDao.getUserIndexForId(key)).thenReturn(migratedIndex);

    UserIndexRegistrationService registrationService = Mockito.mock(UserIndexRegistrationService.class);
    _service.setUserIndexRegistrationService(registrationService);

    UserRegistration registration = new UserRegistration(1234, "5555");
    Mockito.when(registrationService.getRegistrationForUserIndexKey(key)).thenReturn(
        registration);

    UserPropertiesService userPropertiesService = Mockito.mock(UserPropertiesService.class);
    _service.setUserPropertiesService(userPropertiesService);

    User userB = createUser(1235);
    UserIndex index = createUserIndex(key.getType(), key.getValue(), userB);

    UserIndex updated = _service.completePhoneNumberRegistration(index, "5554");
    assertTrue(updated == null);
View Full Code Here

   
    _service.stop();
  }

  private User createUser(int userId) {
    User user = new User();
    user.setId(userId);
    user.setCreationTime(new Date());
    return user;
  }
View Full Code Here

  }

  @Test
  public void testAddStopBookmark() throws BookmarkException {

    User user = createUser();

    _service.addStopBookmark(user, "bookmkark", Arrays.asList("1"),
        new RouteFilter());

    List<String> bookmarks = getProperties(user).getBookmarkedStopIds();
View Full Code Here

  }

  @Test
  public void testMergeUsers01() throws BookmarkException {

    User userA = createUser();

    _service.setLastSelectedStopIds(userA, Arrays.asList("A"));
    _service.addStopBookmark(userA, "bookmark a", Arrays.asList("A", "C"),
        new RouteFilter());

    User userB = createUser();

    _service.setDefaultLocation(userB, "here", 47.0, -122.0);
    _service.addStopBookmark(userB, "bookmark b", Arrays.asList("C", "B"),
        new RouteFilter());
    _service.mergeProperties(userA, userB);
View Full Code Here

TOP

Related Classes of org.onebusaway.users.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.