// Path: buruberi-core/src/test/java/is/hello/buruberi/testing/AssertExtensions.java
// public class AssertExtensions {
//     /**
//      * Checks that a given {@link ThrowingRunnable} throws an exception, calling fail if it does not.
//      * @param runnable  The runnable that should throw an exception. Required.
//      */
//     public static void assertThrows(@NonNull ThrowingRunnable runnable) {
//         try {
//             runnable.run();
//         } catch (Throwable e) {
//             return;
//         }
// 
//         Assert.fail("expected exception, got none");
//     }
// 
//     /**
//      * Variant of the Runnable interface that throws a generic checked exception.
//      */
//     public interface ThrowingRunnable {
//         void run() throws Exception;
//     }
// }
// 
// Path: buruberi-core/src/test/java/is/hello/buruberi/testing/BuruberiTestCase.java
// @RunWith(RobolectricGradleTestRunner.class)
// @Config(constants = BuildConfig.class,
//         sdk = 21,
//         shadows = {
//                 ShadowBluetoothManager.class,
//                 ShadowBluetoothAdapterExt.class,
//                 ShadowBluetoothLeScanner.class,
//                 ShadowBluetoothGatt.class,
//                 ShadowBluetoothDeviceExt.class,
//         })
// public abstract class BuruberiTestCase {
//     protected BuruberiTestCase() {
//         final Context baseContext = RuntimeEnvironment.application.getBaseContext();
//         BuruberiShadows.setUpSystemServices(baseContext);
//     }
// 
//     @Before
//     public void setUp() {
//         ShadowBluetoothAdapterExt shadowBluetoothAdapter = getShadowBluetoothAdapter();
//         shadowBluetoothAdapter.setState(BluetoothAdapter.STATE_ON);
//         shadowBluetoothAdapter.setEnabled(true);
//     }
// 
//     @After
//     public void tearDown() {
//         ShadowBluetoothManager shadowBluetoothManager = getShadowBluetoothManager();
//         shadowBluetoothManager.clearConnectionStates();
//         shadowBluetoothManager.setAdapter(BluetoothAdapter.getDefaultAdapter());
//     }
// 
//     protected Context getContext() {
//         return RuntimeEnvironment.application.getApplicationContext();
//     }
// 
//     protected ShadowBluetoothManager getShadowBluetoothManager() {
//         BluetoothManager bluetoothManager = (BluetoothManager) getContext().getSystemService(Context.BLUETOOTH_SERVICE);
//         return BuruberiShadows.shadowOf(bluetoothManager);
//     }
// 
//     protected ShadowBluetoothAdapterExt getShadowBluetoothAdapter() {
//         return BuruberiShadows.shadowOf(BluetoothAdapter.getDefaultAdapter());
//     }
// }
// 
// Path: buruberi-core/src/test/java/is/hello/buruberi/testing/AssertExtensions.java
// public static void assertThrows(@NonNull ThrowingRunnable runnable) {
//     try {
//         runnable.run();
//     } catch (Throwable e) {
//         return;
//     }
// 
//     Assert.fail("expected exception, got none");
// }


import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import android.support.annotation.Nullable;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import is.hello.buruberi.testing.AssertExtensions;
import is.hello.buruberi.testing.BuruberiTestCase;
import static is.hello.buruberi.testing.AssertExtensions.assertThrows;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
    public void exceptions() throws Exception {
        final SerialQueue queue = new SerialQueue();

        // Have to force the queue into the intended state
        queue.queue.offer(new SerialQueue.Task() {
            @Override
            public void run() {
                throw new RuntimeException(">_<");
            }

            @Override
            public void cancel(@Nullable Throwable cause) {
                fail();
            }
        });
        final AtomicBoolean cancelCalled = new AtomicBoolean();
        queue.queue.offer(new SerialQueue.Task() {
            @Override
            public void cancel(@Nullable Throwable cause) {
                cancelCalled.set(true);
                assertThat(cause, is(instanceOf(RuntimeException.class)));
            }

            @Override
            public void run() {
                fail();
            }
        });
        queue.busy = true;

// Path: buruberi-core/src/test/java/is/hello/buruberi/testing/AssertExtensions.java
// public class AssertExtensions {
//     /**
//      * Checks that a given {@link ThrowingRunnable} throws an exception, calling fail if it does not.
//      * @param runnable  The runnable that should throw an exception. Required.
//      */
//     public static void assertThrows(@NonNull ThrowingRunnable runnable) {
//         try {
//             runnable.run();
//         } catch (Throwable e) {
//             return;
//         }
// 
//         Assert.fail("expected exception, got none");
//     }
// 
//     /**
//      * Variant of the Runnable interface that throws a generic checked exception.
//      */
//     public interface ThrowingRunnable {
//         void run() throws Exception;
//     }
// }
// 
// Path: buruberi-core/src/test/java/is/hello/buruberi/testing/BuruberiTestCase.java
// @RunWith(RobolectricGradleTestRunner.class)
// @Config(constants = BuildConfig.class,
//         sdk = 21,
//         shadows = {
//                 ShadowBluetoothManager.class,
//                 ShadowBluetoothAdapterExt.class,
//                 ShadowBluetoothLeScanner.class,
//                 ShadowBluetoothGatt.class,
//                 ShadowBluetoothDeviceExt.class,
//         })
// public abstract class BuruberiTestCase {
//     protected BuruberiTestCase() {
//         final Context baseContext = RuntimeEnvironment.application.getBaseContext();
//         BuruberiShadows.setUpSystemServices(baseContext);
//     }
// 
//     @Before
//     public void setUp() {
//         ShadowBluetoothAdapterExt shadowBluetoothAdapter = getShadowBluetoothAdapter();
//         shadowBluetoothAdapter.setState(BluetoothAdapter.STATE_ON);
//         shadowBluetoothAdapter.setEnabled(true);
//     }
// 
//     @After
//     public void tearDown() {
//         ShadowBluetoothManager shadowBluetoothManager = getShadowBluetoothManager();
//         shadowBluetoothManager.clearConnectionStates();
//         shadowBluetoothManager.setAdapter(BluetoothAdapter.getDefaultAdapter());
//     }
// 
//     protected Context getContext() {
//         return RuntimeEnvironment.application.getApplicationContext();
//     }
// 
//     protected ShadowBluetoothManager getShadowBluetoothManager() {
//         BluetoothManager bluetoothManager = (BluetoothManager) getContext().getSystemService(Context.BLUETOOTH_SERVICE);
//         return BuruberiShadows.shadowOf(bluetoothManager);
//     }
// 
//     protected ShadowBluetoothAdapterExt getShadowBluetoothAdapter() {
//         return BuruberiShadows.shadowOf(BluetoothAdapter.getDefaultAdapter());
//     }
// }
// 
// Path: buruberi-core/src/test/java/is/hello/buruberi/testing/AssertExtensions.java
// public static void assertThrows(@NonNull ThrowingRunnable runnable) {
//     try {
//         runnable.run();
//     } catch (Throwable e) {
//         return;
//     }
// 
//     Assert.fail("expected exception, got none");
// }


// Path: buruberi-core/src/test/java/is/hello/buruberi/util/SerialQueueTests.java
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import android.support.annotation.Nullable;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import is.hello.buruberi.testing.AssertExtensions;
import is.hello.buruberi.testing.BuruberiTestCase;
import static is.hello.buruberi.testing.AssertExtensions.assertThrows;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;

    public void exceptions() throws Exception {
        final SerialQueue queue = new SerialQueue();

        // Have to force the queue into the intended state
        queue.queue.offer(new SerialQueue.Task() {
            @Override
            public void run() {
                throw new RuntimeException(">_<");
            }

            @Override
            public void cancel(@Nullable Throwable cause) {
                fail();
            }
        });
        final AtomicBoolean cancelCalled = new AtomicBoolean();
        queue.queue.offer(new SerialQueue.Task() {
            @Override
            public void cancel(@Nullable Throwable cause) {
                cancelCalled.set(true);
                assertThat(cause, is(instanceOf(RuntimeException.class)));
            }

            @Override
            public void run() {
                fail();
            }
        });
        queue.busy = true;

        assertThrows(new AssertExtensions.ThrowingRunnable() {