@Test void textTest() throws Exception { InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/Text.txt"); assertThat(inputStream).isNotNull(); assertThat(textExtractor.extractContent(inputStream, ContentType.of("text/plain")).getTextualContent()) .isPresent() .asString() .contains("This is some awesome text text."); }
@Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType.mediaType().equals(TEXT)) { return jsoupTextExtractor.extractContent(inputStream, contentType); } return metricFactory.decorateSupplierWithTimerMetric("tikaTextExtraction", Throwing.supplier( () -> performContentExtraction(inputStream, contentType)) .sneakyThrow()); }
TikaTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType.mediaType().equals(TEXT)) { return jsoupTextExtractor.extractContent(inputStream, contentType); } return metricFactory.decorateSupplierWithTimerMetric("tikaTextExtraction", Throwing.supplier( () -> performContentExtraction(inputStream, contentType)) .sneakyThrow()); } }
TikaTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType.mediaType().equals(TEXT)) { return jsoupTextExtractor.extractContent(inputStream, contentType); } return metricFactory.decorateSupplierWithTimerMetric("tikaTextExtraction", Throwing.supplier( () -> performContentExtraction(inputStream, contentType)) .sneakyThrow()); } @Inject  TikaTextExtractor(MetricFactory metricFactory, TikaHttpClient tikaHttpClient); }
TikaTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType.mediaType().equals(TEXT)) { return jsoupTextExtractor.extractContent(inputStream, contentType); } return metricFactory.decorateSupplierWithTimerMetric("tikaTextExtraction", Throwing.supplier( () -> performContentExtraction(inputStream, contentType)) .sneakyThrow()); } @Inject  TikaTextExtractor(MetricFactory metricFactory, TikaHttpClient tikaHttpClient); @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType); ParsedContent performContentExtraction(InputStream inputStream, ContentType contentType); }
TikaTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType.mediaType().equals(TEXT)) { return jsoupTextExtractor.extractContent(inputStream, contentType); } return metricFactory.decorateSupplierWithTimerMetric("tikaTextExtraction", Throwing.supplier( () -> performContentExtraction(inputStream, contentType)) .sneakyThrow()); } @Inject  TikaTextExtractor(MetricFactory metricFactory, TikaHttpClient tikaHttpClient); @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType); ParsedContent performContentExtraction(InputStream inputStream, ContentType contentType);  }