@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)); }
@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 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 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); }
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); }
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);  }