SpamAssassinInvoker { public boolean learnAsHam(InputStream message, Username username) throws MessagingException { return metricFactory.decorateSupplierWithTimerMetric( "spamAssassin-ham-report", Throwing.supplier( () -> reportMessageAs(message, username, MessageClass.HAM)) .sneakyThrow()); } SpamAssassinInvoker(MetricFactory metricFactory, String spamdHost, int spamdPort); SpamAssassinResult scanMail(MimeMessage message, Username username); SpamAssassinResult scanMail(MimeMessage message); boolean learnAsSpam(InputStream message, Username username); boolean learnAsHam(InputStream message, Username username);  }
@Test public void learnAsHamShouldReturnTrueWhenLearningWorks() throws Exception { MimeMessage mimeMessage = MimeMessageUtil.mimeMessageFromStream( ClassLoader.getSystemResourceAsStream("spamassassin_db/ham/ham2")); boolean result = testee.learnAsHam(mimeMessage.getInputStream(), USERNAME); assertThat(result).isTrue(); }