ReadingTimeCalculatorImpl implements ReadingTimeCalculator { @Override public Optional<Duration> calculate(GroupedModel groupedModel) { ReadingTimeModelInfo<GroupedModel> readingTimeModelInfo = (ReadingTimeModelInfo<GroupedModel>)_serviceTrackerMap.getService( groupedModel.getModelClassName()); if (readingTimeModelInfo == null) { return Optional.empty(); } return calculate( readingTimeModelInfo.getContent(groupedModel), readingTimeModelInfo.getContentType(groupedModel), readingTimeModelInfo.getLocale(groupedModel)); }  @Override Optional<Duration> calculate(GroupedModel groupedModel); @Override Optional<Duration> calculate(
		String content, String contentType, Locale locale);  }
@Test public void testAcceptsHTMLAndText() { ReadingTimeCalculator readingTimeCalculator = new ReadingTimeCalculatorImpl(); for (String contentType : _supportedContentTypes) { Optional<Duration> readingTimeOptional = readingTimeCalculator.calculate( StringUtil.randomString(), contentType, LocaleUtil.getDefault()); Assert.assertTrue(readingTimeOptional.isPresent()); } }
@Test public void testDoesNotAcceptPDFs() { ReadingTimeCalculator readingTimeCalculator = new ReadingTimeCalculatorImpl(); Optional<Duration> readingTimeOptional = readingTimeCalculator.calculate( StringUtil.randomString(), ContentTypes.APPLICATION_PDF, LocaleUtil.getDefault()); Assert.assertFalse(readingTimeOptional.isPresent()); }