Skip to content

Commit

Permalink
Merge branch 'master' of github.com:caelum/brutal
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandaBernardo committed Dec 9, 2013
2 parents 276e61e + f481257 commit 7664960
Show file tree
Hide file tree
Showing 32 changed files with 897 additions and 234 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ src/main/webapp/font/
src/main/webapp/js/jquery/jquery-plugins*.js
versions.txt
/target
jsp-compilation
37 changes: 23 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>br.com.caelum</groupId>
<artifactId>vraptor</artifactId>
<version>4.0.0-beta-3-SNAPSHOT</version>
<version>4.0.0-beta-3</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
Expand All @@ -42,17 +42,13 @@
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-integration</artifactId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>2.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>2.1.0.Final</version>
</dependency>

<!-- VRaptor plugins -->
<dependency>
Expand Down Expand Up @@ -133,6 +129,7 @@
</exclusion>
</exclusions>
</dependency>

<!-- end of VRaptor plugins -->

<!-- hibernate deps -->
Expand All @@ -158,9 +155,9 @@
<version>5.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>5.0.0.Final</version>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>5.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -391,6 +388,12 @@
<!-- end of jetty/container deps -->

<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-test</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -445,6 +448,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.3</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -635,7 +643,8 @@
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package br.com.caelum.brutal.integration.scene.vraptor;

import static br.com.caelum.vraptor.test.http.Parameters.initWith;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

import org.jsoup.select.Elements;
import org.junit.Assert;
import org.junit.Test;

import br.com.caelum.brutal.model.Answer;
import br.com.caelum.brutal.model.AnswerAndVotes;
import br.com.caelum.brutal.model.Question;
import br.com.caelum.vraptor.test.VRaptorTestResult;
import br.com.caelum.vraptor.test.requestflow.UserFlow;

public class AnswerQuestionTest extends CustomVRaptorIntegration {

@Test
public void should_answer_when_logged_in() {
Question question = createQuestionWithDao(moderator(),
"Titulo da questao hahaha",
"Descricao da questao longa demais", tag("java"));

String description = "Resposta da questao do teste de edicao";

UserFlow navigation = login(navigate(), "karma.nigga@caelum.com.br");
navigation = answerQuestionWithFlow(navigation, question, description, false);

VRaptorTestResult questionAnswered = navigation.followRedirect().execute();
questionAnswered.wasStatus(200).isValid();

AnswerAndVotes answerAndVotes = questionAnswered.getObject("answers");
List<Answer> answers = new ArrayList<Answer>(answerAndVotes.getVotes().keySet());
Assert.assertEquals(description, answers.get(0).getDescription());
}

@Test
public void should_not_display_answer_form_when_not_logged_in() {
Question question = createQuestionWithDao(moderator(),
"Titulo da questao hahaha",
"Descricao da questao longa demais", tag("java"));

UserFlow navigation = goToQuestionPage(navigate(), question);

VRaptorTestResult questionPage = navigation.followRedirect().execute();
questionPage.wasStatus(200).isValid();

Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form");
assertTrue(answerForm.isEmpty());
}

@Test
public void should_not_display_answer_form_when_already_answered() {
Question question = createQuestionWithDao(moderator(),
"Titulo da questao hahaha",
"Descricao da questao longa demais", tag("java"));

answerQuestionWithDao(karmaNigga(), question,
"Resposta da questao do teste de edicao", false);

UserFlow navigation = login(navigate(), "karma.nigga@caelum.com.br");
navigation = goToQuestionPage(navigation, question);

VRaptorTestResult questionPage = navigation.followRedirect().execute();
questionPage.wasStatus(200).isValid();

Elements answerForm = getElementsByClass(questionPage.getResponseBody(), "answer-form");
assertTrue(answerForm.isEmpty());
}

private UserFlow goToQuestionPage(UserFlow navigation, Question question) {
String url = String.format("/%s-mock", question.getId());
return navigation.get(url,
initWith("question", question)
.add("sluggedTitle", question.getSluggedTitle()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package br.com.caelum.brutal.integration.scene.vraptor;

import org.junit.Test;

public class CommentAnswerTest extends CustomVRaptorIntegration {

@Test
public void should_comment_answer_after_login() throws Exception {

}
}
Loading

0 comments on commit 7664960

Please sign in to comment.