@Test public void should_bulk_append_unit_report_and_check_metadata_id_unicity() throws Exception { List<TransferReplyUnitModel> transferReplyUnitModels = getDocuments("/transferReplyUnitModel.json"); repository.bulkAppendReport(transferReplyUnitModels); Document first = eliminationUnitCollection.find(and(eq(TransferReplyUnitModel.METADATA + "." + "id", "unitId1"), eq(TransferReplyUnitModel.TENANT, 0))).first(); assertThat(first).isNotNull() .containsEntry("processId", "123456789") .containsEntry("_tenant", 0) .containsKeys("_metadata"); Object metadata = first.get("_metadata"); JsonNode metadataNode = JsonHandler.toJsonNode(metadata); JsonNode expected = JsonHandler.getFromString( "{\"id\":\"unitId1\",\"status\":\"ALREADY_DELETED\"}"); assertThat(metadataNode).isNotNull().isEqualTo(expected); repository.bulkAppendReport(transferReplyUnitModels); assertThat(eliminationUnitCollection.countDocuments()).isEqualTo(2); }
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; }