### Question:
UserFactoryImpl extends RecordFactoryImpl<User, UserImpl> implements UserFactory { public List<User> searchUsers(String theFirstName, String theLastName, Integer olderThan, Integer youngerThan, AnnuData.Gender gender, String theCity, String theCountry, int skip, int count) { final StringBuilder theCondition = new StringBuilder(" user_id = annu_user and annu_confirm = 1 AND ( (annu_prenom IS NOT NULL and annu_prenom != '') OR (annu_nom IS NOT NULL and annu_nom != '' ) ) "); final String[] joinTables = { "annu" }; if (theFirstName != null) { theCondition.append(" and annu_prenom like '" + theFirstName + "%' "); } if (theLastName != null) { theCondition.append(" and annu_nom like '" + theLastName + "%' "); } final CCalendar now = new CCalendar(true); if (olderThan != null) { now.add(Calendar.YEAR, -olderThan); theCondition.append(" and annu_datebirth < '" + now.getYear() + "-" + now.getMonth() + "-" + now.getDay() + "' "); now.add(Calendar.YEAR, olderThan); } if (youngerThan != null) { now.add(Calendar.YEAR, -youngerThan); theCondition.append(" and annu_datebirth > '" + now.getYear() + "-" + now.getMonth() + "-" + now.getDay() + "'"); } if (gender != null) { if (gender == AnnuData.Gender.UNKNOWN) { theCondition.append(" and annu_sexe is null "); } else { theCondition.append(" and annu_sexe = '" + gender.getCodeAnnu() + "' "); } } if (theCity != null) { theCondition.append(" and annu_city = '" + theCity + "' "); } if (theCountry != null) { theCondition.append(" and annu_country = '" + theCountry + "' "); } return findAll(joinTables, theCondition.toString(), null, "user_email", skip, count); } UserFactoryImpl(); User findByEmail(String email); User createNewUser(String inEmail, String inPassword, Lang inLang, String inCountry, String inFirstName, String inLastName, long inTimeZone); List<User> searchUsers(String theFirstName, String theLastName, Integer olderThan, Integer youngerThan, AnnuData.Gender gender, String theCity, String theCountry, int skip, int count); List<User> findAll(int theIndex);  }### Answer:
@Test public void searchUsersTest() { final VObject myVObject = Factories.VOBJECT.find(16952); Assert.assertNotNull(myVObject); final User myUser = Factories.USER.find(103); Assert.assertNotNull(myUser); Assert.assertTrue(myVObject.getPreferences().isVisible()); final List<User> Users = Factories.USER.searchUsers("Janek", "Kowalski", 0, 99, AnnuData.Gender.MALE, "Varsovie", "PL", 0, 10); Assert.assertEquals(1, Users.size()); final Long id1 = Users.get(0).getId(); Assert.assertTrue(id1.equals(103L)); Assert.assertEquals("Janek", Users.get(0).getAnnu().getAnnu_prenom()); final VObject myVObject2 = Factories.VOBJECT.find(16953); Assert.assertNotNull(myVObject2); final User myUser2 = Factories.USER.find(103); Assert.assertNotNull(myUser2); Assert.assertTrue(!(myVObject2.getPreferences().isVisible())); final List<User> Users2 = Factories.USER.searchUsers("Izabella", "Czartoryska", 0, 99, AnnuData.Gender.FEMALE, "Paris", "FR", 0, 10); Assert.assertEquals(1, Users2.size()); }