@Test public void postUpdateNull() throws Exception { receiptTableActionAlterations.postUpdate(receipt, null) .test() .assertNoValues() .assertNotComplete() .assertError(Exception.class); verifyZeroInteractions(storageManager); }
@NonNull @Override public Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt) { return Single.fromCallable(() -> { if (newReceipt == null) { throw new Exception("Post update failed due to a null receipt"); } if (oldReceipt.getFile() != null) { if (newReceipt.getFile() == null || !newReceipt.getFile().equals(oldReceipt.getFile())) { picasso.get().invalidate(oldReceipt.getFile()); storageManager.delete(oldReceipt.getFile()); } } return newReceipt; }); }
ReceiptTableActionAlterations extends StubTableActionAlterations<Receipt> { @NonNull @Override public Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt) { return Single.fromCallable(() -> { if (newReceipt == null) { throw new Exception("Post update failed due to a null receipt"); } if (oldReceipt.getFile() != null) { if (newReceipt.getFile() == null || !newReceipt.getFile().equals(oldReceipt.getFile())) { picasso.get().invalidate(oldReceipt.getFile()); storageManager.delete(oldReceipt.getFile()); } } return newReceipt; }); } }
ReceiptTableActionAlterations extends StubTableActionAlterations<Receipt> { @NonNull @Override public Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt) { return Single.fromCallable(() -> { if (newReceipt == null) { throw new Exception("Post update failed due to a null receipt"); } if (oldReceipt.getFile() != null) { if (newReceipt.getFile() == null || !newReceipt.getFile().equals(oldReceipt.getFile())) { picasso.get().invalidate(oldReceipt.getFile()); storageManager.delete(oldReceipt.getFile()); } } return newReceipt; }); } ReceiptTableActionAlterations(@NonNull Context context,
                                         @NonNull ReceiptsTable receiptsTable,
                                         @NonNull StorageManager storageManager,
                                         @NonNull Lazy<Picasso> picasso);   ReceiptTableActionAlterations(@NonNull Context context,
                                  @NonNull ReceiptsTable receiptsTable,
                                  @NonNull StorageManager storageManager,
                                  @NonNull BuilderFactory1<Receipt, ReceiptBuilderFactory> receiptBuilderFactoryFactory,
                                  @NonNull Lazy<Picasso> picasso); }
ReceiptTableActionAlterations extends StubTableActionAlterations<Receipt> { @NonNull @Override public Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt) { return Single.fromCallable(() -> { if (newReceipt == null) { throw new Exception("Post update failed due to a null receipt"); } if (oldReceipt.getFile() != null) { if (newReceipt.getFile() == null || !newReceipt.getFile().equals(oldReceipt.getFile())) { picasso.get().invalidate(oldReceipt.getFile()); storageManager.delete(oldReceipt.getFile()); } } return newReceipt; }); } ReceiptTableActionAlterations(@NonNull Context context,
                                         @NonNull ReceiptsTable receiptsTable,
                                         @NonNull StorageManager storageManager,
                                         @NonNull Lazy<Picasso> picasso);   ReceiptTableActionAlterations(@NonNull Context context,
                                  @NonNull ReceiptsTable receiptsTable,
                                  @NonNull StorageManager storageManager,
                                  @NonNull BuilderFactory1<Receipt, ReceiptBuilderFactory> receiptBuilderFactoryFactory,
                                  @NonNull Lazy<Picasso> picasso); @NonNull @Override Single<Receipt> preInsert(@NonNull final Receipt receipt); @NonNull @Override Single<Receipt> preUpdate(@NonNull final Receipt oldReceipt, @NonNull final Receipt newReceipt); @NonNull @Override Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt); @NonNull @Override Single<Receipt> postDelete(@Nullable final Receipt receipt); @NonNull Single<Receipt> preCopy(@NonNull final Receipt receipt, @NonNull final Trip toTrip); void postCopy(@NonNull Receipt oldReceipt, @Nullable Receipt newReceipt); @NonNull Single<Receipt> preMove(@NonNull final Receipt receipt, @NonNull final Trip toTrip); void postMove(@NonNull Receipt oldReceipt, @Nullable Receipt newReceipt); }
ReceiptTableActionAlterations extends StubTableActionAlterations<Receipt> { @NonNull @Override public Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt) { return Single.fromCallable(() -> { if (newReceipt == null) { throw new Exception("Post update failed due to a null receipt"); } if (oldReceipt.getFile() != null) { if (newReceipt.getFile() == null || !newReceipt.getFile().equals(oldReceipt.getFile())) { picasso.get().invalidate(oldReceipt.getFile()); storageManager.delete(oldReceipt.getFile()); } } return newReceipt; }); } ReceiptTableActionAlterations(@NonNull Context context,
                                         @NonNull ReceiptsTable receiptsTable,
                                         @NonNull StorageManager storageManager,
                                         @NonNull Lazy<Picasso> picasso);   ReceiptTableActionAlterations(@NonNull Context context,
                                  @NonNull ReceiptsTable receiptsTable,
                                  @NonNull StorageManager storageManager,
                                  @NonNull BuilderFactory1<Receipt, ReceiptBuilderFactory> receiptBuilderFactoryFactory,
                                  @NonNull Lazy<Picasso> picasso); @NonNull @Override Single<Receipt> preInsert(@NonNull final Receipt receipt); @NonNull @Override Single<Receipt> preUpdate(@NonNull final Receipt oldReceipt, @NonNull final Receipt newReceipt); @NonNull @Override Single<Receipt> postUpdate(@NonNull final Receipt oldReceipt, @Nullable final Receipt newReceipt); @NonNull @Override Single<Receipt> postDelete(@Nullable final Receipt receipt); @NonNull Single<Receipt> preCopy(@NonNull final Receipt receipt, @NonNull final Trip toTrip); void postCopy(@NonNull Receipt oldReceipt, @Nullable Receipt newReceipt); @NonNull Single<Receipt> preMove(@NonNull final Receipt receipt, @NonNull final Trip toTrip); void postMove(@NonNull Receipt oldReceipt, @Nullable Receipt newReceipt);  }