@Test public void should_delete_report_by_id_and_tenant() { populateDatabase(); repository.deleteReportByIdAndTenant(processId, TENANT_ID); FindIterable<Document> iterable = preservationReportCollection.find(and(eq("processId", processId), eq("tenantId", TENANT_ID))); MongoCursor<Document> iterator = iterable.iterator(); List<Document> documents = new ArrayList<>(); while (iterator.hasNext()) { documents.add(iterator.next()); } assertThat(documents).isEmpty(); assertThat(documents.size()).isEqualTo(0); }
public void deleteReportByIdAndTenant(String processId, int tenantId) { DeleteResult deleteResult = collection.deleteMany(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))); LOGGER.info("Deleted document count: " + deleteResult.getDeletedCount() + " for process " + processId); }
PreservationReportRepository { public void deleteReportByIdAndTenant(String processId, int tenantId) { DeleteResult deleteResult = collection.deleteMany(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))); LOGGER.info("Deleted document count: " + deleteResult.getDeletedCount() + " for process " + processId); } }
PreservationReportRepository { public void deleteReportByIdAndTenant(String processId, int tenantId) { DeleteResult deleteResult = collection.deleteMany(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))); LOGGER.info("Deleted document count: " + deleteResult.getDeletedCount() + " for process " + processId); } @VisibleForTesting  PreservationReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  PreservationReportRepository(MongoDbAccess mongoDbAccess); }
PreservationReportRepository { public void deleteReportByIdAndTenant(String processId, int tenantId) { DeleteResult deleteResult = collection.deleteMany(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))); LOGGER.info("Deleted document count: " + deleteResult.getDeletedCount() + " for process " + processId); } @VisibleForTesting  PreservationReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  PreservationReportRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PreservationReportEntry> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); PreservationStatsModel stats(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); }
PreservationReportRepository { public void deleteReportByIdAndTenant(String processId, int tenantId) { DeleteResult deleteResult = collection.deleteMany(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))); LOGGER.info("Deleted document count: " + deleteResult.getDeletedCount() + " for process " + processId); } @VisibleForTesting  PreservationReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  PreservationReportRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PreservationReportEntry> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); PreservationStatsModel stats(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); static final String PRESERVATION_REPORT; }