ProfileStore { public void deleteImage(UUID userId) { Long streamId = getPhotoStreamId(userId); if (streamId == null) { return; } UserProfileTable table = tables.getUserProfileTable(tx); table.deletePhotoStreamId(UserProfileRow.of(userId)); UserPhotosStreamStore streamStore = UserPhotosStreamStore.of(txnMgr, tables); streamStore.unmarkStreamAsUsed(tx, streamId, EncodingUtils.encodeUUID(userId)); } ProfileStore(TransactionManager txnMgr, Transaction tx); UUID storeNewUser(UserProfile data); UserProfile getUserData(UUID userId); InputStream getImageForUser(UUID userId); void updateImage(UUID userId, Sha256Hash hash, InputStream imageData); void deleteImage(UUID userId); Set<UUID> getUsersWithBirthday(long birthEpochDays);  }
@Test public void testDeleteImage() { final UUID userId = storeUser(); storeImage(userId); runWithRetry(Transaction.TransactionType.AGGRESSIVE_HARD_DELETE, store -> { store.deleteImage(userId); return userId; }); txnMgr.runTaskWithRetry((TransactionTask<Void, RuntimeException>) txn -> { ProfileTableFactory tables = ProfileTableFactory.of(); UserPhotosStreamValueTable streams = tables.getUserPhotosStreamValueTable(txn); Assert.assertTrue(streams.getAllRowsUnordered().isEmpty()); return null; }); }