* Test lookup mechanisms.
*/
public void testUserLookups() throws Exception {
UserManager mgr = RollerFactory.getRoller().getUserManager();
UserData user = null;
// add test user
UserData testUser = TestUtils.setupUser("userTestUser");
TestUtils.endSession(true);
// lookup by username
user = mgr.getUserByUsername(testUser.getUserName());
assertNotNull(user);
assertEquals(testUser.getUserName(), user.getUserName());
// lookup by id
String id = user.getId();
user = null;
user = mgr.getUser(id);
assertNotNull(user);
assertEquals(testUser.getUserName(), user.getUserName());
// lookup by UserName (part)
user = null;
List users1 = mgr.getUsersStartingWith(testUser.getUserName().substring(0, 3), 0, 1, Boolean.TRUE);
assertEquals(1, users1.size());
user = (UserData) users1.get(0);
assertNotNull(user);
assertEquals(testUser.getUserName(), user.getUserName());
// lookup by Email (part)
user = null;
List users2 = mgr.getUsersStartingWith(testUser.getEmailAddress().substring(0, 3), 0, 1, Boolean.TRUE);
assertEquals(1, users2.size());
user = (UserData) users2.get(0);
assertNotNull(user);
assertEquals(testUser.getUserName(), user.getUserName());
// make sure disable users are not returned
user.setEnabled(Boolean.FALSE);
mgr.saveUser(user);
user = null;
user = mgr.getUserByUsername(testUser.getUserName());
assertNull(user);
// remove test user
TestUtils.teardownUser(testUser.getId());
TestUtils.endSession(true);
}