/**
 * The MIT License
 *
 * Copyright for portions of unirest-java are held by Kong Inc (c) 2013.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package BehaviorTests;

import kong.unirest.Unirest;
import kong.unirest.NoopCallback;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import static kong.unirest.MockCallback.json;

class CallbackFutureTest extends BddTest {

    @Test @Timeout(5)
    void onSuccess() throws Exception {
        Unirest.get(MockServer.GET)
                .queryString("Snazzy", "Shoes")
                .asJsonAsync()
                .thenAccept(r -> {
                    parse(r).assertParam("Snazzy", "Shoes");
                    asyncSuccess();
                }).get();

        assertAsync();
    }

    @Test @Timeout(5)
    void onSuccessSupplyCallback() throws Exception {
        Unirest.get(MockServer.GET)
                .queryString("Snazzy", "Shoes")
                .asJsonAsync(new NoopCallback<>())
                .thenAccept(r -> {
                    parse(r).assertParam("Snazzy", "Shoes");
                    asyncSuccess();
                }).get();

        assertAsync();
    }

    @Test @Timeout(5) @Disabled
    void onFailure() throws Exception {
        Unirest.get("http://localhost:0000")
                .asJsonAsync(json(this))
                .isCompletedExceptionally();

        assertFailed("java.net.ConnectException: Connection refused");
    }
}
@@ -1223,49 +1223,9 @@
 est.
-Unirest;%0Aimport kong.unirest.NoopCallback
+*
 ;%0A%0Ai
@@ -1347,45 +1347,184 @@
 ort 
-static kong.unirest.MockCallback.json
+java.nio.file.Watchable;%0Aimport java.util.concurrent.CompletableFuture;%0A%0Aimport static kong.unirest.MockCallback.json;%0Aimport static org.junit.jupiter.api.Assertions.assertTrue
 ;%0A%0Ac
@@ -2612,10 +2612,1636 @@
 );%0A    %7D
+%0A%0A    boolean wasCalled = false;%0A%0A    @Test @Disabled%0A    void callFailureFunction() throws Exception %7B%0A        wasCalled = false;%0A        try %7B%0A            Unirest.get(%22http://localhost:0000%22)%0A                    .asJsonAsync(new Callback%3CJsonNode%3E() %7B%0A                        @Override%0A                        public void completed(HttpResponse%3CJsonNode%3E response) %7B%0A                            throw new UnirestException(%22Failure!%22);%0A                        %7D%0A%0A                        @Override%0A                        public void failed(UnirestException e) %7B%0A                            wasCalled = true;%0A                        %7D%0A%0A                        @Override%0A                        public void cancelled() %7B%0A%0A                        %7D%0A                    %7D).get();%0A        %7Dcatch (Exception e)%7B%7D%0A%0A        assertTrue(wasCalled);%0A    %7D%0A%0A    @Test @Disabled%0A    void cancelFunction() throws Exception %7B%0A        wasCalled = false;%0A        CompletableFuture%3CHttpResponse%3CJsonNode%3E%3E future = Unirest.get(%22http://localhost:0000%22)%0A                .asJsonAsync(new Callback%3CJsonNode%3E() %7B%0A                    @Override%0A                    public void completed(HttpResponse%3CJsonNode%3E response) %7B%0A                        throw new UnirestException(%22Failure!%22);%0A                    %7D%0A%0A                    @Override%0A                    public void failed(UnirestException e) %7B%0A%0A                    %7D%0A%0A                    @Override%0A                    public void cancelled() %7B%0A                        wasCalled = true;%0A                    %7D%0A                %7D);%0A%0A        future.cancel(true);%0A        assertTrue(wasCalled);%0A    %7D
 %0A%7D

add some tests for async methods as documentation