Syncbase { public static void addScanForUsersInNeighborhood(final ScanNeighborhoodForUsersCallback cb) { synchronized (sScanMappingMu) { try { long scanId = Neighborhood.NewScan(new Neighborhood.NeighborhoodScanCallbacks() { @Override public void onPeer(final NeighborhoodPeer peer) { final SettableFuture<Boolean> setFuture = SettableFuture.create(); Syncbase.sOpts.mCallbackExecutor.execute(new Runnable() { @Override public void run() { User u = new User(getAliasFromBlessingPattern(peer.blessings)); if (peer.isLost) { cb.onLost(u); } else { cb.onFound(u); } setFuture.set(true); } }); try { setFuture.get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); System.err.println(e.toString()); } } }); sScanMapping.put(cb, scanId); } catch (VError vError) { cb.onError(vError); } } } private  Syncbase(); static void init(Options opts); static void executeCallback(Runnable runnable); static Database database(); static void shutdown(); static boolean isLoggedIn(); static User getLoggedInUser(); static void login(final String authToken, final String provider, final LoginCallback cb); static void addScanForUsersInNeighborhood(final ScanNeighborhoodForUsersCallback cb); static void removeScanForUsersInNeighborhood(ScanNeighborhoodForUsersCallback cb); static void removeAllScansForUsersInNeighborhood(); static void advertiseLoggedInUserInNeighborhood(); static void advertiseLoggedInUserInNeighborhood(Iterable<User> usersWhoCanSee); static void stopAdvertisingLoggedInUserInNeighborhood(); static boolean isAdvertisingLoggedInUserInNeighborhood(); static final String USERDATA_NAME; }
@Test public void testScanInNeighborhoodNotLoggedIn() { final SettableFuture<Boolean> errored = SettableFuture.create(); Syncbase.ScanNeighborhoodForUsersCallback cb = new Syncbase.ScanNeighborhoodForUsersCallback() { @Override public void onFound(User user) {} @Override public void onLost(User user) {} @Override public void onError(Throwable e) { assertNotNull("should error", e); errored.set(true); } }; Syncbase.addScanForUsersInNeighborhood(cb); try { assertTrue(errored.get(1, TimeUnit.SECONDS)); } catch (InterruptedException | TimeoutException | ExecutionException e) { fail("should have been able to get successfully"); } }