@Test
public void testToMap() throws Exception {

  EmailData emailData = new EmailData("data1", workflowInstance, catalogs, failedOperation, incidents);
  Map<String, Object> map = emailData.toMap();
  Object catalogs = map.get("catalogs");
  Assert.assertNotNull(catalogs);
  Assert.assertTrue(catalogs instanceof HashMap);
  Object catalogHash = ((HashMap) catalogs).get("episode");
  Assert.assertNotNull(catalogHash);
  Assert.assertTrue(catalogHash instanceof HashMap);
  Assert.assertEquals("Test Media Package", ((HashMap) catalogHash).get("title"));
  catalogHash = ((HashMap) catalogs).get("series");
  Assert.assertNotNull(catalogHash);
  Assert.assertTrue(catalogHash instanceof HashMap);
  Assert.assertEquals("20140119997", ((HashMap) catalogHash).get("identifier"));
  Object mp = map.get("mediaPackage");
  Assert.assertNotNull(mp);
  Assert.assertTrue(mp instanceof MediaPackage);
  Assert.assertEquals("Test Media Package", ((MediaPackage) mp).getTitle());
  Object wf = map.get("workflow");
  Assert.assertNotNull(wf);
  Assert.assertTrue(wf instanceof WorkflowInstance);
  Assert.assertEquals(1, ((WorkflowInstance) wf).getId());
  Object wfConf = map.get("workflowConfig");
  Assert.assertNotNull(wfConf);
  Assert.assertTrue(wfConf instanceof Map);
  Assert.assertEquals("user@domain.com", ((Map) wfConf).get("emailAddress"));
  Object op = map.get("failedOperation");
  Assert.assertNotNull(op);
  Assert.assertTrue(op instanceof WorkflowOperationInstance);
  Assert.assertEquals("operation1", ((WorkflowOperationInstance) op).getTemplate());
  Object inc = map.get("incident");
  Assert.assertNotNull(inc);
  Assert.assertTrue(inc instanceof List);
  Assert.assertEquals(2, ((List) inc).size());
  Assert.assertTrue(((List) inc).contains(incident1));
  Assert.assertTrue(((List) inc).contains(incident2));
}