### Question:
TransactionHandler implements Transaction.Handler { @Override public void onComplete(DatabaseError databaseError, boolean committed, DataSnapshot dataSnapshot) { if (databaseError != null) { promise.doFail(databaseError.toException()); } else { if (committed) { promise.doComplete(null); } else { promise.doFail(TRANSACTION_NOT_ABLE_TO_COMMIT, null); } } } TransactionHandler(Class<?> dataType, Function<R, R> transactionFunction, FuturePromise<Void> promise); @Override @SuppressWarnings("unchecked") Transaction.Result doTransaction(MutableData mutableData); @Override void onComplete(DatabaseError databaseError, boolean committed, DataSnapshot dataSnapshot);  }### Answer:
@Test public void onComplete_withErrorAndCallback() { Function transactionFunction = Mockito.mock(Function.class); FuturePromise promise = Mockito.mock(FuturePromise.class); TransactionHandler transactionHandler = new TransactionHandler(Long.class, transactionFunction, promise); DatabaseError databaseError = Mockito.mock(DatabaseError.class); DataSnapshot dataSnapshot = Mockito.mock(DataSnapshot.class); boolean status = true; transactionHandler.onComplete(databaseError, status, dataSnapshot); Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.nullable(Exception.class)); }
@Test public void onComplete_withoutErrorAndWithCallback_statusOk() { Function transactionFunction = Mockito.mock(Function.class); FuturePromise promise = Mockito.mock(FuturePromise.class); TransactionHandler transactionHandler = new TransactionHandler(Long.class, transactionFunction, promise); DatabaseError databaseError = null; DataSnapshot dataSnapshot = Mockito.mock(DataSnapshot.class); boolean status = true; transactionHandler.onComplete(databaseError, status, dataSnapshot); Mockito.verify(promise, VerificationModeFactory.times(1)).doComplete(Mockito.nullable(Void.class)); }
@Test public void onComplete_withoutErrorAndWithCallback_statusError() { Function transactionFunction = Mockito.mock(Function.class); FuturePromise promise = Mockito.mock(FuturePromise.class); TransactionHandler transactionHandler = new TransactionHandler(Long.class, transactionFunction, promise); DatabaseError databaseError = null; DataSnapshot dataSnapshot = Mockito.mock(DataSnapshot.class); boolean status = false; transactionHandler.onComplete(databaseError, status, dataSnapshot); Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.anyString(), Mockito.nullable(Throwable.class)); }