public class SearchTestITCase extends AbstractTest {
@Test
public void searchUser() throws InvalidSearchConditionException {
// LIKE
AttributeCond fullnameLeafCond1 = new AttributeCond(AttributeCond.Type.LIKE);
fullnameLeafCond1.setSchema("fullname");
fullnameLeafCond1.setExpression("%o%");
AttributeCond fullnameLeafCond2 = new AttributeCond(AttributeCond.Type.LIKE);
fullnameLeafCond2.setSchema("fullname");
fullnameLeafCond2.setExpression("%i%");
NodeCond searchCondition = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond.getLeafCond(
fullnameLeafCond2));
assertTrue(searchCondition.isValid());
List<UserTO> matchedUsers = userService.search(searchCondition);
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());
for (UserTO user : matchedUsers) {
assertNotNull(user);
}
// ISNULL
AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNULL);
isNullCond.setSchema("loginDate");
searchCondition = NodeCond.getLeafCond(isNullCond);
matchedUsers = userService.search(searchCondition);
assertNotNull(matchedUsers);
assertFalse(matchedUsers.isEmpty());