@Test public void testSubmitAllBlankAnswers() { String appName = "FBTutorialDemo"; Player playerWith5Friends = TestUtils.getPlayer(1005); // Take note of the player's points before they submit the blank answers long playerPointsOriginal = playerWith5Friends.getPoints(); // Submit 3 blank answers to our WebService as a POST request String targetURL = "http://localhost:8080/FBTutorialDemo/rest/webService/GameAnswers/" + "1005/67890/76543/89012"; String JSONInput = "[\"" + "\",\"" + "\",\"" + "\"]"; String response = TestUtils.doPOST(targetURL, JSONInput); // Test that we get the correct String back from the blank 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."; System.out.println("\n\n\n\n\n\n response: " + response); System.out.println("\n\n\n\n\n\n"); // Re-GET the player now that the score should be updated playerWith5Friends = TestUtils.getPlayer(1005); Assert.assertTrue(response.equals(expectedResponse)); Assert.assertTrue(playerWith5Friends.getPoints() == (playerPointsOriginal - 30)); }
@Test public void testSubmitAllCorrectAnswers() { Player playerWith5Friends = TestUtils.getPlayer(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 = "http://localhost:8080/FBTutorialDemo/rest/webService/GameAnswers/" + "1005/67890/76543/89012"; String JSONInput = "[\"" + "One Friend" + "\",\"" + "Two Friend" + "\",\"" + "Three Friend" + "\"]"; 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(1005); Assert.assertTrue(response.equals(expectedResponse)); Assert.assertTrue(playerWith5Friends.getPoints() == (playerPointsOriginal + 30)); }