@Test
public void testGetRoomFilesShouldFailOnInvalidJson() {

    mockServer.expect()
            .get()
            .withPath("/api/v1/channels.files")
            .andReturn(DEFAULT_TIMEOUT, "NOT A JSON")
            .once();
    rest.getRoomFiles("general", BaseRoom.RoomType.PUBLIC, 0, Attachment.SortBy.UPLOADED_DATE, Sort.DESC, attachmentCallback);
    verify(attachmentCallback, timeout(100).only())
            .onError(exceptionCaptor.capture());
    RocketChatException exception = exceptionCaptor.getValue();
    assertThat(exception.getMessage(), is(equalTo("A JSONObject text must begin with '{' at character 0")));
    assertThat(exception.getCause(), is(instanceOf(JSONException.class)));
}