Search in sources :

Example 36 with Question

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

the class QuestionTest method should_not_be_touched_when_marked_as_solved.

@Test
public void should_not_be_touched_when_marked_as_solved() {
    Question shouldILiveForever = question.build();
    User touchedBy = shouldILiveForever.getLastTouchedBy();
    User leo = user("", "");
    Answer yes = answer("my answer", shouldILiveForever, leo);
    assertEquals(User.GHOST, shouldILiveForever.getLastTouchedBy());
    shouldILiveForever.markAsSolvedBy(yes);
    assertEquals(touchedBy, shouldILiveForever.getLastTouchedBy());
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 37 with Question

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

the class WithUserPaginatedDAOTest method should_return_only_answers_with_the_provided_user_ordered_by_vote_count.

@Test
public void should_return_only_answers_with_the_provided_user_ordered_by_vote_count() {
    Question androidQuestion = androidQuestion();
    Answer ehMuito = answer("Sim! É muito ruim! (tanto quanto iOS)", androidQuestion, author);
    ehMuito.substitute(null, upVote);
    ehMuito.substitute(null, upVote2);
    Answer nemEh = answer("Não, é a melhor plataforma mobile do mundo!", androidQuestion, author);
    nemEh.substitute(null, upVote3);
    Answer maisOuMenos = answer("Cara, veja bem: depende do seu ponto de vista.", androidQuestion, author);
    session.save(upVote);
    session.save(upVote2);
    session.save(upVote3);
    session.save(maisOuMenos);
    session.save(ehMuito);
    session.save(nemEh);
    List<Answer> respostasDoAuthor = answersWithUser.by(author, ByVotes, 1);
    assertTrue(respostasDoAuthor.contains(maisOuMenos));
    assertTrue(respostasDoAuthor.contains(ehMuito));
    assertTrue(respostasDoAuthor.contains(nemEh));
    assertEquals(respostasDoAuthor.get(0), ehMuito);
    assertEquals(respostasDoAuthor.get(1), nemEh);
    assertEquals(respostasDoAuthor.get(2), maisOuMenos);
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 38 with Question

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

the class WithUserPaginatedDAOTest method should_return_only_questions_with_the_provided_user_ordered_by_vote_count.

@Test
public void should_return_only_questions_with_the_provided_user_ordered_by_vote_count() {
    Question javaEEQuestion = javaEEQuestion();
    javaEEQuestion.substitute(null, upVote);
    javaEEQuestion.substitute(null, upVote2);
    Question androidQuestion = androidQuestion();
    androidQuestion.substitute(null, upVote3);
    Question javaQuestion = javaQuestion();
    List<Question> perguntasDoAuthor = questionsWithUser.by(author, ByVotes, 1);
    assertTrue(perguntasDoAuthor.contains(javaQuestion));
    assertTrue(perguntasDoAuthor.contains(javaEEQuestion));
    assertTrue(perguntasDoAuthor.contains(androidQuestion));
    assertEquals(perguntasDoAuthor.get(0), javaEEQuestion);
    assertEquals(perguntasDoAuthor.get(1), androidQuestion);
    assertEquals(perguntasDoAuthor.get(2), javaQuestion);
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 39 with Question

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

the class WithUserPaginatedDAOTest method javaQuestion.

private Question javaQuestion() {
    Question q = question.withTitle("Some question about java SE and other stuff").withDescription("Please help solving my question about java! Thanks, guys!").withAuthor(author).withTag(defaultTag).build();
    session.save(q);
    return q;
}
Also used : Question(org.mamute.model.Question)

Example 40 with Question

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

the class WithUserPaginatedDAOTest method javaEEQuestion.

private Question javaEEQuestion() {
    Question q = question.withTitle("Some question about java ee and other stuff?").withDescription("Please help solving my question about java ee! Thanks, guys!").withAuthor(author).withTag(defaultTag).build();
    session.save(q);
    return q;
}
Also used : Question(org.mamute.model.Question)

Aggregations

Question (org.mamute.model.Question)96 Test (org.junit.Test)74 User (org.mamute.model.User)28 Answer (org.mamute.model.Answer)24 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)15 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)15 Tag (org.mamute.model.Tag)9 ArrayList (java.util.ArrayList)8 QuestionBuilder (org.mamute.builder.QuestionBuilder)7 QuestionInformation (org.mamute.model.QuestionInformation)7 DateTime (org.joda.time.DateTime)6 LoggedUser (org.mamute.model.LoggedUser)5 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)5 Elements (org.jsoup.select.Elements)4 AnswerAndVotes (org.mamute.model.AnswerAndVotes)4 Comment (org.mamute.model.Comment)4 Get (br.com.caelum.vraptor.Get)3 Before (org.junit.Before)3 DaoManager (org.mamute.integration.util.DaoManager)3 AnswerInformation (org.mamute.model.AnswerInformation)3