Search in sources :

Example 51 with Question

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

the class QuestionRssEntryFactoryTest method should_create_entry_from_a_question.

@Test
public void should_create_entry_from_a_question() throws IOException {
    DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
    QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
    QuestionBuilder builder = new QuestionBuilder();
    DateTimeUtils.setCurrentMillisFixed(100);
    Question question = builder.withAuthor(user("author", "author@email")).withTitle("question title").withDescription("description").withId(1l).build();
    DateTimeUtils.setCurrentMillisSystem();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    factory.writeEntry(question, output);
    output.close();
    String xml = new String(output.toByteArray());
    assertTrue(xml.contains("<link>http://localhost:8080/1-question-title</link>"));
    assertTrue(xml.contains("<title><![CDATA[question title]]></title>"));
    assertTrue(xml.contains("<author><![CDATA[author]]></author>"));
}
Also used : DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) EnvironmentType(br.com.caelum.vraptor.environment.EnvironmentType) QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question) ByteArrayOutputStream(java.io.ByteArrayOutputStream) QuestionRssEntryFactory(org.mamute.infra.rss.write.QuestionRssEntryFactory) Test(org.junit.Test)

Example 52 with Question

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

the class QuestionTest method return_true_if_answer_was_last_touched_two_months_ago.

@Test
public void return_true_if_answer_was_last_touched_two_months_ago() throws Exception {
    Question inactiveQuestion = TimeMachine.goTo(new DateTime().minusMonths(2)).andExecute(new Block<Question>() {

        @Override
        public Question run() {
            return question.withTitle("question title").withDescription("description").build();
        }
    });
    assertTrue(inactiveQuestion.isInactiveForOneMonth());
}
Also used : Question(org.mamute.model.Question) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 53 with Question

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

the class QuestionTest method should_not_trim_short_meta.

@Test
public void should_not_trim_short_meta() throws Exception {
    String title = "0123456789";
    String description = "description";
    Question q = question.withTitle(title).withDescription(description).build();
    assertTrue(q.getMetaDescription().contains(title));
    assertTrue(q.getMetaDescription().contains(description));
}
Also used : Question(org.mamute.model.Question) Test(org.junit.Test)

Example 54 with Question

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

the class QuestionTest method should_verify_if_is_visible_for_author.

@Test
public void should_verify_if_is_visible_for_author() {
    User author = user("leo", "leo@leo");
    Question shouldILiveForever = question.withAuthor(author).build();
    shouldILiveForever.remove();
    boolean isVisibleForAuthor = shouldILiveForever.isVisibleFor(author);
    assertTrue(isVisibleForAuthor);
}
Also used : User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 55 with Question

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

the class QuestionTest method can_be_marked_as_solved_by_the_an_answer_that_is_mine.

@Test
public void can_be_marked_as_solved_by_the_an_answer_that_is_mine() {
    Question shouldILiveForever = question.build();
    Answer yes = answer("my answer", shouldILiveForever, null);
    shouldILiveForever.markAsSolvedBy(yes);
    assertEquals(yes, shouldILiveForever.getSolution());
}
Also used : Answer(org.mamute.model.Answer) 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