title: Test POST request on PlayFramework 2.4.x
body: <p>Good morning,</p>
  
  <p>I'm trying to test some POST requests on my controllers.</p>
  
  <p>I have no problems with GET request :</p>
  
  <pre><code>@Test
  public void testGetAll() {
      TestModel test = new TestModel();
      test.done = true;
      test.name = "Pierre";
      test.save();
  
      TestModel test2 = new TestModel();
      test2.done = true;
      test2.name = "Paul";
      test2.save();
  
      Result result = new controllers.ressources.TestRessource().get(null);
      assertEquals(200, result.status());
      assertEquals("text/plain", result.contentType());
      assertEquals("utf-8", result.charset());
      assertTrue(contentAsString(result).contains("Pierre"));
      assertTrue(contentAsString(result).contains("Paul"));
  }
  </code></pre>
  
  <p>But when I have to test a POST request, i can't give POST params to the controller.</p>
  
  <p>here is the method I want to test :</p>
  
  <pre><code>public Result post() {
      Map&lt;String, String&gt; params =     RequestUtils.convertRequestForJsonDecode(request().queryString());
  
      T model = Json.fromJson(Json.toJson(params), genericType);
      model.save();
  
      reponse.setData(model);
      return ok(Json.prettyPrint(Json.toJson(reponse)));
  }
  </code></pre>
  
  <p>I've try several solutions, but I can't find a proper one :</p>
  
  <ul>
  <li>Try to use FakeRequest</li>
  <li>Try to Mock the Http.Request object</li>
  </ul>
  
  <p>So, what is the best way to write tests for my controllers ?</p>
  
  <p>I'm using Play Framework 2.4.6 with Java.
  Junit 4 and Mockito.</p>