### Question:
TooEmail { public Message createMessage(ISPObservation obs) { final TooType tooType = Too.get(obs); if (tooType == TooType.none) { LOG.log(Level.WARNING, "Tried to email alert for non-TOO observation."); return null; } ISPProgram prg = obs.getProgram(); SPProgram prgDo = (SPProgram) prg.getDataObject(); Properties props = _getTemplateProperties(obs, prgDo); String subj = _subjTemplate.subsitute(props); String body = _bodyTemplate.subsitute(props); InternetAddress[] toAddrs = _getToAddress(prgDo, tooType); InternetAddress[] ccAddrs = _getCcAddress(prgDo, tooType); InternetAddress[] bccAddrs = _lookupAddresses(tooType, DestinationType.bcc); String notifiedMsg = _getNotifiedString(toAddrs, ccAddrs); body = body + "\n\n" + notifiedMsg; Properties sessionProps = new Properties(); sessionProps.put("mail.transport.protocol", "smtp"); sessionProps.put("mail.smtp.host", _smtpHost); Session session = Session.getInstance(sessionProps, null); MimeMessage mess = new MimeMessage(session); try { if (toAddrs.length > 0) { mess.addRecipients(Message.RecipientType.TO, toAddrs); } if (ccAddrs.length > 0) { mess.addRecipients(Message.RecipientType.CC, ccAddrs); } if (bccAddrs.length > 0) { mess.addRecipients(Message.RecipientType.BCC, bccAddrs); } mess.setFrom(_sender); mess.setSubject(subj); mess.setText(body); } catch (MessagingException ex) { LOG.log(Level.WARNING, "Problem creating message.", ex); return null; } return mess; } TooEmail(TooEmailConfig conf); Message createMessage(ISPObservation obs);  }### Answer:
@Test public void testMessages() throws Exception { for (TooType too : TooType.values()) { for (Site site : Site.values()) { TestTooEmailConfig conf; conf = new TestTooEmailConfig(site, createDoc()); Too.set(getProgram(), too); Message m = (new TooEmail(conf)).createMessage(getObs()); if (too == TooType.none) { assertNull(m); continue; } verifyMessage(m, too, site); } } }