// Path: qbit/core/src/main/java/io/advantageous/qbit/reactive/Callback.java
// public interface Callback<T> extends io.advantageous.reakt.CallbackHandler<T> {
// 
// 
//     /**
//      * Client View (client of the service)
//      * Called when there is an error
//      *
//      * @param error error
//      */
//     default void onError(final Throwable error) {
// 
//         LoggerFactory.getLogger(Callback.class)
//                 .error(error.getMessage(), error);
// 
//     }
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param t the input argument
//      */
//     void accept(T t);
// 
// 
//     @Override
//     default void onResult(Result<T> result) {
//         if (result.failure()) {
//             onError(result.cause());
//         } else {
//             accept(result.get());
//         }
//     }
// 
// 
//     /**
//      * Called if there is a timeout.
//      * <p>
//      * This will be taken out in Reakt 3.0 (and QBit 2.0).
//      * Use reject instead.
//      */
//     default void onTimeout() {
//     }
// 
// 
//     /**
//      * Service View (service)
//      * Return an error message
//      * alias for reject.
//      * <p>
//      * This will be taken out in Reakt 3.0 (and QBit 2.0).
//      * Use reject instead.
//      *
//      * @param error error
//      */
//     @Deprecated
//     @SuppressWarnings("deprecated")
//     default void returnError(final String error) {
//         reject(error);
//     }
// 
// 
//     /**
//      * Service View (service)
//      * alias for reply
//      * <p>
//      * This will be taken out in Reakt 3.0 (and QBit 2.0).
//      * Use resolve or reply instead.
//      *
//      * @param thisReturn the value to return.
//      */
//     @Deprecated
//     @SuppressWarnings("deprecated")
//     default void returnThis(T thisReturn) {
//         resolve(thisReturn);
//     }
// 
// 
// }


import static org.junit.Assert.assertTrue;
import io.advantageous.qbit.annotation.QueueCallback;
import io.advantageous.qbit.annotation.QueueCallbackType;
import io.advantageous.qbit.message.MethodCall;
import io.advantageous.qbit.message.MethodCallBuilder;
import io.advantageous.qbit.message.Response;
import io.advantageous.qbit.queue.SendQueue;
import io.advantageous.qbit.reactive.Callback;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.Promises;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
            public void method() {
                called = true;
            }

        }
        MyServiceForInvoke myService = new MyServiceForInvoke();

        final BoonServiceMethodCallHandler boonServiceMethodCallHandler = new BoonServiceMethodCallHandler(true);
        boonServiceMethodCallHandler.init(myService, "", "", new SendQueue<Response<Object>>() {
        });

        final Response<Object> response = boonServiceMethodCallHandler.receiveMethodCall(MethodCallBuilder.methodCallBuilder().setName("method").build());


        assertFalse(response.wasErrors());
        assertTrue(myService.called);


        boonServiceMethodCallHandler.startBatch();
        assertTrue(myService.called);
    }


    @Test
    public void testCallMethodWithCallback() {

        class MyServiceForInvoke {

            boolean called;

// Path: qbit/core/src/main/java/io/advantageous/qbit/reactive/Callback.java
// public interface Callback<T> extends io.advantageous.reakt.CallbackHandler<T> {
// 
// 
//     /**
//      * Client View (client of the service)
//      * Called when there is an error
//      *
//      * @param error error
//      */
//     default void onError(final Throwable error) {
// 
//         LoggerFactory.getLogger(Callback.class)
//                 .error(error.getMessage(), error);
// 
//     }
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param t the input argument
//      */
//     void accept(T t);
// 
// 
//     @Override
//     default void onResult(Result<T> result) {
//         if (result.failure()) {
//             onError(result.cause());
//         } else {
//             accept(result.get());
//         }
//     }
// 
// 
//     /**
//      * Called if there is a timeout.
//      * <p>
//      * This will be taken out in Reakt 3.0 (and QBit 2.0).
//      * Use reject instead.
//      */
//     default void onTimeout() {
//     }
// 
// 
//     /**
//      * Service View (service)
//      * Return an error message
//      * alias for reject.
//      * <p>
//      * This will be taken out in Reakt 3.0 (and QBit 2.0).
//      * Use reject instead.
//      *
//      * @param error error
//      */
//     @Deprecated
//     @SuppressWarnings("deprecated")
//     default void returnError(final String error) {
//         reject(error);
//     }
// 
// 
//     /**
//      * Service View (service)
//      * alias for reply
//      * <p>
//      * This will be taken out in Reakt 3.0 (and QBit 2.0).
//      * Use resolve or reply instead.
//      *
//      * @param thisReturn the value to return.
//      */
//     @Deprecated
//     @SuppressWarnings("deprecated")
//     default void returnThis(T thisReturn) {
//         resolve(thisReturn);
//     }
// 
// 
// }


// Path: qbit/core/src/test/java/io/advantageous/qbit/boon/service/impl/BoonServiceMethodCallHandlerTest.java
import static org.junit.Assert.assertTrue;
import io.advantageous.qbit.annotation.QueueCallback;
import io.advantageous.qbit.annotation.QueueCallbackType;
import io.advantageous.qbit.message.MethodCall;
import io.advantageous.qbit.message.MethodCallBuilder;
import io.advantageous.qbit.message.Response;
import io.advantageous.qbit.queue.SendQueue;
import io.advantageous.qbit.reactive.Callback;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.Promises;
import org.junit.Test;
import static org.junit.Assert.assertFalse;

            public void method() {
                called = true;
            }

        }
        MyServiceForInvoke myService = new MyServiceForInvoke();

        final BoonServiceMethodCallHandler boonServiceMethodCallHandler = new BoonServiceMethodCallHandler(true);
        boonServiceMethodCallHandler.init(myService, "", "", new SendQueue<Response<Object>>() {
        });

        final Response<Object> response = boonServiceMethodCallHandler.receiveMethodCall(MethodCallBuilder.methodCallBuilder().setName("method").build());


        assertFalse(response.wasErrors());
        assertTrue(myService.called);


        boonServiceMethodCallHandler.startBatch();
        assertTrue(myService.called);
    }


    @Test
    public void testCallMethodWithCallback() {

        class MyServiceForInvoke {

            boolean called;

            public void method(Callback<Boolean> callback) {