Search in sources :

Example 6 with QuestionBuilder

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;
}
Also used : QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question)

Example 7 with QuestionBuilder

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));
}
Also used : AuthorRule(org.mamute.auth.rules.AuthorRule) User(org.mamute.model.User) QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question) Moderatable(org.mamute.model.interfaces.Moderatable) Test(org.junit.Test)

Example 8 with QuestionBuilder

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();
}
Also used : QuestionBuilder(org.mamute.builder.QuestionBuilder) Before(org.junit.Before)

Example 9 with QuestionBuilder

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>"));
}
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 10 with QuestionBuilder

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);
}
Also used : QuestionBuilder(org.mamute.builder.QuestionBuilder) Before(org.junit.Before)

Aggregations

QuestionBuilder (org.mamute.builder.QuestionBuilder)11 Question (org.mamute.model.Question)7 Test (org.junit.Test)5 Before (org.junit.Before)3 DefaultEnvironment (br.com.caelum.vraptor.environment.DefaultEnvironment)2 EnvironmentType (br.com.caelum.vraptor.environment.EnvironmentType)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 QuestionRssEntryFactory (org.mamute.infra.rss.write.QuestionRssEntryFactory)2 User (org.mamute.model.User)2 URL (java.net.URL)1 AuthorRule (org.mamute.auth.rules.AuthorRule)1 NewsBuilder (org.mamute.builder.NewsBuilder)1 RssFeedFactory (org.mamute.infra.rss.write.RssFeedFactory)1 News (org.mamute.model.News)1 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)1 Moderatable (org.mamute.model.interfaces.Moderatable)1