ReceiptBackupListener extends DatabaseBackupListener<Receipt> { @Override public void onDeleteSuccess(@NonNull Receipt receipt, @NonNull DatabaseOperationMetadata databaseOperationMetadata) { super.onDeleteSuccess(receipt, databaseOperationMetadata); if (databaseOperationMetadata.getOperationFamilyType() != OperationFamilyType.Sync) { mDriveReceiptsManager.handleDelete(receipt); } } ReceiptBackupListener(@NonNull DriveDatabaseManager driveDatabaseManager, @NonNull DriveReceiptsManager driveReceiptsManager); @Override void onInsertSuccess(@NonNull Receipt receipt, @NonNull DatabaseOperationMetadata databaseOperationMetadata); @Override void onUpdateSuccess(@NonNull Receipt oldReceipt, @NonNull Receipt newReceipt, @NonNull DatabaseOperationMetadata databaseOperationMetadata); @Override void onDeleteSuccess(@NonNull Receipt receipt, @NonNull DatabaseOperationMetadata databaseOperationMetadata);  }
@Test public void onDeleteSuccess() { mListener.onDeleteSuccess(mReceipt, new DatabaseOperationMetadata()); verify(mDriveDatabaseManager).syncDatabase(); verify(mDriveReceiptsManager).handleDelete(mReceipt); }
@Test public void onSyncDeleteSuccess() { mListener.onDeleteSuccess(mReceipt, new DatabaseOperationMetadata(OperationFamilyType.Sync)); verify(mDriveDatabaseManager, never()).syncDatabase(); verify(mDriveReceiptsManager, never()).handleDelete(any(Receipt.class)); }