@Test public void should_bulk_append_unit_report_and_check_no_duplicate() throws Exception { List<PurgeUnitModel> purgeUnitModels1 = getDocuments("/purgeUnitWithDuplicateUnit.json"); List<PurgeUnitModel> purgeUnitModels2 = getDocuments("/purgeUnitWithDuplicateUnit.json"); repository.bulkAppendReport(purgeUnitModels1); repository.bulkAppendReport(purgeUnitModels2); FindIterable<Document> iterable = purgeUnitCollection.find(); MongoCursor<Document> iterator = iterable.iterator(); List<Document> documents = new ArrayList<>(); while (iterator.hasNext()) { documents.add(iterator.next()); } Assertions.assertThat(documents.size()).isEqualTo(9); }
public void bulkAppendReport(List<PurgeUnitModel> reports) { Set<PurgeUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> eliminationUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(eliminationUnitDocument, purgeUnitReportCollection); }
PurgeUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeUnitModel> reports) { Set<PurgeUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> eliminationUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(eliminationUnitDocument, purgeUnitReportCollection); } }
PurgeUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeUnitModel> reports) { Set<PurgeUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> eliminationUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(eliminationUnitDocument, purgeUnitReportCollection); } @VisibleForTesting  PurgeUnitRepository(MongoDbAccess mongoDbAccess, String collectionName);  PurgeUnitRepository(MongoDbAccess mongoDbAccess); }
PurgeUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeUnitModel> reports) { Set<PurgeUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> eliminationUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(eliminationUnitDocument, purgeUnitReportCollection); } @VisibleForTesting  PurgeUnitRepository(MongoDbAccess mongoDbAccess, String collectionName);  PurgeUnitRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PurgeUnitModel> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); MongoCursor<String> distinctObjectGroupOfDeletedUnits(String processId, int tenantId); MongoCursor<Document> computeOwnAccessionRegisterDetails(String processId, int tenantId); }
PurgeUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeUnitModel> reports) { Set<PurgeUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> eliminationUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(eliminationUnitDocument, purgeUnitReportCollection); } @VisibleForTesting  PurgeUnitRepository(MongoDbAccess mongoDbAccess, String collectionName);  PurgeUnitRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PurgeUnitModel> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); MongoCursor<String> distinctObjectGroupOfDeletedUnits(String processId, int tenantId); MongoCursor<Document> computeOwnAccessionRegisterDetails(String processId, int tenantId); static final String PURGE_UNIT; static final String METADATA_OBJECT_GROUP_ID; }