    @Test
    public void clearIndexAsync() throws Exception {

        index.clearIndexAsync(new AssertCompletionHandler() {
            @Override
            public void doRequestCompleted(JSONObject content, AlgoliaException error) {
                if (error == null) {
                    index.waitTaskAsync(content.optString("taskID"), new AssertCompletionHandler() {
                        @Override
                        public void doRequestCompleted(JSONObject content, AlgoliaException error) {
                            if (error == null) {
                                index.browseAsync(new Query(), new AssertCompletionHandler() {
                                    @Override
                                    public void doRequestCompleted(JSONObject content, AlgoliaException error) {
                                        if (error == null) {
                                            assertEquals(content.optInt("nbHits"), 0);
                                        } else {
                                            fail(error.getMessage());
                                        }
                                    }
                                });
                            } else {
                                fail(error.getMessage());
                            }
                        }
                    });
                } else {
                    fail(error.getMessage());
                }
            }
        });
    }