Java Code Examples for com.google.firebase.database.Transaction#success()
The following examples show how to use
com.google.firebase.database.Transaction#success() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionHandler.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public Transaction.Result doTransaction(MutableData mutableData) { try { if (mutableData.getValue() == null) { mutableData.setValue(transactionFunction.apply((R) DefaultTypeRecognizer.getDefaultValue(dataType))); return Transaction.success(mutableData); } MapConversion mapConversionAnnotation = null; R transactionData; if (promise.getThenConsumer() != null) { mapConversionAnnotation = AnnotationFinder.getMethodAnnotation(MapConversion.class, promise.getThenConsumer()); } if (mapConversionAnnotation != null) { transactionData = (R) mutableData.getValue(mapConversionAnnotation.value()); } else { transactionData = (R) mutableData.getValue(); } mutableData.setValue(transactionFunction.apply(transactionData)); return Transaction.success(mutableData); } catch (Exception e) { GdxFIRLogger.error(TRANSACTION_ERROR, e); return Transaction.abort(); } }
Example 2
Source File: TransactionHandlerTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void doTransaction() { // Given Function transactionFunction = Mockito.mock(Function.class); FuturePromise promise = Mockito.mock(FuturePromise.class); TransactionHandler transactionHandler = new TransactionHandler(Long.class, transactionFunction, promise); MutableData mutableData = Mockito.mock(MutableData.class); Mockito.when(mutableData.getValue()).thenReturn("test_value"); // When transactionHandler.doTransaction(mutableData); // Then PowerMockito.verifyStatic(Transaction.class, VerificationModeFactory.times(1)); Transaction.success(Mockito.nullable(MutableData.class)); }