Skip to content

Commit

Permalink
JAMES-2404 Fix Eclipse warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aduprat committed May 29, 2018
1 parent 0bde59b commit 2129cba
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.ZoneId;
import java.util.Optional;

import javax.mail.Flags;

Expand All @@ -48,6 +47,7 @@
import org.apache.james.mailbox.tika.TikaHttpClientImpl;
import org.apache.james.mailbox.tika.TikaTextExtractor;
import org.apache.james.metrics.api.NoopMetricFactory;
import org.assertj.core.api.iterable.Extractor;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
Expand Down Expand Up @@ -473,11 +473,18 @@ public void otherAttachmentsShouldBeenIndexedWhenOneOfThemCannotBeParsed() throw

// Then
assertThat(indexableMessage.getAttachments())
.extracting(MimePart::getTextualBody)
.contains(Optional.of("first attachment content"));
assertThat(indexableMessage.getAttachments())
.extracting(MimePart::getTextualBody)
.contains(Optional.of("third attachment content"));
.extracting(new TextualBodyExtractor())
.contains("first attachment content", TextualBodyExtractor.NO_TEXTUAL_BODY, "third attachment content");
}

private static class TextualBodyExtractor implements Extractor<MimePart, String> {

public static final String NO_TEXTUAL_BODY = "The textual body is not present";

@Override
public String extract(MimePart input) {
return input.getTextualBody().orElse(NO_TEXTUAL_BODY);
}
}

@Test
Expand Down

0 comments on commit 2129cba

Please sign in to comment.