Created
February 13, 2017 17:14
-
-
Save kouphax/c04b70e379ed8b549dcb086b6be6966c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package parsers; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import helpers.Assertions; | |
import org.junit.Test; | |
import play.http.HttpErrorHandler; | |
import play.libs.F; | |
import play.mvc.BodyParser; | |
import play.mvc.Http; | |
import play.mvc.Result; | |
import play.test.WithApplication; | |
import static com.google.common.collect.ImmutableMap.of; | |
import static org.junit.Assert.assertTrue; | |
import static org.mockito.Mockito.RETURNS_DEEP_STUBS; | |
import static org.mockito.Mockito.mock; | |
import static play.libs.Json.toJson; | |
public class SubmissionBodyParserTest extends WithApplication implements Assertions { | |
@Test | |
public void parseParsesValidBodies() throws Exception { | |
HttpErrorHandler errorHandler = mock(HttpErrorHandler.class, RETURNS_DEEP_STUBS); | |
JsonNode body = toJson(of("firstName", "James", "lastName", "Hughes")); | |
BodyParser.Json bodyParser = new BodyParser.Json(1024*1024, errorHandler); | |
Http.RequestHeader request = new Http.RequestBuilder().bodyJson(body).build(); | |
F.Either<Result, JsonNode> run = bodyParser.apply(request).run(mat).toCompletableFuture().get(); | |
assertTrue(run.right.isPresent()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment