@Test public void should_bulk_append_unit_report_and_check_no_duplicate() throws Exception { List<TransferReplyUnitModel> transferReplyUnitModels1 = getDocuments("/eliminationUnitWithDuplicateUnit.json"); List<TransferReplyUnitModel> transferReplyUnitModels2 = getDocuments("/eliminationUnitWithDuplicateUnit.json"); repository.bulkAppendReport(transferReplyUnitModels1); repository.bulkAppendReport(transferReplyUnitModels2); FindIterable<Document> iterable = eliminationUnitCollection.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<TransferReplyUnitModel> reports) { Set<TransferReplyUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> transferReplyUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(transferReplyUnitDocument, transferReplyReportCollection); }
TransferReplyUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<TransferReplyUnitModel> reports) { Set<TransferReplyUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> transferReplyUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(transferReplyUnitDocument, transferReplyReportCollection); } }
TransferReplyUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<TransferReplyUnitModel> reports) { Set<TransferReplyUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> transferReplyUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(transferReplyUnitDocument, transferReplyReportCollection); } @VisibleForTesting  TransferReplyUnitRepository(MongoDbAccess mongoDbAccess, String collectionName);  TransferReplyUnitRepository(MongoDbAccess mongoDbAccess); }
TransferReplyUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<TransferReplyUnitModel> reports) { Set<TransferReplyUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> transferReplyUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(transferReplyUnitDocument, transferReplyReportCollection); } @VisibleForTesting  TransferReplyUnitRepository(MongoDbAccess mongoDbAccess, String collectionName);  TransferReplyUnitRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<TransferReplyUnitModel> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); }
TransferReplyUnitRepository extends ReportCommonRepository { public void bulkAppendReport(List<TransferReplyUnitModel> reports) { Set<TransferReplyUnitModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> transferReplyUnitDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(transferReplyUnitDocument, transferReplyReportCollection); } @VisibleForTesting  TransferReplyUnitRepository(MongoDbAccess mongoDbAccess, String collectionName);  TransferReplyUnitRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<TransferReplyUnitModel> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); static final String TRANSFER_REPLY_UNIT; }