### Question:
QueryCompletionListener implements DatabaseReference.CompletionListener { @Override public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { if (promise == null) return; if (databaseError != null) { promise.doFail(databaseError.toException()); } else { promise.doComplete(null); } } QueryCompletionListener(FuturePromise promise); @Override void onComplete(DatabaseError databaseError, DatabaseReference databaseReference);  }### Answer:
@Test public void onComplete_withoutError() { DatabaseError databaseError = null; DatabaseReference databaseReference = Mockito.mock(DatabaseReference.class); FuturePromise promise = Mockito.spy(FuturePromise.class); QueryCompletionListener listener = new QueryCompletionListener(promise); listener.onComplete(databaseError, databaseReference); Mockito.verify(promise, VerificationModeFactory.times(1)).doComplete(Mockito.any()); }
@Test public void onComplete_error() { DatabaseError databaseError = Mockito.mock(DatabaseError.class); DatabaseReference databaseReference = Mockito.mock(DatabaseReference.class); FuturePromise promise = Mockito.spy(FuturePromise.class); promise.silentFail(); QueryCompletionListener listener = new QueryCompletionListener(promise); listener.onComplete(databaseError, databaseReference); Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.nullable(Exception.class)); }