use of org.mamute.model.Question in project mamute by caelum.
the class EditQuestionTest method should_touch_question.
@Test
public void should_touch_question() throws Exception {
User user = new DaoManager().randomUser();
Question question = createQuestionWithDao(user(user.getEmail()), "Question question question question question", "Description description description description description", tag("java"));
UserFlow navigation = login(navigate(), user.getEmail());
navigation = editQuestionWithFlow(navigation, question, "ASdoA sodi aosido iasod iOASIDoIASOdi", "asd oiasudo iausdoi uasoid uaosiduasoduoasi udaiosud oiasud oiasud oisa", "so diaos diaosi d", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
Elements questionElements = getElementsByClass(editedQuestion.getResponseBody(), "edited-touch");
Elements touchImage = getElementsByTag(questionElements.html(), "img");
assertTrue(touchImage.isEmpty());
navigation = login(navigate(), moderator().getEmail());
navigation = editQuestionWithFlow(navigation, question, "Question question question question question", "Description description description description description", "new comment", "java");
editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
questionElements = getElementsByClass(editedQuestion.getResponseBody(), "edited-touch");
touchImage = getElementsByTag(questionElements.html(), "img");
assertFalse(touchImage.isEmpty());
}
use of org.mamute.model.Question in project mamute by caelum.
the class EditQuestionTest method should_edit_and_automatically_approve_author_edit.
@Test
public void should_edit_and_automatically_approve_author_edit() throws Exception {
User karmaNigga = karmaNigga();
Question question = createQuestionWithDao(karmaNigga, "Title title title title title title title", "Description description description description description", tag("java"));
String newTitle = "NEW title title title title title title title";
String newDescription = "NEW description description description description description";
UserFlow navigation = login(navigate(), karmaNigga.getEmail());
navigation = editQuestionWithFlow(navigation, question, newTitle, newDescription, "edited question woots!", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
List<String> messagesList = messagesList(editedQuestion);
assertTrue(messagesList.contains(message("status.no_need_to_approve")));
Question fetchQuestion = editedQuestion.getObject("question");
assertEquals(newTitle, fetchQuestion.getTitle());
assertEquals(newDescription, fetchQuestion.getDescription());
}
use of org.mamute.model.Question in project mamute by caelum.
the class EditQuestionTest method should_edit_question_of_other_author.
@Test
public void should_edit_question_of_other_author() throws Exception {
Question question = createQuestionWithDao(moderator(), "Title title title title title title title", "Description description description description description", tag("java"));
String newTitle = "NEW title title title title title title title";
String newDescription = "NEW description description description description description";
UserFlow navigation = login(navigate(), karmaNigga().getEmail());
navigation = editQuestionWithFlow(navigation, question, newTitle, newDescription, "edited question woots!", "java");
VRaptorTestResult editedQuestion = navigation.followRedirect().execute();
editedQuestion.wasStatus(200).isValid();
List<String> messagesList = messagesList(editedQuestion);
assertTrue(messagesList.contains(message("status.pending")));
}
use of org.mamute.model.Question in project mamute by caelum.
the class CreateQuestionTest method should_make_a_question.
@Test
public void should_make_a_question() {
String title = "My new question about java";
String description = "just a question that i have about java hahahhaha";
Tag tag = tag("java");
UserFlow navigation = login(navigate(), karmaNigga().getEmail());
navigation = createQuestionWithFlow(navigation, title, description, tag.getName(), false);
VRaptorTestResult createdQuestion = navigation.followRedirect().execute();
createdQuestion.wasStatus(200).isValid();
Question question = createdQuestion.getObject("question");
Tag questionTag = question.getTags().get(0);
assertThat(question.getTitle(), equalTo(title));
assertThat(question.getDescription(), equalTo(description));
assertThat(questionTag.getName(), equalTo(tag.getName()));
}
use of org.mamute.model.Question in project mamute by caelum.
the class RssFeedFactoryTest method should_generate_feed.
@Test
public void should_generate_feed() throws IOException {
DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
RssFeedFactory rssFeedFactory = new RssFeedFactory(env, factory);
QuestionBuilder builder = new QuestionBuilder();
DateTimeUtils.setCurrentMillisFixed(100);
User user1 = user("author1", "author@email");
user1.setPhotoUri(new URL("http://imagemsuser1.com"));
Question question1 = builder.withAuthor(user1).withTitle("first question").withDescription("question").withId(1l).build();
User user2 = user("author2", "author@email");
user2.setPhotoUri(new URL("http://imagemsuser2.com"));
Question question2 = builder.withId(2l).withTitle("second question").withAuthor(user2).build();
ByteArrayOutputStream output = new ByteArrayOutputStream();
rssFeedFactory.build(Arrays.<RssContent>asList(question1, question2), output, "title", "description");
output.close();
String xml = new String(output.toByteArray());
assertTrue(xml.contains("first question"));
assertTrue(xml.contains("second question"));
assertTrue(xml.contains("http://imagemsuser1.com"));
assertTrue(xml.contains("http://imagemsuser2.com"));
DateTimeUtils.setCurrentMillisSystem();
}
Aggregations