### Question:
ExtendedMimeMessage extends MimeMessage { public String getType() { try { return getHeader(XMAIL_TYPE_HEADER, null); } catch (MessagingException e) { throw new RuntimeException("Failed to get Type header", e); } } ExtendedMimeMessage();  ExtendedMimeMessage(Session session, InputStream is);  ExtendedMimeMessage(MimeMessage source); static ExtendedMimeMessage wrap(MimeMessage message); boolean isEmpty(); void setType(String mailType); String getType(); void setMessageId(String messageId); boolean ensureSaved(); @Override void setHeader(String name, String value); String getUniqueMessageId();  }### Answer:
@Test public void getType() throws Exception { ExtendedMimeMessage message = new ExtendedMimeMessage(); message.setHeader(XMAIL_TYPE_HEADER, TEST_XMAIL_TYPE); assertThat(message.getType(), equalTo(TEST_XMAIL_TYPE)); }
@Test public void getTypeWhenException() { Throwable exception = assertThrows(RuntimeException.class, () -> { ExtendedMimeMessage message = new ThrowingeExtendedMimeMessage(); message.getType(); }); assertEquals("Failed to get Type header", exception.getMessage()); assertEquals("MessagingException: error", ExceptionUtils.getRootCauseMessage(exception)); }