Search in sources :

Example 21 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserDAOTest method should_search_by_email_and_legacy_password_and_update_password.

@Test
public void should_search_by_email_and_legacy_password_and_update_password() {
    String password = "654321";
    User gui = user("Guilherme Sonar", "gui@email.com.br");
    LoginMethod brutalLogin = LoginMethod.brutalLogin(gui, "gui@email.com.br", password);
    new Mirror().on(brutalLogin).set().field("token").withValue(MD5.crypt(password));
    gui.add(brutalLogin);
    users.save(gui);
    session.save(brutalLogin);
    assertNull(users.findByMailAndPassword("gui@email.com.br", password));
    User found = users.findByMailAndLegacyPasswordAndUpdatePassword("gui@email.com.br", password);
    assertEquals(gui, found);
    assertEquals(Digester.encrypt(password), found.getBrutalLogin().getToken());
    assertNull(users.findByMailAndPassword("joao.silveira@email.com.br", password));
    assertNull(users.findByMailAndPassword("gui@email.com.br", "123456"));
}
Also used : User(org.mamute.model.User) LoginMethod(org.mamute.model.LoginMethod) Mirror(net.vidageek.mirror.dsl.Mirror) Test(org.junit.Test)

Example 22 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserDAOTest method should_search_by_email_and_password.

@Test
public void should_search_by_email_and_password() {
    User gui = user("Guilherme Sonar", "gui@email.com.br");
    LoginMethod brutalLogin = LoginMethod.brutalLogin(gui, "gui@email.com.br", "654321");
    gui.add(brutalLogin);
    users.save(gui);
    session.save(brutalLogin);
    assertEquals(gui, users.findByMailAndPassword("gui@email.com.br", "654321"));
    assertNull(users.findByMailAndPassword("gui@email.com.br", "1234567"));
    assertNull(users.findByMailAndPassword("joao.silveira@email.com.br", "654321"));
}
Also used : User(org.mamute.model.User) LoginMethod(org.mamute.model.LoginMethod) Test(org.junit.Test)

Example 23 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserDAOTest method saveUser.

private User saveUser(String name, String email) {
    User user = user(name, email);
    LoginMethod facebookLogin = LoginMethod.facebookLogin(user, user.getEmail(), "1234");
    user.add(facebookLogin);
    session.save(user);
    session.save(facebookLogin);
    return user;
}
Also used : User(org.mamute.model.User) LoginMethod(org.mamute.model.LoginMethod)

Example 24 with User

use of org.mamute.model.User in project mamute by caelum.

the class WatcherDAOTest method should_get_subscribed_users_of_a_question.

@Test
public void should_get_subscribed_users_of_a_question() {
    User subscribedWatcher = user("watcher", "watcher@watcher.com");
    session.save(subscribedWatcher);
    watchers.add(question, new Watcher(subscribedWatcher));
    assertThat(watchers.of(question), not(empty()));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) Watcher(org.mamute.model.watch.Watcher) Test(org.junit.Test)

Example 25 with User

use of org.mamute.model.User in project mamute by caelum.

the class WatcherDAOTest method set_up.

@Before
public void set_up() {
    User leo = user("Leonardo", "leo@leo.com");
    session.save(leo);
    Tag java = tag("java");
    session.save(java);
    question = question(leo, java);
    session.save(question);
    watchers = new WatcherDAO(session, new InvisibleForUsersRule(new LoggedUser(leo, null)));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) WatcherDAO(org.mamute.dao.WatcherDAO) LoggedUser(org.mamute.model.LoggedUser) Tag(org.mamute.model.Tag) InvisibleForUsersRule(org.mamute.dao.InvisibleForUsersRule) Before(org.junit.Before)

Aggregations

User (org.mamute.model.User)97 Test (org.junit.Test)56 Question (org.mamute.model.Question)28 LoggedUser (org.mamute.model.LoggedUser)25 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)9 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)9 Answer (org.mamute.model.Answer)9 LoginMethod (org.mamute.model.LoginMethod)9 Post (br.com.caelum.vraptor.Post)7 Before (org.junit.Before)7 Tag (org.mamute.model.Tag)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Email (org.apache.commons.mail.Email)5 UserPersonalInfo (org.mamute.dto.UserPersonalInfo)5 ReputationEvent (org.mamute.model.ReputationEvent)5 ArrayList (java.util.ArrayList)4 Watcher (org.mamute.model.watch.Watcher)4 DateTime (org.joda.time.DateTime)3 Elements (org.jsoup.select.Elements)3 DaoManager (org.mamute.integration.util.DaoManager)3