### Question:
BetterMimeMessage extends MimeMessage { public boolean isSpam() throws MessagingException { String[] spamFlags = this.mimeMessage.getHeader(SPAM_FLAG_HEADER); if (spamFlags != null) { for (String flag : spamFlags) { if ("YES".equalsIgnoreCase(flag)) { return true; } } } return false; } BetterMimeMessage(MimeMessage message); boolean isSpam(); float getSpamLevel(); boolean isBounced(); static final String SPAM_FLAG_HEADER; static final String SPAM_LEVEL_HEADER; static final String AUTO_SUBMITTED_HEADER; }### Answer:
@Test public void testIsSpam() throws Exception { MimeMessage automatic = mock(MimeMessage.class); when(automatic.getHeader("X-Spam-Flag")).thenReturn(new String[]{"YES"}); BetterMimeMessage instance = new BetterMimeMessage(automatic); assertTrue(instance.isSpam()); automatic = mock(MimeMessage.class); when(automatic.getHeader("X-Spam-Flag")).thenReturn(new String[]{"NO"}); instance = new BetterMimeMessage(automatic); assertFalse(instance.isSpam()); automatic = mock(MimeMessage.class); when(automatic.getHeader("X-Spam-Flag")).thenReturn(null); instance = new BetterMimeMessage(automatic); assertFalse(instance.isSpam()); }