@Test public void run() { final Database databaseDistribution = Mockito.spy(Database.class); final DatabaseReference databaseReference = Mockito.mock(DatabaseReference.class); Mockito.when(firebaseDatabase.getReference(Mockito.anyString())).thenReturn(databaseReference); Mockito.when(databaseDistribution.inReference(Mockito.anyString())).thenCallRealMethod(); final QueryOnDataChange queryOnDataChange = new QueryOnDataChange(databaseDistribution, "/test"); final ConverterPromise promise = Mockito.spy(ConverterPromise.class); databaseDistribution.inReference("/test"); queryOnDataChange.with(promise).withArgs(Map.class).execute(); Mockito.verify(databaseReference, VerificationModeFactory.times(1)).addValueEventListener(Mockito.any(ValueEventListener.class)); }
@Override @SuppressWarnings("unchecked") protected R run() { SnapshotValueListener dataChangeListener = new SnapshotValueListener((Class) arguments.get(0), (ConverterPromise) promise); filtersProvider.applyFiltering().addValueEventListener(dataChangeListener); ((FutureListenerPromise) promise).onCancel(new CancelListenerAction(dataChangeListener, query)); return null; }
QueryOnDataChange extends AndroidDatabaseQuery<R> { @Override @SuppressWarnings("unchecked") protected R run() { SnapshotValueListener dataChangeListener = new SnapshotValueListener((Class) arguments.get(0), (ConverterPromise) promise); filtersProvider.applyFiltering().addValueEventListener(dataChangeListener); ((FutureListenerPromise) promise).onCancel(new CancelListenerAction(dataChangeListener, query)); return null; } }
QueryOnDataChange extends AndroidDatabaseQuery<R> { @Override @SuppressWarnings("unchecked") protected R run() { SnapshotValueListener dataChangeListener = new SnapshotValueListener((Class) arguments.get(0), (ConverterPromise) promise); filtersProvider.applyFiltering().addValueEventListener(dataChangeListener); ((FutureListenerPromise) promise).onCancel(new CancelListenerAction(dataChangeListener, query)); return null; } QueryOnDataChange(Database databaseDistribution, String databasePath); }
QueryOnDataChange extends AndroidDatabaseQuery<R> { @Override @SuppressWarnings("unchecked") protected R run() { SnapshotValueListener dataChangeListener = new SnapshotValueListener((Class) arguments.get(0), (ConverterPromise) promise); filtersProvider.applyFiltering().addValueEventListener(dataChangeListener); ((FutureListenerPromise) promise).onCancel(new CancelListenerAction(dataChangeListener, query)); return null; } QueryOnDataChange(Database databaseDistribution, String databasePath);  }
QueryOnDataChange extends AndroidDatabaseQuery<R> { @Override @SuppressWarnings("unchecked") protected R run() { SnapshotValueListener dataChangeListener = new SnapshotValueListener((Class) arguments.get(0), (ConverterPromise) promise); filtersProvider.applyFiltering().addValueEventListener(dataChangeListener); ((FutureListenerPromise) promise).onCancel(new CancelListenerAction(dataChangeListener, query)); return null; } QueryOnDataChange(Database databaseDistribution, String databasePath);   }