### Question:
BetterMimeMessage extends MimeMessage { public float getSpamLevel() throws MessagingException { String[] spamScores = this.mimeMessage.getHeader(SPAM_LEVEL_HEADER); if (spamScores != null && spamScores.length > 0) { return Float.parseFloat(spamScores[0]); } return 0f; } 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 testGetSpamLevel() throws Exception { MimeMessage automatic = mock(MimeMessage.class); when(automatic.getHeader("X-Spam-Score")).thenReturn(new String[]{"4.32"}); BetterMimeMessage instance = new BetterMimeMessage(automatic); assertEquals(4.32, instance.getSpamLevel(), 0.01f); automatic = mock(MimeMessage.class); when(automatic.getHeader("X-Spam-Score")).thenReturn(null); instance = new BetterMimeMessage(automatic); assertEquals(0.0f, instance.getSpamLevel(), 0.01f); }