Search in sources :

Example 11 with QuestionInformation

use of org.mamute.model.QuestionInformation 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 12 with QuestionInformation

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

the class UpdaterTest method should_update_if_is_the_author.

@Test
public void should_update_if_is_the_author() {
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(author, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.NO_NEED_TO_APPROVE, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Example 13 with QuestionInformation

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

the class UpdaterTest method should_update_if_is_moderator.

@Test
public void should_update_if_is_moderator() {
    User moderator = user("moderator", "moderator@brutal", nextId()).asModerator();
    QuestionInformation newInformation = new QuestionInformation("title", notMarked("description"), new LoggedUser(moderator, null));
    UpdateStatus update = updater.update(myQuestion, newInformation);
    assertEquals(UpdateStatus.NO_NEED_TO_APPROVE, update);
    assertTrue(myQuestion.getHistory().contains(newInformation));
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) UpdateStatus(org.mamute.model.UpdateStatus) LoggedUser(org.mamute.model.LoggedUser) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Aggregations

QuestionInformation (org.mamute.model.QuestionInformation)13 Test (org.junit.Test)11 Question (org.mamute.model.Question)6 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)6 User (org.mamute.model.User)5 LoggedUser (org.mamute.model.LoggedUser)3 UpdateStatus (org.mamute.model.UpdateStatus)3 DateTime (org.joda.time.DateTime)2 Tag (org.mamute.model.Tag)2 ArrayList (java.util.ArrayList)1 Information (org.mamute.model.Information)1 ModeratableAndPendingHistory (org.mamute.model.ModeratableAndPendingHistory)1