use of org.mamute.builder.QuestionBuilder in project mamute by caelum.
the class InformationDAOTest method newQuestion.
private Question newQuestion(User author) {
Question question = new QuestionBuilder().withAuthor(author).withTag(java).build();
session.save(question);
return question;
}
use of org.mamute.builder.QuestionBuilder in project mamute by caelum.
the class AuthorRuleTest method should_allow_moderatable_author.
@Test
public void should_allow_moderatable_author() {
AuthorRule<Moderatable> rule = new AuthorRule<>();
User author = user("author", "author@brutal.com", 1l);
User other = user("other", "other@brutal.com", 2l);
Question question = new QuestionBuilder().withAuthor(author).build();
assertFalse(rule.isAllowed(other, question));
assertTrue(rule.isAllowed(author, question));
}
use of org.mamute.builder.QuestionBuilder in project mamute by caelum.
the class EditQuestionRuleTest method setUp.
@Before
public void setUp() {
author = loggedUser("author", "author@brutal.com", 1l);
question = new QuestionBuilder().withAuthor(author.getCurrent()).build();
}
use of org.mamute.builder.QuestionBuilder 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.builder.QuestionBuilder in project mamute by caelum.
the class AnswerInformationTest method setup.
@Before
public void setup() {
AnswerInformation rubyInformation = newVersion(100);
QuestionBuilder builder = new QuestionBuilder();
ruby = new Answer(rubyInformation, builder.build(), null);
}
Aggregations