Search in sources :

Example 56 with Question

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

the class QuestionTest method should_verify_that_a_user_already_flagged_question.

@Test
public void should_verify_that_a_user_already_flagged_question() throws Exception {
    Question q = question.build();
    User author = user("author", "author@brutal.com", 1l);
    User other = user("other", "other@brutal.com", 2l);
    Flag flag = flag(FlagType.OTHER, author);
    q.add(flag);
    assertTrue(q.alreadyFlaggedBy(author));
    assertFalse(q.alreadyFlaggedBy(other));
}
Also used : User(org.mamute.model.User) Question(org.mamute.model.Question) Flag(org.mamute.model.Flag) Test(org.junit.Test)

Example 57 with Question

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

the class QuestionTest method should_update_information_and_tag_usage_count.

@Test
public void should_update_information_and_tag_usage_count() throws Exception {
    Tag ruby = tag("ruby");
    Tag java = tag("java");
    Question q = question.withTag(ruby).build();
    QuestionInformation approved = new QuestionInformationBuilder().withTag(java).build();
    q.updateApproved(approved);
    assertEquals(0l, ruby.getUsageCount().longValue());
    assertEquals(1l, java.getUsageCount().longValue());
}
Also used : QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 58 with Question

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

the class QuestionTest method should_verify_show_mark_as_solution_rules_for_author.

@Test
public void should_verify_show_mark_as_solution_rules_for_author() throws Exception {
    User author = user("Fernanda", "bla@bla.com", 1l);
    Question question = question(author);
    assertFalse(question.canMarkAsSolution(author));
    question.add(answer("", question, author));
    assertTrue(question.canMarkAsSolution(author));
}
Also used : User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 59 with Question

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

the class QuestionTest method should_be_touched_by_original_author_after_edit.

@Test
public void should_be_touched_by_original_author_after_edit() throws Exception {
    User artur = user("artur", "artur@x.com");
    artur.setId(1l);
    Question comoFaz = question.withTitle("titulo").withDescription("descricao").withAuthor(artur).build();
    User leo = user("leo", "leo@x.com");
    leo.setId(2l);
    QuestionInformation info = new QuestionInformationBuilder().with(leo).build();
    comoFaz.updateWith(info, updater);
    assertEquals(comoFaz.getLastTouchedBy().getId(), artur.getId());
}
Also used : User(org.mamute.model.User) QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) Question(org.mamute.model.Question) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 60 with Question

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

the class QuestionTest method should_trim_big_meta.

@Test
public void should_trim_big_meta() throws Exception {
    String title = bigString('a', 100);
    String description = bigString('b', 10000);
    Question q = question.withTitle(title).withDescription(description).build();
    assertTrue(q.getMetaDescription().contains(title));
    assertFalse(q.getMetaDescription().contains(description));
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

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