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>"));
}
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());
}
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));
}
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);
}
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());
}
Aggregations