public void testFindUsersByQuery() throws Exception
{
createUser("tolik");
uHandler.authenticate("tolik", "pwd");
Query query = new Query();
query.setEmail("email@test");
// try to find user by email
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by name with mask
query = new Query();
query.setUserName("*tolik*");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by name with mask
query = new Query();
query.setUserName("tol*");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by name with mask
query = new Query();
query.setUserName("*lik");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by name explicitly
query = new Query();
query.setUserName("tolik");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by name explicitly, case sensitive search
query = new Query();
query.setUserName("Tolik");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by part of name without mask
query = new Query();
query.setUserName("tol");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
// try to find user by fist and last names, case sensitive search
query = new Query();
query.setFirstName("fiRst");
query.setLastName("lasT");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
if (!"true".equals(skipDateTests))
{
// try to find user by login date
Calendar calc = Calendar.getInstance();
calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);
query = new Query();
query.setFromLoginDate(calc.getTime());
query.setUserName("tolik");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
calc = Calendar.getInstance();
calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
query = new Query();
query.setFromLoginDate(calc.getTime());
assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);
calc = Calendar.getInstance();
calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);
query = new Query();
query.setToLoginDate(calc.getTime());
assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);
calc = Calendar.getInstance();
calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
query = new Query();
query.setToLoginDate(calc.getTime());
query.setUserName("tolik");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
}
createUser("rolik");
createUser("bolik");
createUser("volik");
query = new Query();
query.setUserName("olik");
ListAccess<User> users = uHandler.findUsersByQuery(query);
assertEquals(users.getSize(), 4);