TripTableActionAlterations extends StubTableActionAlterations<Trip> { @NonNull @Override public Single<Trip> postDelete(@Nullable final Trip trip) { return Single.fromCallable(() -> { if (trip == null) { throw new Exception("Post delete failed due to a null trip"); } mReceiptsTable.deleteParentBlocking(trip); mDistanceTable.deleteParentBlocking(trip); if (!mStorageManager.deleteRecursively(trip.getDirectory())) { Logger.error(this, "Failed to fully delete the underlying data. Create a clean up script to fix this later"); } return trip; }); } TripTableActionAlterations(@NonNull PersistenceManager persistenceManager);  TripTableActionAlterations(@NonNull DatabaseHelper databaseHelper, @NonNull StorageManager storageManager);  TripTableActionAlterations(@NonNull Table<Trip> tripsTable, @NonNull ReceiptsTable receiptsTable, @NonNull DistanceTable distanceTable,
                                      @NonNull DatabaseHelper databaseHelper, @NonNull StorageManager storageManager); @NonNull @Override Single<List<Trip>> postGet(@NonNull final List<Trip> trips); @NonNull @Override Single<Trip> postInsert(@NonNull final Trip postInsertTrip); @NonNull @Override Single<Trip> postUpdate(@NonNull final Trip oldTrip, @Nullable final Trip newTrip); @NonNull @Override Single<Trip> postDelete(@Nullable final Trip trip);  }
@Test public void postDeleteNull() throws Exception { mTripTableActionAlterations.postDelete(null) .test() .assertNoValues() .assertNotComplete() .assertError(Exception.class); verifyZeroInteractions(mReceiptsTable, mDistanceTable); }
@Test public void postDeleteSuccess() throws Exception { final File dir = new File("name"); when(mTrip1.getDirectory()).thenReturn(dir); mTripTableActionAlterations.postDelete(mTrip1) .test() .assertValue(mTrip1) .assertComplete() .assertNoErrors(); verify(mReceiptsTable).deleteParentBlocking(mTrip1); verify(mDistanceTable).deleteParentBlocking(mTrip1); verify(mStorageManager).deleteRecursively(dir); }