@Test public void bulkAppendUnits_noDuplicates() throws Exception { List<String> units1 = Arrays.asList("unit1", "unit2", "unit4"); List<String> units2 = Arrays.asList("unit3", "unit4"); List<String> units3 = Collections.singletonList("unit5"); repository.bulkAppendReport(buildReport(units1, "procId1")); repository.bulkAppendReport(buildReport(units2, "procId1")); repository.bulkAppendReport(buildReport(units3, "procId1")); long count = mongoCollection.countDocuments(and( eq(METADATA_UNIT_ID, "unit1"), eq(TENANT_ID, 0), eq(PROCESS_ID, "procId1"))); assertThat(count).isEqualTo(1); assertThat(mongoCollection.countDocuments()).isEqualTo(5); }
public void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports) { Set<UnitComputedInheritedRulesInvalidationModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> entries = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument).collect(Collectors.toList()); super.bulkAppendReport(entries, collection); }
UnitComputedInheritedRulesInvalidationRepository extends ReportCommonRepository { public void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports) { Set<UnitComputedInheritedRulesInvalidationModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> entries = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument).collect(Collectors.toList()); super.bulkAppendReport(entries, collection); } }
UnitComputedInheritedRulesInvalidationRepository extends ReportCommonRepository { public void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports) { Set<UnitComputedInheritedRulesInvalidationModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> entries = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument).collect(Collectors.toList()); super.bulkAppendReport(entries, collection); } @VisibleForTesting  UnitComputedInheritedRulesInvalidationRepository(MongoDbAccess mongoDbAccess, String collectionName);  UnitComputedInheritedRulesInvalidationRepository(SimpleMongoDBAccess mongoDbAccess); }
UnitComputedInheritedRulesInvalidationRepository extends ReportCommonRepository { public void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports) { Set<UnitComputedInheritedRulesInvalidationModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> entries = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument).collect(Collectors.toList()); super.bulkAppendReport(entries, collection); } @VisibleForTesting  UnitComputedInheritedRulesInvalidationRepository(MongoDbAccess mongoDbAccess, String collectionName);  UnitComputedInheritedRulesInvalidationRepository(SimpleMongoDBAccess mongoDbAccess); void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports); CloseableIterator<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); }
UnitComputedInheritedRulesInvalidationRepository extends ReportCommonRepository { public void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports) { Set<UnitComputedInheritedRulesInvalidationModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> entries = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument).collect(Collectors.toList()); super.bulkAppendReport(entries, collection); } @VisibleForTesting  UnitComputedInheritedRulesInvalidationRepository(MongoDbAccess mongoDbAccess, String collectionName);  UnitComputedInheritedRulesInvalidationRepository(SimpleMongoDBAccess mongoDbAccess); void bulkAppendReport(List<UnitComputedInheritedRulesInvalidationModel> reports); CloseableIterator<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId);  }