@Test
public void onPostInsertException() throws Exception {

    final KeyedObject insertItem = new KeyedObject();
    final Exception e = new Exception();
    final DatabaseOperationMetadata databaseOperationMetadata = new DatabaseOperationMetadata();
    when(mTableActionAlterations.preInsert(insertItem)).thenReturn(Single.just(insertItem));
    when(mTable.insert(insertItem, databaseOperationMetadata)).thenReturn(Single.just(insertItem));
    when(mTableActionAlterations.postInsert(insertItem)).thenReturn(Single.error(e));
    mAbstractTableController.unsubscribe(mListener2);
    mAbstractTableController.insert(insertItem, databaseOperationMetadata);
    // The Exceptions.propagate call wraps our exception inside a RuntimeException
    verify(mAnalytics).record(any(ErrorEvent.class));
    verify(mListener1).onInsertFailure(eq(insertItem), any(Exception.class), eq(databaseOperationMetadata));
    verify(mListener3).onInsertFailure(eq(insertItem), any(Exception.class), eq(databaseOperationMetadata));
    verifyZeroInteractions(mListener2);
}