Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

True End-To-End Integration Tests

  • Loading branch information...
commit 4cff0b0c9cddde852e0795a12408f30c7cbe3cb1 1 parent fb8297f
@css181 css181 authored
View
56 src/test/java/com/example/domain/MyWebServiceTest.java
@@ -264,4 +264,60 @@ public boolean userNameInList(User user, ArrayList<String> friendNamesList){
return list;
}
+
+
+
+ @Test
+ public void testSubmitAllWrongAnswers(){
+ Player playerWith5Friends = TestUtils.getPlayer(baseContext, 1005);
+
+ //Take note of the player's points before they submit the wrong answers
+ long playerPointsOriginal = playerWith5Friends.getPoints();
+
+ //Submit 3 incorrect answers to our WebService as a POST request
+ String targetURL = baseContext + "rest/webService/GameAnswers/" +
+ "1005/67890/76543/89012/Four%20Friend/Five%20Friend/One%20Friend";
+ String JSONInput = "";
+ String response = TestUtils.doPOST(targetURL, JSONInput);
+
+ //Test that we get the correct String back from the incorrect answers and our points were deducted
+ String expectedResponse = "First entry was INCORRECT "
+ + "Second entry was INCORRECT "
+ + "Third entry was INCORRECT "
+ + "You will have a total of [" + 30
+ + "] points deducted.";
+
+ //Re-GET the player now that the score should be updated
+ playerWith5Friends = TestUtils.getPlayer(baseContext, 1005);
+ Assert.assertTrue(response.equals(expectedResponse));
+ Assert.assertTrue(playerWith5Friends.getPoints()==(playerPointsOriginal - 30));
+ }
+
+
+ @Test
+ public void testSubmitAllCorrectAnswers(){
+ Player playerWith5Friends = TestUtils.getPlayer(baseContext, 1005);
+
+ //Take note of the player's points before they submit the correct answers
+ long playerPointsOriginal = playerWith5Friends.getPoints();
+
+ //Submit 3 correct answers to our WebService as a POST request
+ String targetURL = baseContext + "rest/webService/GameAnswers/" +
+ "1005/67890/76543/89012/One%20Friend/Two%20Friend/Three%20Friend";
+ String JSONInput = "";
+ String response = TestUtils.doPOST(targetURL, JSONInput);
+
+ //Test that we get the correct String back from the incorrect answers and our points were deducted
+ String expectedResponse = "First entry was correct "
+ + "Second entry was correct "
+ + "Thrid entry was correct "
+ + "You will have a total of [" + 30
+ + "] points added!";
+
+ //Re-GET the player now that the score should be updated
+ playerWith5Friends = TestUtils.getPlayer(baseContext, 1005);
+ Assert.assertTrue(response.equals(expectedResponse));
+ Assert.assertTrue(playerWith5Friends.getPoints()==(playerPointsOriginal + 30));
+ }
+
}
View
2  target/m2e-wtp/web-resources/META-INF/maven/com.example/FBTutorialDemo/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
-#Thu Apr 19 20:23:45 EDT 2012
+#Thu Apr 19 20:31:15 EDT 2012
version=1.0.0-SNAPSHOT
groupId=com.example
m2e.projectName=FBTutorialDemo
Please sign in to comment.
Something went wrong with that request. Please try again.