### Question:
DocxGenerator extends OutputGenerator<byte[]> { protected static Set<String> extractMostCommonLicenses(Collection<ObligationParsingResult> obligationResults, long threshold) { return obligationResults.stream() .filter(opr -> opr.getStatus() == ObligationInfoRequestStatus.SUCCESS) .flatMap(opr -> opr.getObligationsAtProject().stream()) .flatMap(o -> o.getLicenseIDs().stream()) .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) .entrySet().stream() .filter(entry -> entry.getValue().longValue() >= threshold) .map(entry -> entry.getKey()) .map(license -> license.replace("\n", "").replace("\r", "")) .collect(Collectors.toSet()); } DocxGenerator(OutputFormatVariant outputFormatVariant, String description); @Override byte[] generateOutputFile(Collection<LicenseInfoParsingResult> projectLicenseInfoResults, Project project, Collection<ObligationParsingResult> obligationResults, User user, Map<String, String> externalIds, Map<String, ObligationStatusInfo> obligationsStatus); int getNoOfTablesCreated(); void setNoOfTablesCreated(int noOfTablesCreated); static final int OVERVIEW_TABLE_INDEX; static final int SPECIAL_OSS_RISKS_TABLE_INDEX; static final int DEV_DETAIL_TABLE_INDEX; static final int THIRD_PARTY_COMPONENT_OVERVIEW_TABLE_INDEX; static final int ADDITIONAL_REQ_TABLE_INDEX; static int OBLIGATION_STATUS_TABLE_INDEX; }### Answer:
@Test public void testExtractingMostCommonLicense() throws Exception { Set<String> mostCommonLicenses = DocxGenerator.extractMostCommonLicenses(obligationParsingResults, 100); assertThat(mostCommonLicenses.size(), is(1)); assertThat(mostCommonLicenses.toArray(new String[1])[0], is("License1")); mostCommonLicenses = DocxGenerator.extractMostCommonLicenses(obligationParsingResults, 3); assertThat(mostCommonLicenses.size(), is(98)); }