Search in sources :

Example 71 with User

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

the class WatcherDAOTest method should_not_get_innactive_watchers_of_a_question.

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

Example 72 with User

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

the class WatcherDAOTest method should_innactivate_watcher.

@Test
public void should_innactivate_watcher() {
    User subscribedWatcher = user("watcher", "watcher@watcher.com");
    session.save(subscribedWatcher);
    Watcher watch = new Watcher(subscribedWatcher);
    watch.inactivate();
    watchers.add(question, watch);
    watchers.ping(question, subscribedWatcher);
    assertTrue(watch.isActive());
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) Watcher(org.mamute.model.watch.Watcher) Test(org.junit.Test)

Example 73 with User

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

the class AttachmentRepositoryTest method should_detach_from_answer.

@Test
public void should_detach_from_answer() {
    final User author = user("question owner", "question@owner.local");
    session.save(author);
    final Attachment attachment = createAttachment("test");
    attachmentRepository.save(attachment);
    final Tag tag = tag("testtag");
    session.save(tag);
    final Question question = question(author, tag);
    session.save(question);
    final Answer answer = answer("answer answer answer answer answer", question, author);
    answer.getAttachments().add(attachment);
    session.save(answer);
    attachmentRepository.delete(answer.getAttachments());
    assertEquals(0, answer.getAttachments().size());
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Attachment(org.mamute.model.Attachment) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) Test(org.junit.Test)

Example 74 with User

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

the class AttachmentRepositoryTest method should_detach_from_question.

@Test
public void should_detach_from_question() {
    final User author = user("question owner", "question@owner.local");
    session.save(author);
    final Attachment attachment = createAttachment("test");
    attachmentRepository.save(attachment);
    final Tag tag = tag("testtag");
    session.save(tag);
    final Question question = question(author, tag);
    question.getAttachments().add(attachment);
    session.save(question);
    attachmentRepository.delete(question.getAttachments());
    assertEquals(0, question.getAttachments().size());
}
Also used : User(org.mamute.model.User) Attachment(org.mamute.model.Attachment) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) Test(org.junit.Test)

Example 75 with User

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

the class AttachmentRepositoryTest method createAttachment.

private Attachment createAttachment(final String content) {
    final User owner = user("attachment owner", "attachment@owner.local");
    session.save(owner);
    final UploadedFile file = new DefaultUploadedFile(IOUtils.toInputStream(content), "hello.txt", "text/plain", content.length());
    final Attachment attachment = new Attachment(file, owner, "127.0.0.1");
    return attachment;
}
Also used : User(org.mamute.model.User) UploadedFile(br.com.caelum.vraptor.observer.upload.UploadedFile) DefaultUploadedFile(br.com.caelum.vraptor.observer.upload.DefaultUploadedFile) DefaultUploadedFile(br.com.caelum.vraptor.observer.upload.DefaultUploadedFile) Attachment(org.mamute.model.Attachment)

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