@Test public void onPostDeleteException() throws Exception { final KeyedObject deleteCandidateItem = new KeyedObject(); final KeyedObject deletedItem = new KeyedObject(); final Exception e = new Exception(); final DatabaseOperationMetadata databaseOperationMetadata = new DatabaseOperationMetadata(); when(mTableActionAlterations.preDelete(deleteCandidateItem)).thenReturn(Single.just(deleteCandidateItem)); when(mTable.delete(deleteCandidateItem, databaseOperationMetadata)).thenReturn(Single.just(deletedItem)); when(mTableActionAlterations.postDelete(deletedItem)).thenReturn(Single.error(e)); mAbstractTableController.unsubscribe(mListener2); mAbstractTableController.delete(deleteCandidateItem, databaseOperationMetadata); verify(mAnalytics).record(any(ErrorEvent.class)); verify(mListener1).onDeleteFailure(eq(deleteCandidateItem), any(Exception.class), eq(databaseOperationMetadata)); verify(mListener3).onDeleteFailure(eq(deleteCandidateItem), any(Exception.class), eq(databaseOperationMetadata)); verifyZeroInteractions(mListener2); }
@Override public synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener) { if (tableEventsListener instanceof TripForeignKeyTableEventsListener) { final TripForeignKeyTableEventsListener<ModelType> tripForeignKeyTableEventsListener = (TripForeignKeyTableEventsListener<ModelType>) tableEventsListener; mForeignTableEventsListeners.remove(tripForeignKeyTableEventsListener); final BridgingTripForeignKeyTableEventsListener<ModelType> bridge = mBridgingTableEventsListeners.remove(tripForeignKeyTableEventsListener); if (bridge != null) { bridge.unsubscribe(); } } else { super.unsubscribe(tableEventsListener); } }
TripForeignKeyAbstractTableController extends AbstractTableController<ModelType> { @Override public synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener) { if (tableEventsListener instanceof TripForeignKeyTableEventsListener) { final TripForeignKeyTableEventsListener<ModelType> tripForeignKeyTableEventsListener = (TripForeignKeyTableEventsListener<ModelType>) tableEventsListener; mForeignTableEventsListeners.remove(tripForeignKeyTableEventsListener); final BridgingTripForeignKeyTableEventsListener<ModelType> bridge = mBridgingTableEventsListeners.remove(tripForeignKeyTableEventsListener); if (bridge != null) { bridge.unsubscribe(); } } else { super.unsubscribe(tableEventsListener); } } }
TripForeignKeyAbstractTableController extends AbstractTableController<ModelType> { @Override public synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener) { if (tableEventsListener instanceof TripForeignKeyTableEventsListener) { final TripForeignKeyTableEventsListener<ModelType> tripForeignKeyTableEventsListener = (TripForeignKeyTableEventsListener<ModelType>) tableEventsListener; mForeignTableEventsListeners.remove(tripForeignKeyTableEventsListener); final BridgingTripForeignKeyTableEventsListener<ModelType> bridge = mBridgingTableEventsListeners.remove(tripForeignKeyTableEventsListener); if (bridge != null) { bridge.unsubscribe(); } } else { super.unsubscribe(tableEventsListener); } } TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull Analytics analytics);  TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull TableActionAlterations<ModelType> tableActionAlterations, @NonNull Analytics analytics);   TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull TableActionAlterations<ModelType> tableActionAlterations, @NonNull Analytics analytics, @NonNull Scheduler subscribeOnScheduler, @NonNull Scheduler observeOnScheduler); }
TripForeignKeyAbstractTableController extends AbstractTableController<ModelType> { @Override public synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener) { if (tableEventsListener instanceof TripForeignKeyTableEventsListener) { final TripForeignKeyTableEventsListener<ModelType> tripForeignKeyTableEventsListener = (TripForeignKeyTableEventsListener<ModelType>) tableEventsListener; mForeignTableEventsListeners.remove(tripForeignKeyTableEventsListener); final BridgingTripForeignKeyTableEventsListener<ModelType> bridge = mBridgingTableEventsListeners.remove(tripForeignKeyTableEventsListener); if (bridge != null) { bridge.unsubscribe(); } } else { super.unsubscribe(tableEventsListener); } } TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull Analytics analytics);  TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull TableActionAlterations<ModelType> tableActionAlterations, @NonNull Analytics analytics);   TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull TableActionAlterations<ModelType> tableActionAlterations, @NonNull Analytics analytics, @NonNull Scheduler subscribeOnScheduler, @NonNull Scheduler observeOnScheduler); @Override synchronized void subscribe(@NonNull TableEventsListener<ModelType> tableEventsListener); @Override synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener); synchronized Single<List<ModelType>> get(@NonNull Trip trip); synchronized Single<List<ModelType>> get(@NonNull final Trip trip, final  boolean isDescending); @NonNull Observable<ForeignKeyGetResult<ModelType>> getForeignKeyGetStream(); }
TripForeignKeyAbstractTableController extends AbstractTableController<ModelType> { @Override public synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener) { if (tableEventsListener instanceof TripForeignKeyTableEventsListener) { final TripForeignKeyTableEventsListener<ModelType> tripForeignKeyTableEventsListener = (TripForeignKeyTableEventsListener<ModelType>) tableEventsListener; mForeignTableEventsListeners.remove(tripForeignKeyTableEventsListener); final BridgingTripForeignKeyTableEventsListener<ModelType> bridge = mBridgingTableEventsListeners.remove(tripForeignKeyTableEventsListener); if (bridge != null) { bridge.unsubscribe(); } } else { super.unsubscribe(tableEventsListener); } } TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull Analytics analytics);  TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull TableActionAlterations<ModelType> tableActionAlterations, @NonNull Analytics analytics);   TripForeignKeyAbstractTableController(@NonNull TripForeignKeyAbstractSqlTable<ModelType> table, @NonNull TableActionAlterations<ModelType> tableActionAlterations, @NonNull Analytics analytics, @NonNull Scheduler subscribeOnScheduler, @NonNull Scheduler observeOnScheduler); @Override synchronized void subscribe(@NonNull TableEventsListener<ModelType> tableEventsListener); @Override synchronized void unsubscribe(@NonNull TableEventsListener<ModelType> tableEventsListener); synchronized Single<List<ModelType>> get(@NonNull Trip trip); synchronized Single<List<ModelType>> get(@NonNull final Trip trip, final  boolean isDescending); @NonNull Observable<ForeignKeyGetResult<ModelType>> getForeignKeyGetStream();  }