@Test
public void testDispatch() throws Exception {

    mMockWebServer.start();
    Packet packet = mock(Packet.class);
    when(packet.getTargetURL()).thenReturn(mMockWebServer.url("/").toString());
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("key", "value");
    when(packet.getPostData()).thenReturn(jsonObject);
    mMockWebServer.enqueue(new MockResponse());
    mDefaultPacketSender.send(packet);
    final RecordedRequest recordedRequest = mMockWebServer.takeRequest();
    assertThat(recordedRequest, is(not(nullValue())));
    String body = recordedRequest.getBody().readUtf8();
    assertThat(jsonObject.toString(), is(body));
    assertThat(recordedRequest.getHeader("Content-Encoding"), is((nullValue())));
}