@Test
public void testSigninShouldFailOnInvalidJson() {

    mockServer.expect()
            .post()
            .withPath("/api/v1/login")
            .andReturn(200, "NOT A JSON")
            .once();
    rest.signin("user", "password", loginCallback);
    verify(loginCallback, timeout(DEFAULT_TIMEOUT).only())
            .onError(exceptionCaptor.capture());
    RocketChatException exception = exceptionCaptor.getValue();
    assertThat(exception, is(instanceOf(RocketChatInvalidResponseException.class)));
    assertThat(exception.getMessage(),
            is(equalTo("Use JsonReader.setLenient(true) to accept malformed JSON at path $")));
    assertThat(exception.getCause(), is(instanceOf(JsonEncodingException.class)));
}