@Test public void generateReport() throws Exception { when(documentClasses.count()).thenReturn(100L); doReturn(docClassCounts).when(documentClasses).map(Mockito.any()); doReturn(2L).doReturn(3L).doReturn(4L).doReturn(5L).doReturn(6L).when(docClassCounts).reduce(Mockito.any()); List<ReportEntry> reportEntries = reportGenerator.generateReport(documentClasses); assertReportEntries(reportEntries, 100, 2, 3, 4, 5, 6); verify(documentClasses, Mockito.times(5)).map(mapFunction.capture()); assertArxivMapFunction(mapFunction.getAllValues().get(0)); assertWosMapFunction(mapFunction.getAllValues().get(1)); assertDdcMapFunction(mapFunction.getAllValues().get(2)); assertMeshMapFunction(mapFunction.getAllValues().get(3)); assertAcmMapFunction(mapFunction.getAllValues().get(4)); verify(docClassCounts, Mockito.times(5)).reduce(reduceFunction.capture()); for (Function2<Long, Long, Long> rf : reduceFunction.getAllValues()) { assertReduceFunction(rf); } }
List<ReportEntry> generateReport(JavaRDD<DocumentToDocumentClasses> documentClasses) { Preconditions.checkNotNull(documentClasses); long classifiedDocumentCount = documentClasses.count(); if (classifiedDocumentCount == 0) { return createReportEntries(0, 0, 0, 0, 0, 0); } long arxivClassCount = documentClasses.map(docClass->size(docClass.getClasses().getArXivClasses())).reduce((i1, i2)-> i1+i2); long wosClassCount = documentClasses.map(docClass->size(docClass.getClasses().getWoSClasses())).reduce((i1, i2)-> i1+i2); long ddcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getDDCClasses())).reduce((i1, i2)-> i1+i2); long meshEuroPmcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getMeshEuroPMCClasses())).reduce((i1, i2)-> i1+i2); long acmClassCount = documentClasses.map(docClass->size(docClass.getClasses().getACMClasses())).reduce((i1, i2)-> i1+i2); return createReportEntries(classifiedDocumentCount, arxivClassCount, wosClassCount, ddcClassCount, meshEuroPmcClassCount, acmClassCount); }
DocClassificationReportGenerator { List<ReportEntry> generateReport(JavaRDD<DocumentToDocumentClasses> documentClasses) { Preconditions.checkNotNull(documentClasses); long classifiedDocumentCount = documentClasses.count(); if (classifiedDocumentCount == 0) { return createReportEntries(0, 0, 0, 0, 0, 0); } long arxivClassCount = documentClasses.map(docClass->size(docClass.getClasses().getArXivClasses())).reduce((i1, i2)-> i1+i2); long wosClassCount = documentClasses.map(docClass->size(docClass.getClasses().getWoSClasses())).reduce((i1, i2)-> i1+i2); long ddcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getDDCClasses())).reduce((i1, i2)-> i1+i2); long meshEuroPmcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getMeshEuroPMCClasses())).reduce((i1, i2)-> i1+i2); long acmClassCount = documentClasses.map(docClass->size(docClass.getClasses().getACMClasses())).reduce((i1, i2)-> i1+i2); return createReportEntries(classifiedDocumentCount, arxivClassCount, wosClassCount, ddcClassCount, meshEuroPmcClassCount, acmClassCount); } }
DocClassificationReportGenerator { List<ReportEntry> generateReport(JavaRDD<DocumentToDocumentClasses> documentClasses) { Preconditions.checkNotNull(documentClasses); long classifiedDocumentCount = documentClasses.count(); if (classifiedDocumentCount == 0) { return createReportEntries(0, 0, 0, 0, 0, 0); } long arxivClassCount = documentClasses.map(docClass->size(docClass.getClasses().getArXivClasses())).reduce((i1, i2)-> i1+i2); long wosClassCount = documentClasses.map(docClass->size(docClass.getClasses().getWoSClasses())).reduce((i1, i2)-> i1+i2); long ddcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getDDCClasses())).reduce((i1, i2)-> i1+i2); long meshEuroPmcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getMeshEuroPMCClasses())).reduce((i1, i2)-> i1+i2); long acmClassCount = documentClasses.map(docClass->size(docClass.getClasses().getACMClasses())).reduce((i1, i2)-> i1+i2); return createReportEntries(classifiedDocumentCount, arxivClassCount, wosClassCount, ddcClassCount, meshEuroPmcClassCount, acmClassCount); }  }
DocClassificationReportGenerator { List<ReportEntry> generateReport(JavaRDD<DocumentToDocumentClasses> documentClasses) { Preconditions.checkNotNull(documentClasses); long classifiedDocumentCount = documentClasses.count(); if (classifiedDocumentCount == 0) { return createReportEntries(0, 0, 0, 0, 0, 0); } long arxivClassCount = documentClasses.map(docClass->size(docClass.getClasses().getArXivClasses())).reduce((i1, i2)-> i1+i2); long wosClassCount = documentClasses.map(docClass->size(docClass.getClasses().getWoSClasses())).reduce((i1, i2)-> i1+i2); long ddcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getDDCClasses())).reduce((i1, i2)-> i1+i2); long meshEuroPmcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getMeshEuroPMCClasses())).reduce((i1, i2)-> i1+i2); long acmClassCount = documentClasses.map(docClass->size(docClass.getClasses().getACMClasses())).reduce((i1, i2)-> i1+i2); return createReportEntries(classifiedDocumentCount, arxivClassCount, wosClassCount, ddcClassCount, meshEuroPmcClassCount, acmClassCount); }   }
DocClassificationReportGenerator { List<ReportEntry> generateReport(JavaRDD<DocumentToDocumentClasses> documentClasses) { Preconditions.checkNotNull(documentClasses); long classifiedDocumentCount = documentClasses.count(); if (classifiedDocumentCount == 0) { return createReportEntries(0, 0, 0, 0, 0, 0); } long arxivClassCount = documentClasses.map(docClass->size(docClass.getClasses().getArXivClasses())).reduce((i1, i2)-> i1+i2); long wosClassCount = documentClasses.map(docClass->size(docClass.getClasses().getWoSClasses())).reduce((i1, i2)-> i1+i2); long ddcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getDDCClasses())).reduce((i1, i2)-> i1+i2); long meshEuroPmcClassCount = documentClasses.map(docClass->size(docClass.getClasses().getMeshEuroPMCClasses())).reduce((i1, i2)-> i1+i2); long acmClassCount = documentClasses.map(docClass->size(docClass.getClasses().getACMClasses())).reduce((i1, i2)-> i1+i2); return createReportEntries(classifiedDocumentCount, arxivClassCount, wosClassCount, ddcClassCount, meshEuroPmcClassCount, acmClassCount); }    }